ESLint 规则或插件来识别注释代码
ES-Lint Rule or Plugin to identify the commented code
我试图找到 ES-Lint 的规则或插件来识别注释代码,以便我可以删除那些不必要的代码并清理我的存储库。
我想识别多行代码和单行代码:
/* import CreateIncentive from './containers/create-incentive';
import AffiliateFilters from './containers/affiliate-filters'; */
//import NotificationsSettings from './containers/notifications-settings';
我已尝试使用以下规则,但它无法识别上述类型的代码:
"rules": {
"no-warning-comments": [1, { "terms": ["todo", "fixme", "xxx"], "location": "anywhere" }],
"spaced-comment": ["error", "always", { "exceptions": ["-", "+"] }]
}
也许你可以试试no-inline-comments
ESLint规则
所以我找到了考虑 Sonar 代码注释规则的方法。这只是 Quality Profile 的问题。我已将 DEFAULT 配置文件设置为 sonar-way,但它只指定了 100 条规则。
虽然另一个可用于 JAVASCRIPT 的配置文件是 Sonar way Recommended,它有 148 条规则,它还包括规则识别注释的代码。
因此将默认配置文件切换为 Sonar Way Recommended 具有默认规则来识别 multi-line 或单行代码。
我为此创建了一个插件:
安装
npm install eslint-plugin-no-comments --save-dev
配置
// eslintrc.js
{
"plugins": ["eslint-plugin-no-comments"],
"rules": {
"eslint-plugin-no-comments/disallowComments": "error"
}
}
我试图找到 ES-Lint 的规则或插件来识别注释代码,以便我可以删除那些不必要的代码并清理我的存储库。
我想识别多行代码和单行代码:
/* import CreateIncentive from './containers/create-incentive';
import AffiliateFilters from './containers/affiliate-filters'; */
//import NotificationsSettings from './containers/notifications-settings';
我已尝试使用以下规则,但它无法识别上述类型的代码:
"rules": {
"no-warning-comments": [1, { "terms": ["todo", "fixme", "xxx"], "location": "anywhere" }],
"spaced-comment": ["error", "always", { "exceptions": ["-", "+"] }]
}
也许你可以试试no-inline-comments
ESLint规则
所以我找到了考虑 Sonar 代码注释规则的方法。这只是 Quality Profile 的问题。我已将 DEFAULT 配置文件设置为 sonar-way,但它只指定了 100 条规则。
虽然另一个可用于 JAVASCRIPT 的配置文件是 Sonar way Recommended,它有 148 条规则,它还包括规则识别注释的代码。
因此将默认配置文件切换为 Sonar Way Recommended 具有默认规则来识别 multi-line 或单行代码。
我为此创建了一个插件:
安装
npm install eslint-plugin-no-comments --save-dev
配置
// eslintrc.js
{
"plugins": ["eslint-plugin-no-comments"],
"rules": {
"eslint-plugin-no-comments/disallowComments": "error"
}
}