Reputation: 476
Is it possible to enable Eslint custom rule via comments for some code fragment only? Eg. I'd like to change rule setting only for single function in file (func2
) and the rest should use global Eslint setting. Something like this:
func1() {
...
};
/* eslint-enable sonarjs/cognitive-complexity: ["error", 16] */
func2() {
...
}
/* eslint-disable sonarjs/cognitive-complexity: ["error", 16] */
func3() {
...
}
...so only func2
can reach 16 points of complexity - other functions shouldn't exceed complexity value from global settings.
Upvotes: 1
Views: 3169
Reputation: 2352
If you want disable cognitive-complexity
in one function. Try this:
// eslint-disable-next-line sonarjs/cognitive-complexity
func2() {
...
}
Upvotes: 0
Reputation: 13087
You can do this but only on a per file bais. In your eslintrc file you can do
override: {
files: [...],
rules: {...},
}
Upvotes: 1