module.exports = { parser: '@typescript-eslint/parser', //定义ESLint的解析器 extends: [ 'plugin:react/recommended', 'plugin:prettier/recommended', 'plugin:@typescript-eslint/recommended', ], //定义文件继承的子规范 plugins: ['@typescript-eslint', 'react', 'react-hooks'], //定义了该eslint文件所依赖的插件 settings: { //自动发现React的版本,从而进行规范react代码 react: { pragma: 'React', version: 'detect', }, }, parserOptions: { //指定ESLint可以解析JSX语法 ecmaVersion: 2019, sourceType: 'module', ecmaFeatures: { jsx: true, }, }, rules: { 'prettier/prettier': 'error', '@typescript-eslint/adjacent-overload-signatures': 'error', '@typescript-eslint/array-type': 'error', '@typescript-eslint/ban-types': 'error', '@typescript-eslint/ban-ts-ignore': 'off', '' '@typescript-eslint/class-name-casing': 'error', '@typescript-eslint/explicit-member-accessibility': [ 'error', { accessibility: 'explicit', overrides: { accessors: 'explicit', constructors: 'no-public', methods: 'no-public', properties: 'off', parameterProperties: 'explicit', }, }, ], '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/indent': ['error', 2], '@typescript-eslint/interface-name-prefix': [ 'error', { prefixWithI: 'always' }, ], '@typescript-eslint/member-delimiter-style': 'off', '@typescript-eslint/member-ordering': 'error', '@typescript-eslint/no-angle-bracket-type-assertion': 'off', '@typescript-eslint/no-empty-interface': 'error', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-inferrable-types': 'error', '@typescript-eslint/no-misused-new': 'error', '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/no-namespace': 'error', '@typescript-eslint/no-parameter-properties': 'off', '@typescript-eslint/triple-slash-reference': [ 'error', { path: 'always', types: 'always', lib: 'always' }, ], '@typescript-eslint/no-use-before-declare': 'off', '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/no-var-requires': 'error', '@typescript-eslint/prefer-for-of': 'error', '@typescript-eslint/prefer-function-type': 'error', '@typescript-eslint/prefer-interface': 'off', '@typescript-eslint/prefer-namespace-keyword': 'error', '@typescript-eslint/type-annotation-spacing': 'error', '@typescript-eslint/unified-signatures': 'error', 'arrow-body-style': 'off', 'arrow-parens': ['off', 'as-needed'], complexity: 'off', 'constructor-super': 'error', curly: 'error', 'default-case': 'error', 'dot-notation': 'off', 'eol-last': 'off', 'guard-for-in': 'off', 'linebreak-style': 'off', 'max-classes-per-file': ['error', 1], 'new-parens': 'off', 'newline-per-chained-call': 'off', 'no-bitwise': 'off', 'no-caller': 'error', 'no-cond-assign': 'error', 'no-console': [ 'error', { allow: ['log'], }, ], 'no-debugger': 'error', 'no-empty': 'off', 'no-empty-functions': 'off', 'no-eval': 'error', 'no-extra-semi': 'off', 'no-fallthrough': 'error', 'no-invalid-this': 'off', 'no-irregular-whitespace': 'off', 'no-multiple-empty-lines': 'error', 'no-new-wrappers': 'error', 'no-throw-literal': 'off', 'no-undef-init': 'error', 'no-unsafe-finally': 'error', 'no-unused-labels': 'error', 'no-var': 'error', 'object-shorthand': 'error', 'one-var': 'off', 'prefer-const': 'error', 'quote-props': 'off', radix: 'error', 'space-before-function-paren': 'off', 'use-isnan': 'error', 'valid-typeof': 'off', 'react-hooks/rules-of-hooks': 'error', // 检查 Hook 的规则 'react-hooks/exhaustive-deps': 'warn', // 检查 effect 的依赖 }, env: { //指定代码的运行环境 browser: true, node: true, es6: true, }, }