Suppress “Expected '===' and instead saw '=='.” error in jslint

后端 未结 5 1699
轮回少年
轮回少年 2020-12-29 19:25

How can I stop the error message Expected \'===\' and instead saw \'==\'. from appearing in jslint. Doesn\'t seem to be an option.

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-29 20:04

    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
    

    From the documentation: http://jshint.com/docs/options/#eqeqeq

    Edit:

    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.

    For example:

    "123" == 123          // true, I'm lazy and JSHint hates me
    "123" === 123         // false, no love
    Number("123") === 123 // true, no warning
    

提交回复
热议问题