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:
- Created 9 years ago
- Comments:6 (4 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
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:@platinumazure
I have solved by the following code.
it seems the rules are changed.