1.0.0 • Published 7 months ago

eslint-config-enn v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

规则介绍

这套规则是用于规范新奥数能团队开发习惯的一套基于eslint-config-airbnb拓展的一套eslint规则

安装(搭配prettier插件)

│ index.js ----------规则入口 │ package-lock.json │ package.json │ readme.md │ tree.txt │
└─rules best-pratices.js ----------最佳实践规则 error.js ----------possible error 规则 es6.js ---------- import.js ----------导入规则 strict.js ----------严格规则 styles.js ----------代码样式风格规则 variables.js ----------变量规则

npm i @shuneng/eslint-config-enn -D --registry=https://registry-npm.ennew.com/
// prettier.config.js 具体需要个性化配置的请自行去官网查看[官网地址](https://prettier.io/docs/en/options.html#arrow-function-parentheses)
module.exports = {
  printWidth: 300,
  useTabs: false, // 是否使用t
  singleQuote: true, // 使用单引号(默认false)
  bracketSpacing: true, // 对象字面量的大括号间使用空格(默认true)
  arrowParens: 'avoid', // 尽可能减少箭头函数括号
  trailingComma: 'all', // 拖尾逗号
};
/**
 * 内置了如下的全局变量
 * require: 0,
    Vue: 0,
    '$': 0,
    globalThis: 0,
    Element: 0,
    Vant: 0,
    module: 0
 * 
*/
本规则囊括了默认规则以及eslint-config-airbnb,覆盖了官网的大部分规则

