i have already tried to find eslint rules or options in the project but i could not find these. i am using angularjs with mvc5 template type of aspnet zero. How to disable eqeqeq in visual studio for eslint in aspnet zero ?
The OP is asking how to disable this One Rule for the Entire Project.
The eqeqeq
rule is explained here: https://eslint.org/docs/rules/eqeqeq
To change one rule for the entire project, you should edit the .eslintrc
file.
To find this file, you could look up the file path in Visual Studio 2017 using:
Tools -> Options -> TextEditor -> JavaScript/TypeScript -> Linting
It'll probably be somewhere like: C:\Users\<UserName>\.eslintrc
Editing the file you will see this near the top (around Line 20):
"rules": {
"eqeqeq": 2,
The following are synonymous: 0
= "off"
, 1
= "warn"
, and 2
= "error"
.
You may disable the rule by changing the 2nd line to this:
"eqeqeq": "off",
I based this off of the information found here:
https://eslint.org/docs/user-guide/configuring#configuring-rules
Add this line in your File:
/*eslint-disable eqeqeq*/
OR
/*eslint eqeqeq: "off"*/
It is important you add this near the top of your Javascript file before your scripts.
This is because it takes affect after the line you add this comment to.
How to do this is buried in this link under the section "Disabling Rules with Inline Comments":
https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments
If you're interested in changing the equality-operator warnings so they are "smarter" and won't always throw warnings (when it is obvious they do not apply), then this may be the better option.
This way you still keep these warnings when it really matters.
At the Project Level, use this in the .eslintrc
file:
"eqeqeq": ["error", "smart"],
OR
At the File Level, use this:
/*eslint eqeqeq: ["error", "smart"]*/
This "Smart" feature is further explained here:
https://eslint.org/docs/rules/eqeqeq#smart
Dislaimer: I have verified this works at the File Level, but have not tested at the Project Level.
The .eslintrc
file appears to be in Json, and these proposed edits fit the expected format.
It also follows the examples I found in the links above.
Add the below line to the JavaScript code to disable checking.
/*eslint eqeqeq: ["error", "smart"]*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With