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?
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With