I'm trying to find the rules or plugins of ES-Lint to identify the mented code so that I can remove that unnecessary code and clean my repository.
I would like to identify the multiline as well as single line code:
/* import CreateIncentive from './containers/create-incentive';
import AffiliateFilters from './containers/affiliate-filters'; */
//import NotificationsSettings from './containers/notifications-settings';
I have tried with below rules Bt it is not identifying the above kind of code :
"rules": {
"no-warning-ments": [1, { "terms": ["todo", "fixme", "xxx"], "location": "anywhere" }],
"spaced-ment": ["error", "always", { "exceptions": ["-", "+"] }]
}
I'm trying to find the rules or plugins of ES-Lint to identify the mented code so that I can remove that unnecessary code and clean my repository.
I would like to identify the multiline as well as single line code:
/* import CreateIncentive from './containers/create-incentive';
import AffiliateFilters from './containers/affiliate-filters'; */
//import NotificationsSettings from './containers/notifications-settings';
I have tried with below rules Bt it is not identifying the above kind of code :
"rules": {
"no-warning-ments": [1, { "terms": ["todo", "fixme", "xxx"], "location": "anywhere" }],
"spaced-ment": ["error", "always", { "exceptions": ["-", "+"] }]
}
Share
Improve this question
asked Aug 20, 2020 at 11:36
HarshalHarshal
3,6229 gold badges39 silver badges67 bronze badges
4 Answers
Reset to default 3eslint-plugin-etc
Is a great suite of extra ESLint rules (often TS-related) and they offer one for mented out code:
https://github./cartant/eslint-plugin-etc/blob/main/docs/rules/no-mented-out-code.md
Add it to your ESLint config
rules: {
"etc/no-mented-out-code": "error"
}
I have created a plugin for that purpose:
Install
npm install eslint-plugin-no-ments --save-dev
Configuration
// eslintrc.js
{
"plugins": ["eslint-plugin-no-ments"],
"rules": {
"eslint-plugin-no-ments/disallowComments": "error"
}
}
Full Documentation
So I found the way to consider the code mented rule for Sonar. It is just a matter of Quality Profile.I had set the DEFAULT profile to sonar-way but it has only 100 rules specified.
While the other profile available for JAVASCRIPT is Sonar way Remended which has 148 rules and it also includes the rule to identify the code mented.
So switching the default profile to Sonar Way Remended had the default rule to identify the mented code for multi-line or single line code.
Maybe you can try no-inline-ments
ESLint rule
https://eslint/docs/rules/no-inline-ments