禁止“ Expected'===”,而是看到“ ==”。” jslint中的错误 [英] Suppress "Expected '===' and instead saw '=='." error in jslint
问题描述
我如何停止错误消息预期的'===',而是看到'=='。
不在jslint中显示。
似乎不是一个选择。
How can I stop the error message Expected '===' and instead saw '=='.
from appearing in jslint.
Doesn't seem to be an option.
推荐答案
对于使用JSHint的用户,可以通过以下方式关闭此警告:在您的JSHint选项(通常是 .jshintrc )中将选项 eqeqeq 设置为false
For those using JSHint, you can turn off this warning by setting the option eqeqeq to false in your JSHint options (usually .jshintrc)
"eqeqeq": false
从文档中: http://jshint.com/docs/options/#eqeqeq
编辑:
如果您想成为一个好公民,并修改代码以使用建议的比较而不是关闭警告,请确保比较的两面都在使用相同的类型。
If you want to be a good citizen and fix your code to use the recommended comparison instead of turning the warning off, make sure both sides of the comparison are using the same type.
例如:
"123" == 123 // true, I'm lazy and JSHint hates me
"123" === 123 // false, no love
Number("123") === 123 // true, no warning
这篇关于禁止“ Expected'===”,而是看到“ ==”。” jslint中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!