规则
使用两个空格缩进
eslint: indent
字符串使用单引号
eslint: quotes
禁止出现未使用过的变量
eslint: no-unused-vars
关键字后使用空格
eslint: keyword-spacing
在function的左括号之前使用一致的空格
eslint: space-before-function-paren
要求使用 === 和 !==
此外: obj == null 被允许检查 null || undefined
eslint: eqeqeq
要求操作符周围有空格
eslint: space-infix-ops
强制在逗号后使用一致的空格
eslint: comma-spacing
强制在代码块中使用一致的大括号风格
eslint: brace-style
强制所有控制语句使用一致的括号风格
eslint: curly
要求回调函数中有容错处理
eslint: handle-callback-err
始终使用window.全局作为前缀
eslint: no-undef
禁止出现多行空行
eslint: no-multiple-empty-lines
强制操作符使用一致的换行符
eslint: operator-linebreak
变量声明要分开声明
eslint: one-var
用附加的括号包含条件赋值。 这使得这个赋值(=)表达式有意,而不是一个等于(===)的拼写错误。
eslint: no-cond-assign
强制在单行代码块中使用一致的空格
eslint: block-spacing
使用驼峰命名变量和方法名
eslint: camelcase
禁止拖尾逗号
eslint: comma-dangle
强制使用一致的逗号风格
eslint: comma-style
点号之前换行(点号应该和属性在一行)
eslint: dot-location
文件必须以换行符结尾。
eslint: eol-last
在功能表示符和其调用之间不能有空格(No space between function identifiers and their invocations.)
eslint: func-call-spacing
强制在对象字面量的属性中键和值之间使用一致的间距
eslint: key-spacing
要求构造函数首字母大写
eslint: new-cap
要求调用无参构造函数时有圆括号
eslint: new-parens
强制 getter 和 setter 在对象中成对出现
eslint: accessor-pairs
要求在构造函数中有 super() 的调用
eslint: constructor-super
禁用 Array 构造函数
eslint: no-array-constructor
禁用 arguments.caller 或 arguments.callee
eslint: no-caller
禁止修改类声明的变量
eslint: no-class-assign
禁止修改 const 声明的变量
eslint: no-const-assign
禁止在条件中使用常量表达式(除了循环)
eslint: no-constant-condition
禁止在正则表达式中使用控制字符
eslint: no-control-regex
禁用bugger
eslint: no-debugger
禁止删除变量
eslint: no-delete-var
禁止 function 定义中出现重名参数
eslint: no-dupe-args
禁止类成员中出现重复的名称
eslint: no-dupe-class-members
禁止对象字面量中出现重复的 key
eslint: no-dupe-keys
禁止出现重复的 case 标签
eslint: no-duplicate-case
每个module 使用一个import的语句
eslint: no-duplicate-imports
禁用eval()
eslint: no-eval
禁止对 catch 子句的参数重新赋值
eslint: no-ex-assign
禁止扩展原生类型
eslint: no-extend-native
禁止不必要的 .bind() 调用
eslint: no-extra-bind
禁止不必要的布尔转换
eslint: no-extra-boolean-cast
禁止不必要的括号
eslint: no-extra-parens
使用break禁止 case 语句落空
eslint: no-fallthrough
禁止数字字面量中使用前导和末尾小数点
eslint: no-floating-decimal
禁止对 function 声明重新赋值
eslint: no-func-assign
不能对只读的全局变量重新赋值
eslint: no-global-assign
禁止使用类似 eval() 的方法
eslint: no-implied-eval
禁止在嵌套的块中出现变量声明或 function 声明
eslint: no-inner-declarations
禁止 RegExp 构造函数中存在无效的正则表达式字符串
eslint: no-invalid-regexp
禁止在字符串和注释之外不规则的空白
eslint: no-irregular-whitespace
禁用 iterator 属性
eslint: no-iterator
不允许标签与变量同名
eslint: no-label-var
禁用标签语句
eslint: no-labels
禁用不必要的嵌套块
eslint: no-lone-blocks
禁止空格和 tab 的混合缩进
eslint: no-mixed-spaces-and-tabs
禁止使用多个空格
eslint: no-multi-spaces
禁止使用多行字符串
eslint: no-multi-str
禁止在非赋值或条件语句中使用 new 操作符
eslint: no-new
禁止对 Function 对象使用 new 操作符
eslint: no-new-func
禁用 Object 的构造函数
eslint: no-new-object
禁止调用 require 时使用 new 操作符
eslint: no-new-require
禁止Symbol构造函数
eslint: no-new-symbol
禁止原函数包装实例
eslint: no-new-wrappers
禁止把全局对象作为函数调用
eslint: no-obj-calls
禁止在字符串中使用八进制转义序列
eslint: no-octal-escape
禁用八进制字面量
eslint: no-octal
禁止对 dirname 和 filename 进行字符串连接
eslint: no-path-concat
禁用 proto 属性
eslint: no-proto
禁止多次声明同一变量
eslint: no-redeclare
禁止正则表达式字面量中出现多个空格
eslint: no-regex-spaces
禁止在 return 语句中使用赋值语句
eslint: no-return-assign
禁止自我赋值
eslint : no-self-assign
禁止自身比较
eslint: no-self-compare
禁用逗号操作符
eslint: no-sequences
禁止覆盖受限制的标识符
eslint: no-shadow-restricted-names
禁用稀疏数组
eslint: no-sparse-arrays
disallow tabs in file
eslint: no-tabs
disallow template literal placeholder syntax in regular strings
eslint: no-template-curly-in-string
禁止在构造函数中,在调用 super() 之前使用 this 或 super
eslint: no-this-before-super
禁止抛出异常字面量
eslint: no-throw-literal
禁用行尾空格
eslint: no-trailing-spaces
禁止将变量初始化为 undefined
eslin: no-undef-init
禁用未修改的循环条件
eslint: no-unmodified-loop-condition
禁止可以在有更简单的可替代的表达式时使用三元操作符
eslint: no-unneeded-ternary
禁止在return、throw、continue 和 break 语句之后出现不可达代码
eslint: no-unreachable
禁止在 finally 语句块中出现控制流语句
eslint: no-unsafe-finally
disallow negating the left operand of relational operators
eslint: no-unsafe-negation
禁止不必要的 .call() 和 .apply()
disallow unnecessary computed property keys in object literals
eslint: no-useless-computed-key
禁用不必要的构造函数
eslint: no-useless-constructor
禁用不必要的转义字符
eslint: no-useless-escape
disallow renaming import, export, and destructured assignments to the same name
eslint: no-useless-rename
禁用 with 语句
eslint: no-with
保持一致性将对象的属性放在不同的行上
eslint: object-property-newline
enforce spacing between rest and spread operators and their expressions
eslint: rest-spread-spacing
强制分号前后有空格
eslint: semi-spacing
强制在块之前使用一致的空格
eslint:space-before-blocks
强制在圆括号内使用一致的空格
eslint: space-in-parens
强制在一元操作符前后使用一致的空格
eslint: space-unary-ops
强制在注释中 // 或 /* 使用一致的空格
eslint: spaced-comment
要求或禁止模板字符串中的嵌入表达式周围空格的使用
eslint: template-curly-spacing
要求使用 isNaN() 检查 NaN
eslint: use-isnan
强制 typeof 表达式与有效的字符串进行比较
eslint: valid-typeof
要求 IIFE 使用括号括起来
eslint: wrap-iife
强制在 yield 表达式中 周围使用空格
eslint: yield-star-spacing
要求或禁止 “Yoda” 条件
eslint: yoda
禁止出现令人困惑的多行表达式
eslint: no-unexpected-multiline
要求或禁止使用分号而不是 ASI
eslint: semi
如果想要调过某个规则的校验,可以采用eslint-disabled。
参考资料:
https://standardjs.com/readme-zhcn.html
http://eslint.cn/