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 ments 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?
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 ments 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?
Share Improve this question asked Sep 22, 2020 at 1:36 RichySTRichyST 2731 gold badge3 silver badges12 bronze badges 3- gitlab enterprise and github team has the feature to lock the .eslintrc file so no one has permission to change it – arslan2012 Commented Sep 22, 2020 at 2:16
-
1
@arslan2012 I'm specifically referring to the ments
/* eslint-disable */
put in files by other programmers – RichyST Commented Sep 22, 2020 at 2:35 - You can probably add a checklist in the PR template and have an item stating that you should do you best to lint your code or at least leave ments for code where an eslint-disable is used. – Joshua Commented Sep 22, 2020 at 3:57
2 Answers
Reset to default 17Wow, 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-ments
in your .eslintrc.*
file add
{
"extends": [
"eslint:remended",
"plugin:eslint-ments/remended"
],
"rules": {
"eslint-ments/no-use": ["error", {"allow": []}]
}
}
For more info check this link https://mysticatea.github.io/eslint-plugin-eslint-ments/rules/no-use.html
If you don't want to add an additional plugin, you can use eslint's no-warning-ments rule to achieve this. Add the following line under rules in your eslint config file to disable eslint-disable term in ments which has the same effect.
"no-warning-ments": ["warn", { "terms": ["eslint-disable"], "location": "anywhere" }]