自我ESLint配置【仅供参考】
ESLint
Eslint配置:ESLint中文
Key | Value | Des |
---|---|---|
camelcase | 1 | 强制驼峰法命名 |
indent | [‘error’, 2] | 缩进风格四个空格 |
semi | [“error”, “never”] | 语句强制不要分号结尾 |
new-parens | 2 | new时必须加小括号 |
init-declarations | 1 | 声明时必须赋初值 |
eqeqeq | 2 | 必须使用全等 |
no-use-before-define | 2 | 未定义前不能使用 |
no-undef-init | 2 | 变量初始化时不能直接给它赋值为undefined |
no-undef | 1 | 不能有未定义的变量 |
no-sparse-arrays | 2 | 禁止稀疏数组 |
no-unreachable | 2 | 不能有无法执行的代码 |
no-unused-expressions | 2 | 禁止无用的表达式 |
no-void | 2 | 禁用void操作符 |
no-var | 1 | 禁用var定义变量 |
array-bracket-spacing | [2, “never”] | 不允许允许非空数组里面有多余的空格 |
block-scoped-var | 0 | 块语句中使用var |
comma-dangle | [2, “never”] | 对象字面量项尾不能有逗号 |
comma-style | [2, “last”] | ,号风格,换行时在行尾 |
consistent-this | [2, “context”] | this别名 |
quotes | [1, “single”] | 只允许单引号 |
以上Eslint配置都在 .eslintrc.js
>rules
字段中,如遇实在没办法编译的情况请注释验证即可