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.

eslint comments to enable/disable not respecting order specified in code

See original GitHub issue
/*eslint camelcase: 0*/
var queryParams = {
    first_param: 'foo'
};
queryParams.second_param = 'bar';
/*eslint camelcase: 1*/
  3:1   warning  Identifier 'first_param' is not in camel case   camelcase
  5:12  warning  Identifier 'second_param' is not in camel case  camelcase
✖ 2 problems

It looks like the second /*eslint*/ comment takes precedence. Default rule is camelcase: 2. If I remove the second /*eslint*/ comment, no errors are thrown.

Use Case: Legacy APIs sometimes use underscores for params.

I’ve also verified this is the case with other rules as well.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

11reactions
nzakascommented, Aug 5, 2014

It’s not possible to change rules like that. Basically, ESLint goes through and finds all comments that of the form /*eslint foo:0*/ before it starts parsing and evaluating the code. If you want to turn off rules for a particular piece of code, you need to use /*eslint-disable*/ and /*eslint-enable*/ to turn it back on:

/*eslint-disable camelcase*/
var queryParams = {
    first_param: 'foo'
};
queryParams.second_param = 'bar';
/*eslint-enable camelcase*/
0reactions
calidioncommented, Mar 2, 2016

@platinumazure

I have solved by the following code.

/*eslint camelcase: [2, {properties: "never"}]*/

it seems the rules are changed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Turning off eslint rule for a specific line
I use a combination of prettier and eslint to format my code. This does not allow for inline comments. Many /* eslint-disable-next-line ......
Read more >
eslint-comments/no-use - mysticatea
allow option is an array to allow specified directive-comments. The value of the array is some of the following strings: "eslint"; "eslint-disable ......
Read more >
How To Lint and Format Code with ESLint in Visual Studio ...
To customize the errors that trigger ESLint or to disable ESLint's response to certain pieces of code, you will add key-value pairs to...
Read more >
User Guide | eslint-plugin-vue
Official ESLint plugin for Vue.js. ... How to use a custom parser? # ... rules are applied to code that passes any of...
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