112 lines
3.6 KiB
YAML
112 lines
3.6 KiB
YAML
env:
|
|
browser: true
|
|
es6: true
|
|
mocha: true
|
|
parser: "@typescript-eslint/parser"
|
|
#parser: "@babel/eslint-parser"
|
|
plugins:
|
|
- "@typescript-eslint"
|
|
- "react"
|
|
- "react-hooks"
|
|
- "prettier"
|
|
- "jsx-a11y"
|
|
- "import"
|
|
extends:
|
|
- "eslint:recommended"
|
|
- "plugin:@typescript-eslint/recommended"
|
|
- "plugin:react/recommended"
|
|
- "plugin:jsx-a11y/recommended"
|
|
- "plugin:import/recommended"
|
|
- "plugin:prettier/recommended"
|
|
parserOptions:
|
|
ecmaVersion: 2021
|
|
sourceType: "module"
|
|
ecmaFeatures:
|
|
classes: true
|
|
jsx: true
|
|
rules:
|
|
brace-style: #大括号样式
|
|
- warn
|
|
- 1tbs #默认
|
|
camelcase: warn
|
|
comma-dangle: #在对象字面量或者数组属性的结尾使用逗号
|
|
- off
|
|
- always-multiline
|
|
comma-style: #设置逗号放置的位置
|
|
- error
|
|
- last #放在最后
|
|
complexity: #制代码层级的复杂度,如if...else if...else等。配置参数是一个数值,表示层级数量。
|
|
- error
|
|
- 20
|
|
curly: #if...else、while等语句必须使用 大括号{}包括
|
|
- warn
|
|
eol-last: #文件最后必须有一行空行
|
|
- error
|
|
- always
|
|
id-length: #规定标识符的长短,默认最小是2个字符
|
|
- off
|
|
"import/named": off
|
|
"import/no-named-as-default": off
|
|
"import/no-named-as-default-member": off
|
|
max-lines: #强制每个文件的最大行数,默认300
|
|
- warn
|
|
- 600
|
|
max-params: #在函数定义中强制使用最大数量的参数
|
|
- error
|
|
- 8
|
|
eqeqeq: #需要使用 === 和 !==
|
|
- error
|
|
- smart
|
|
no-cond-assign: #条件判断语句中不允许赋值操作
|
|
- error
|
|
- except-parens #仅在括号括起来时才允许在测试条件中赋值
|
|
no-const-assign: error #不允许重新分配 const 变量
|
|
no-duplicate-imports: error #禁止重复的模块导入
|
|
no-empty-function: off #禁止空函数
|
|
no-eq-null: error #不允许没有类型检查运算符的 null 比较
|
|
no-eval: error #禁止使用 eval()
|
|
no-extend-native: error #禁止扩展原生类型
|
|
no-implied-eval: error #禁止使用类似 eval() 的方法
|
|
no-invalid-this: error #禁止在 this 的值为 undefined 的上下文中使用 this
|
|
no-label-var: warn #禁止与变量共享名称的标签
|
|
no-param-reassign: warn #不允许重新分配 function 参数
|
|
no-shadow: off #禁止在外部作用域中声明的隐藏变量中的变量声明
|
|
no-undefined: off #禁止使用 undefined 作为标识符
|
|
no-unused-expressions: warn #禁止未使用的表达式
|
|
no-use-before-define: warn #在定义之前禁止使用变量
|
|
no-useless-concat: warn #禁止不必要的字面或模板字面串联
|
|
no-useless-constructor: warn #禁止不必要的构造函数
|
|
no-useless-rename: warn #不允许将导入、导出和解构的分配重命名为相同的名称
|
|
no-warning-comments: #不允许在评论中使用指定的警告词
|
|
- warn
|
|
- location: anywhere
|
|
terms:
|
|
- todo
|
|
- fixme
|
|
object-curly-newline: off #在打开大括号之后和关闭大括号之前强制执行一致的换行符
|
|
prefer-promise-reject-errors: error #要求使用 Error 对象作为 Promise 拒绝原因
|
|
semi: #要求或禁止使用分号而不是 ASI
|
|
- error
|
|
- never
|
|
"jsx-a11y/click-events-have-key-events": off
|
|
"jsx-a11y/no-static-element-interactions": off
|
|
|
|
#react
|
|
react/display-name: off
|
|
react/sort-comp: error
|
|
react/self-closing-comp:
|
|
- error
|
|
- component: true
|
|
html: false
|
|
|
|
#import
|
|
import/no-unresolved: off
|
|
|
|
"@typescript-eslint/no-explicit-any": off
|
|
"@typescript-eslint/no-empty-function": error
|
|
"@typescript-eslint/no-unused-vars": warn
|
|
settings:
|
|
react:
|
|
pragma: React
|
|
version: 18.3.1
|