简体   繁体   English

如何关闭 Webstorm 中的 JSHint 错误?

[英]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.我在测试中的文件有以下错误: Expected an assignment or function call and instead saw an expression. It is generated from Chai libraries asserts.它是从 Chai 库断言生成的。 How can I turn it off in Webstorm?如何在 Webstorm 中关闭它? It makes the line yellow and shows a warning.它使线变黄并显示警告。

Had the same issue when using chai , here is what fixed it for me — 使用chai时有同样的问题,这就是为我修复的问题 -

  1. Open Preferences by tapping on WebStorm then Preferences 点击WebStorm然后点击偏好设置打开偏好Preferences
  2. Search for, Expression statement which is not assignment 搜索, Expression statement which is not assignment
  3. Disable the inspection (see screenshot), hit Apply & OK 禁用检查(见屏幕截图),点击Apply&OK

表达式语句不是赋值

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. 这里的问题是WebStorm 使用 JSHint生成内部警告,但是这个内部机制完全独立于在Settings / Languages&Frameworks / JavaScript / Code Quality Tools / JSHint下启用JSHint。 (If you enable JSHint there, you'll get even more warnings, it seems like JSHint is basically running twice with different configurations.) (如果你在那里启用JSHint,你会得到更多的警告,看起来JSHint基本上是用不同的配置运行两次。)

You need to configure the inspections in Settings/Editor/Inspections, then in the list on the right, find JavaScript/JavaScript validity issues. 您需要在Settings / Editor / Inspections中配置检查,然后在右侧列表中查找JavaScript / JavaScript有效性问题。 That worked for me to remove the Chai warnings. 这对我有用,可以删除Chai警告。 (I am using the WebStorm 11 EAP at the moment.) (我现在正在使用WebStorm 11 EAP。)

设置/语言和框架/ JavaScript /代码质量工具/ JSHint,放宽选项/禁止关于将表达式用作语句的警告

It's for phpstorm这是为了 phpstorm

Disable JSHint and configure its behavior in PhpStorm In the Settings/Preferences dialog ⌘ , go to Languages and Frameworks |禁用 JSHint 并在 PhpStorm 中配置其行为 在 Settings/Preferences 对话框 ⌘ 中,转到 Languages and Frameworks | JavaScript | JavaScript | Code Quality Tools |代码质量工具 | JSHint. JSHint。

On the JSHint page that opens, Unselect the Enable checkbox.在打开的 JSHint 页面上,取消选中启用复选框。

Refer link: https://www.jetbrains.com/help/phpstorm/jshint.html参考链接: https : //www.jetbrains.com/help/phpstorm/jshint.html

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM