SoniCoder
SoniCoder

Reputation: 4174

How to turn off JSHint error in Webstorm?

I have the following error for my files in tests: Expected an assignment or function call and instead saw an expression. It is generated from Chai libraries asserts. How can I turn it off in Webstorm? It makes the line yellow and shows a warning.

Upvotes: 18

Views: 9983

Answers (4)

Jai Kumaresh
Jai Kumaresh

Reputation: 835

It's for phpstorm

Disable JSHint and configure its behavior in PhpStorm In the Settings/Preferences dialog ⌘ , go to Languages and Frameworks | JavaScript | Code Quality Tools | JSHint.

On the JSHint page that opens, Unselect the Enable checkbox.

Refer link: https://www.jetbrains.com/help/phpstorm/jshint.html

enter image description here

Upvotes: 4

Zorayr
Zorayr

Reputation: 24902

Had the same issue when using chai, here is what fixed it for me —

  1. Open Preferences by tapping on WebStorm then Preferences
  2. Search for, Expression statement which is not assignment
  3. Disable the inspection (see screenshot), hit Apply & OK

Expression statement which is not assignment

Upvotes: 18

David Noha
David Noha

Reputation: 670

The issue here is that WebStorm generates internal warnings using JSHint, but this internal mechanism is entirely separate from enabling JSHint under Settings/Languages & Frameworks/JavaScript/Code Quality Tools/JSHint. (If you enable JSHint there, you'll get even more warnings, it seems like JSHint is basically running twice with different configurations.)

You need to configure the inspections in Settings/Editor/Inspections, then in the list on the right, find JavaScript/JavaScript validity issues. That worked for me to remove the Chai warnings. (I am using the WebStorm 11 EAP at the moment.)

Upvotes: 15

lena
lena

Reputation: 93728

Settings/Languages & Frameworks/JavaScript/Code Quality Tools/JSHint, Relaxing Options/Suppress warnings about the use of expressions as statements

Upvotes: 1

Related Questions