ESLint -- 要求使用 === 和 !== (eqeqeq)

详细讲解请看eqeqeq

配置文件代码:

    // require the use of === and !==
    // http://eslint.org/docs/rules/eqeqeq
    eqeqeq: ['error', 'always', { null: 'ignore' }],

always 选项 "always"(默认)强制在任何情况下都使用 === 和 !==(除非你选择对 null 有更具体的处理[见下文])

该规则可以有第二个参数,是个对象,支持以下属性:

"null": 自定义如何对待 null 字面量。可能的值:

  • always (默认) - 总是使用 === 或 !==.
  • never - 从不和 null 一起使用 === 或 !==。
  • ignore - 不要对 null 应用此规则。

results matching ""

    No results matching ""