简体   繁体   English

ESLint 规则阻止用户禁用 ESLint 规则

[英]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.我有一个项目,其中只有很少的 ESLint 规则对所有协作者都是强制性的,不幸的是,我发现一些开发人员在没有正当理由的情况下禁用了一些规则,代码审查未能阻止这种情况。 Is there a way to configure ESLint to ignore comments disabling rules or for it to throw warnings whenever this happens?有没有办法将 ESLint 配置为忽略注释禁用规则或让它在发生这种情况时抛出警告?

I've been looking for a while and haven't found anything of the sort.我一直在寻找一段时间,但没有找到任何类似的东西。 Is there maybe another way to do this?有没有其他方法可以做到这一点?

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在你的.eslintrc.*文件中添加

{
    "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有关更多信息,请查看此链接https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/no-use.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM