Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESLint rule to block users from disabling ESLint rules

I have a project with very few ESLint rules that are mandatory for all the collaborators, unfortunately, I've found some developers have disabled some rules with no justification and the Code Review failed to stop this. Is there a way to configure ESLint to ignore comments disabling rules or for it to throw warnings whenever this happens?

I've been looking for a while and haven't found anything of the sort. Is there maybe another way to do this?

like image 660
RichyST Avatar asked Sep 22 '20 01:09

RichyST


People also ask

How do I disable ESLint rules?

If you want to disable an ESLint rule in a file or on a specific line, you can add a comment. On a single line: const message = 'foo'; console. log(message); // eslint-disable-line no-console // eslint-disable-next-line no-console console.

How do I disable block ESLint?

General case To temporarily turn off ESLint, you should add a block comment /* eslint-disable */ before the lines that you're interested in: /* eslint-disable */ console.


1 Answers

Wow, very cool scenario. But I feel sorry for the developers who might want to kick me for answering this. Follow the below steps

npm install --save-dev eslint eslint-plugin-eslint-comments

in your .eslintrc.* file add

{
    "extends": [
        "eslint:recommended",
        "plugin:eslint-comments/recommended"
    ],
    "rules": {
        "eslint-comments/no-use": ["error", {"allow": []}]
    }
}

For more info check this link https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-use.html

like image 139
Nav Kumar V Avatar answered Nov 15 '22 00:11

Nav Kumar V