Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESlint: Expected !== and instead saw !=

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 ?

like image 829
Sajjad Mahmood Avatar asked Jan 22 '18 05:01

Sajjad Mahmood


2 Answers

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.

like image 137
MikeTeeVee Avatar answered Nov 14 '22 08:11

MikeTeeVee


Add the below line to the JavaScript code to disable checking.

/*eslint eqeqeq: ["error", "smart"]*/  
like image 3
Alper Ebicoglu Avatar answered Nov 14 '22 08:11

Alper Ebicoglu