Feature request: eslint-disable-block or eslint-disable-next
See original GitHub issueThis is one almost real part of my code:
function unbindNode(object, key, node, eventOptions) {
if(typeof this === 'object' && whatever) {
eventOptions = node;
node = key;
key = object;
object = this;
} else {
checkObjectType(object, 'unbindNode');
}
...
no-param-reassign
shows errors “Assignment to function parameter…”. It’s OK but I need to use eslint-disable-line
for every line of the if
block. I have almost the same code in tens of files and I really don’t want to disable the rule globally.
I hope this proposition makes sense. At least istanbul has very similar feature /* istanbul ignore next */
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Rules - ESLint - Pluggable JavaScript Linter
Disabling Rules. Using configuration comments. To disable rule warnings in a part of a file, use block comments in the following format: /*...
Read more >Ignoring ESLint - next.config.js
If you'd like Next.js to produce production code even when your application has ESLint errors, you can disable the built-in linting step completely....
Read more >How to disable ESLint for some lines, files or folders
To turn off ESLint in the whole file, you can add /* eslint-disable */ in the first line of that file. Alternatively, you...
Read more >Turning off eslint rule for a specific file - Stack Overflow
1) Disabling "All rules" Two ways you can do this: Put /* eslint-disable-line */ at the end of the line(s), or /* eslint-disable-next-line...
Read more >How to ignore ESLint in Next.js ? - GeeksforGeeks
Example: Ignore ESLint in Next.Js, if the ESLint is enabled the production build of your application will fail automatically if any error is ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can use
/* eslint-disable rule-name */
and/* eslint-enable rule-name */
within the block. Note that those have to be block comments, not line comments.Yes, that’s two comments instead of one, but better than one per line.
My voice may be in the minority, but I would also like the ability to disable a rule per function. A common use case is decorating an object with extra properties, or updating summary/total properties. ESLint will complain with
no-param-reassign
about each assignment to properties of the object.I’d rather not add
// eslint-disable-line no-param-reassign
after each line that computes a new property for the object.