ESLint rule to block users from disabling ESLint rules

Viewed 634

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?

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

Related