question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: eslint-disable-block or eslint-disable-next

See original GitHub issue

This 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:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

32reactions
platinumazurecommented, Aug 13, 2016

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.

20reactions
dandvcommented, Jun 29, 2017

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.

function decorateObject(object) {
    ...
    object.someSummaryProp = ...  // eslint-disable-line no-param-reassign
    object.extraProperty1 = ...  // eslint-disable-line no-param-reassign
    object.extraProperty2 = ...  // eslint-disable-line no-param-reassign
}

I’d rather not add // eslint-disable-line no-param-reassign after each line that computes a new property for the object.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found