!(https://img-blog.csdnimg.cn/20210610184238309.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDg1OTY2NQ==,size_16,color_FFFFFF,t_70#pic_center)

规则详情如需查看可访问 eslint 进行查阅
已启用规则
规则名称规则介绍预警级别是否可以fix
for-direction强制 “for” 循环中更新子句的计数器朝着正确的方向移动error
getter-return强制 getter 函数中出现 return 语句error
no-async-promise-executor禁止使用异步函数作为执行函数error
no-await-in-loop禁止在循环中出现 awaiterror
no-compare-neg-zero禁止与 -0 进行比较error
no-cond-assign禁止条件表达式中出现赋值操作符warn
no-console禁用 consolewarn
no-constant-condition禁止在条件中使用常量表达式error
no-control-regex禁止在正则表达式中使用控制字符warn
no-debugger禁用 debuggerwarn
no-dupe-args禁止 function 定义中出现重名参数error
no-dupe-else-if禁止重复的eles if 语句error
no-dupe-keys禁止对象字面量中出现重复的keyerror
no-duplicate-case禁止出现重复的 case 标签error
no-empty禁止出现空语句块warn
no-empty-character-class禁止在正则表达式中使用空字符集error
no-ex-assign禁止对 catch 子句的参数重新赋值error
no-extra-boolean-cast禁止不必要的布尔转换warn
no-extra-parens禁止不必要的括号off
no-extra-semi禁止不必要的分号error
no-func-assign禁止对 function 声明重新赋值error
no-import-assign禁止对导入模块重新赋值error
no-inner-declarations禁止在嵌套的块中出现变量声明或 function 声明error
no-invalid-regexp禁止 RegExp 构造函数中存在无效的正则表达式字符串error
no-irregular-whitespace禁止不规则的空白warn
no-loss-of-precision禁止丢失精度的数字文字off
no-misleading-character-class不允许在字符类语法中出现由多个代码点组成的字符error
no-promise-executor-return禁止promise 返回值error
no-obj-calls禁止把全局对象作为函数调用error
no-prototype-builtins禁止直接调用 Object.prototypes 的内置属性warn
no-regex-spaces禁止正则表达式字面量中出现多个空格error
no-setter-return禁止setter 返回值off
no-sparse-arrays禁用稀疏数组error
no-template-curly-in-string禁止在常规字符串中使用模板文字占位符语法error
no-unreachable禁止在 return、throw、continue 和 break 语句之后出现不可达代码error
no-unreachable-loop禁止循环体中只执行一次迭代off
no-unsafe-finally禁止在 finally 语句块中出现控制流语句error
no-unsafe-negation禁止对关系运算符的左操作数使用否定操作符off
no-useless-backreference禁止在正则表达式中使用无用的反向引用off
no-negated-in-lhs不允许对 in 表达式的左操作数取反off
require-atomic-updates禁止由于 await 或 yield的使用而可能导致出现竞态条件的赋值off
use-isnan禁止与值 NaN 进行比较warn
valid-jsdoc确保 JSDoc 注释有效off
valid-typeof确保将 typeof 的结果与有效字符串进行比较error
arrow-body-style要求箭头函数体使用大括号warn
arrow-parens要求箭头函数的参数使用圆括号warn
arrow-spacing箭头函数的箭头前后使用一致的空格warn
constructor-super要求在构造函数中有 super() 的调用error
generator-star-spacing强制 generator 函数中 * 号周围使用一致的空格warn
no-class-assign禁止修改类声明的变量error
no-confusing-arrow禁止在可能与比较操作符相混淆的地方使用箭头函数warn
no-const-assign禁止修改 const 声明的变量error
no-dupe-class-members禁止类成员中出现重复的名称error
no-duplicate-imports禁止重复模块导入warn
no-new-symbol禁止 Symbolnew 操作符和 new 一起使用error
no-restricted-exports禁止导出中的指定名称off
no-restricted-imports禁止导入中的指定名称off
no-this-before-super禁止在构造函数中,在调用 super() 之前使用 this 或 supererror
no-useless-computed-key禁止在对象中使用不必要的计算属性warn
no-useless-constructor禁用不必要的构造函数warn
no-useless-rename禁止在 import 和 export 和解构赋值时将引用重命名为相同的名字error
no-var要求使用 let 或 const 而不是 varerror
object-shorthand要求或禁止对象字面量中方法和属性使用简写语法warn
prefer-arrow-callback要求回调函数使用箭头函数off
prefer-const要求使用 const 声明那些声明后不再被修改的变量warn
prefer-destructuring优先使用数组和对象解构off
prefer-numeric-literals禁用 parseInt() 和 Number.parseInt(),使用二进制,八进制和十六进制字面量off
prefer-reflect优先使用Reflectoff
prefer-rest-params要求使用剩余参数而不是 argumentswarn
prefer-spread要求使用扩展运算符而非 .apply()off
prefer-template要求使用模板字面量而非字符串连接warn
require-yield要求 generator 函数内有 yieldoff
rest-spread-spacing强制剩余和扩展运算符及其表达式之间有空格off
sort-imports强制模块内的 import 排序off
symbol-description要求 symbol 描述warn
template-curly-spacing要求或禁止模板字符串中的嵌入表达式周围空格的使用warn
yield-star-spacing强制在 yield 表达式中 周围使用空格warn
init-declarations要求或禁止声明中的初始化off
no-delete-var禁止删除变量error
no-label-var不允许标签与变量同名error
no-shadow禁止变量声明与外层作用域的变量同名off
no-shadow-restricted-names禁止将标识符定义为受限的名字error
no-undef禁用未声明的变量,除非它们在 /global / 注释中被提到error
no-undef-init禁止将变量初始化为 undefinedoff
no-undefined禁止将 undefined 作为标识符off
no-unused-vars禁止出现未使用过的变量warn
no-use-before-define禁止在变量定义之前使用它们error
array-bracket-newline在数组开括号后和闭括号前强制换行off
array-element-newline强制数组元素间出现换行warn
array-bracket-spacing禁止或强制在括号内使用空格warn
block-spacing禁止或强制在代码块中开括号前和闭括号后有空格warn
brace-style强制在代码块中使用一致的大括号风格warn
camelcase强制使用骆驼拼写法命名约定off
capitalized-comments强制或禁止对注释的第一个字母大写off
comma-dangle要求或禁止末尾逗号warn
comma-spacing强制在逗号前后使用一致的空格warn
comma-style强制使用一致的逗号风格warn
computed-property-spacing强制在计算的属性的方括号中使用一致的空格warn
consistent-this当获取当前执行环境的上下文时,强制使用一致的命名off
eol-last要求或禁止文件末尾存在空行off
func-call-spacing要求或禁止在函数标识符和其调用之间有空格warn
func-names要求或禁止使用命名的 function 表达式off
func-style强制使用函数声明或表达式off
function-paren-newline强制在函数括号内使用一致的换行warn
id-blacklist将某些标识符列入黑名单以防止它们被使用off
id-denylist禁止指定标识符off
implicit-arrow-linebreak强制隐式返回的箭头函数体的位置warn
indent强制使用一致的缩进warn
jsx-quotes强制在 JSX 属性中一致地使用双引号或单引号off
key-spacing强制在对象字面量的属性中键和值之间使用一致的间距warn
line-comment-position强制行注释的位置off
linebreak-style强制使用一致的换行风格off
lines-between-class-members要求或禁止类成员之间出现空行warn
lines-around-comment要求在注释周围有空行off
lines-around-directive要求或禁止在指令周围换行warn
max-len强制一行的最大长度off
max-depth强制可嵌套的块的最大深度off
max-lines强制最大行数off
max-lines-per-function强制函数最大代码行数off
max-nested-callbacks强制回调函数最大嵌套深度off
max-params强制函数定义中最多允许的参数数量off
max-statements强制函数块最多允许的的语句数量off
max-statements-per-line强制每一行中所允许的最大语句数量off
multiline-comment-style强制对多行注释使用特定风格off
multiline-ternary要求或禁止在三元操作数中间换行off
new-cap要求构造函数首字母大写error
new-parens强制或禁止调用无参构造函数时有圆括号off
newline-after-var定义后留一空行off
newline-before-returnreaturn前留一空行off
newline-per-chained-call要求方法链中每个调用都有一个换行符warn
no-array-constructor禁用 Array 构造函数error
no-bitwise禁用按位运算符off
no-continue禁用 continue 语句off
no-inline-comments禁止在代码后使用内联注释off
no-lonely-if禁止 if 作为唯一的语句出现在 else 语句中warn
no-mixed-operators禁止混合使用不同的操作符off
no-mixed-spaces-and-tabs禁止空格和 tab 的混合缩进error
no-multi-assign禁止连续赋值warn
no-multiple-empty-lines禁止出现多行空行warn
no-negated-condition禁用否定的表达式off
no-nested-ternary禁用嵌套的三元表达式off
no-new-object禁用object构造函数off
no-plusplus禁止使用一元运算符off
no-restricted-syntax禁用特殊语法off
no-spaced-func禁止函数标识符和应用程序之间的空间warn
no-tabs禁用taboff
no-ternary禁用三元操作符off
no-trailing-spaces禁用行尾空格off
no-underscore-dangle禁止标识符中有悬空下划线off
no-unneeded-ternary禁止可以在有更简单的可替代的表达式时使用三元操作符warn
no-whitespace-before-property禁止属性前有空白warn
nonblock-statement-body-position强制单个语句的位置warn
object-curly-spacing强制在大括号中使用一致的空格warn
object-curly-newline强制大括号内换行符的一致性warn
object-property-newline强制将对象的属性放在不同的行上warn
one-var强制函数中的变量要么一起声明要么分开声明off
one-var-declaration-per-line要求或禁止在变量声明周围换行off
operator-assignment要求或禁止在可能的情况下使用简化的赋值操作符warn
operator-linebreak强制操作符使用一致的换行符warn
padded-blocks要求或禁止块内填充warn
padding-line-between-statements要求或禁止在语句间填充空行off
prefer-exponentiation-operator禁止使用 Math.pow 来支持 ** 运算符off
prefer-object-spread禁止使用以对象字面量作为第一个参数的 Object.assign,优先使用对象扩展off
quote-props要求对象字面量属性名称用引号括起来warn
quotes强制使用一致的反勾号、双引号或单引号off
require-jsdoc不需要jsdocoff
semi要求或禁止使用分号代替warn
semi-spacing强制分号之前和之后使用一致的空格warn
semi-style强制分号的位置warn
sort-keys要求对象属性按序排列off
sort-vars要求同一个声明块中的变量按顺序排列off
space-before-blocks强制在块之前使用一致的空格warn
space-before-function-paren强制在 function的左括号之前使用一致的空格warn
space-in-parens强制在圆括号内使用一致的空格warn
space-infix-ops要求操作符周围有空格warn
space-unary-ops强制在一元操作符前后使用一致的空格warn
spaced-comment强制在注释中 // 或 /* 使用一致的空格off否是
switch-colon-spacing强制在 switch 的冒号左右有空格warn
template-tag-spacing要求或禁止在模板标记和它们的字面量之间有空格off
unicode-bom要求或禁止 Unicode 字节顺序标记off
wrap-regex要求正则表达式被括号括起来off
accessor-pairs强制getter/setter成对出现off
array-callback-return在数组方法的回调中强制执行 return 语句off
block-scoped-var强制把变量的使用限制在其定义的作用域范围内warn
complexity指定程序中允许的最大环路复杂度off
class-methods-use-this强制类方法使用 thisoff
consistent-return要求 return 语句要么总是指定返回的值,要么不指定off
curly强制所有控制语句使用一致的括号风格warn
default-case要求 switch 语句中有 default 分支warn
dot-notation强制尽可能地使用点号warn
dot-location强制在点号之前和之后一致的换行warn
eqeqeq要求使用 === 和 !==error
guard-for-in要求 for-in 循环中有一个 if 语句warn
max-classes-per-file强制每个文件中包含的的类的最大数量error
no-alert禁用 alert、confirm 和 promptwarn
no-caller禁用 arguments.caller 或 arguments.calleeerror
no-case-declarations不允许在 case 子句中使用词法声明off
no-else-return禁止 if 语句中 return 语句之后有 else 块warn
no-empty-function禁止出现空函数warn
no-empty-pattern禁止使用空解构模式warn
no-eq-null禁止在没有类型检查操作符的情况下与 null 进行比较off
no-eval禁用 eval()error
no-extend-native禁止扩展原生类型error
no-extra-bind禁止不必要的 .bind() 调用warn
no-extra-label禁用不必要的标签error
no-fallthrough禁止 case 语句落空warn
no-floating-decimal禁止数字字面量中使用前导和末尾小数点off
no-global-assign禁止对原生对象或只读的全局对象进行赋值error
no-implicit-coercion禁止使用短符号进行类型转换off
no-implicit-globals禁止在全局范围内使用变量声明和 function 声明off
no-implied-eval禁止使用类似 eval() 的方法error
no-invalid-this禁止在类或类对象之外使用 this 关键字off
no-iterator禁用 iterator 属性error
no-labels禁用标签语句error
no-lone-blocks禁用不必要的嵌套块warn
no-loop-func禁止在循环语句中出现包含不安全引用的函数声明off
no-magic-numbers禁用魔术数字off
no-multi-spaces禁止使用多个空格warn
no-multi-str禁止使用多行字符串off
no-new禁止使用newoff
no-new-func禁用Function构造函数off
no-new-wrappers禁止对 String,Number 和 Boolean 使用 new 操作符error
no-octal禁用八进制字面量error
no-octal-escape禁止在字符串中使用八进制转义序列error
no-param-reassign禁止对 function 的参数进行重新赋值off
no-proto禁用 proto 属性error
no-redeclare禁止多次声明同一变量error
no-restricted-properties禁止使用对象的某些属性error
no-return-assign禁止在 return 语句中使用赋值off
no-return-await禁用不必要的 return awaitwarn
no-script-url禁止使用 javascript: urlerror
no-self-assign禁止自我赋值warn
no-self-compare禁止自身比较warn
no-sequences禁用逗号操作符warn
no-throw-literal禁止抛出异常字面量off
no-unmodified-loop-condition禁用一成不变的循环条件error
no-unused-expressions强制off
no-useless-call禁止不必要的 .call() 和 .apply()warn
no-useless-catch禁止不必要的 catch 子句warn
no-useless-concat禁止不必要的字符串字面量或模板字面量的连接warn
no-useless-escape禁用不必要的转义字符error
no-useless-return禁止多余的 return 语句warn
no-void禁用void操作符error否
no-warning-comments禁止在注释中使用特定的警告术语off
no-with禁用 with 语句off
prefer-promise-reject-errors要求使用 Error 对象作为 Promise 拒绝的原因warn
prefer-named-capture-group建议在正则表达式中使用命名捕获组off
radix强制在 parseInt() 使用基数参数off
require-await禁止使用不带 await 表达式的 async 函数warn
vars-on-top要求所有的 var 声明出现在它们所在的作用域顶部off
wrap-iife要求 IIFE 使用括号括起来warn
yoda要求或禁止 “Yoda” 条件error