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.

New rule: eslint-disable-next-line ...

See original GitHub issue

Premise

With the // eslint-disable-line ... comment, lines can get a bit long. It’d be nice to be able to put the comment on the preceding line.

When does this rule warn? Please describe and show example code:

For example:

// eslint-disable-line no-extend-native
Map.prototype.updateGrid = function updateGrid(col, row) { 
  return this.merge({ col, row });
};

Instead of:

Map.prototype.updateGrid = function updateGrid(col, row) { // eslint-disable-line no-extend-native
  return this.merge({ col, row });
};

It’d be great if the parser was smart enough to recognize when the line is effectively blank, it’s referring to the next line. However, in case that’s unreasonable, let me propose a new rule: // eslint-disable-next-line ...

For example:

// eslint-disable-next-line no-extend-native
Map.prototype.updateGrid = function updateGrid(col, row) { 
  return this.merge({ col, row });
};

Is this rule preventing an error or is it stylistic?

Stylistic.

Why is this rule a candidate for inclusion instead of creating a custom rule?

Not sure if it can be written as a stand-alone rule.

Are you willing to create the rule yourself?

No. I’m not sure this is in my skill set.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
BYKcommented, Feb 13, 2016

@ilyavolodin I think the reason is /*eslint-disable */ requires a matching /*eslint-enable */ afterwards and doing that only for a single line, just because the line gets too long with the // eslint-disable-line directive is a bit wasteful. At least that’s how I feel and why I’d support something like this.

@bionikspoon is that accurate?

1reaction
platinumazurecommented, Feb 14, 2016

For what it’s worth, I would support this too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Turning off eslint rule for a specific line - Stack Overflow
To disable next line: // eslint-disable-next-line no-use-before-define var thing = new Thing();. Or use the single line syntax: var thing = new Thing(); ......
Read more >
Rules - ESLint - Pluggable JavaScript Linter
Rules are the core building block of ESLint. A rule validates if your code meets a certain expectation, and what to do if...
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 >
eslint-plugin-unicorn/no-abusive-eslint-disable.md at main
This rule makes you specify the rules you want to disable when using eslint-disable , eslint-disable-line or eslint-disable-next-line comments. If you want to ......
Read more >
Ignore Lines and Files In ESLint - Mastering JS
The // eslint-disable-line comment disables the no-eval rule for just that line. You can also disable the no-eval rule for an entire function ......
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