ESlint: Expected !== and instead saw !=

Sajjad Mahmood picture Sajjad Mahmood · Jan 22, 2018 · Viewed 9k times · Source

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 ?

Answer

MikeTeeVee picture MikeTeeVee · Jan 6, 2019

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

Disable One Rule at the Project Level:

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 -> Lintingenter image description here
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

Disable One Rule at the File Level:

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

Smarter is Better Than Disabling

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.