|
3 | 3 | "browser": true,
|
4 | 4 | "es2021": true
|
5 | 5 | },
|
6 |
| - // 也可以不用airbnb-typescript |
7 |
| - // 因为你都用@typescript-eslint/parser解析器了,可以识别 |
8 | 6 | "extends": [
|
9 |
| - // 你配置了airbnb这个规则 就不用再配置多个 选择一个就行 当然也可以多个 重复的话就覆盖 |
10 |
| - // "plugin:react/recommended", |
11 |
| - "plugin:@typescript-eslint/recommended", |
12 | 7 | "airbnb",
|
13 |
| - "plugin:prettier/recommended", |
| 8 | + "plugin:import/errors", |
| 9 | + "plugin:import/warnings", |
| 10 | + // ts项目可能跟eslint规则冲突,这个插件就是解决这个问题的 |
| 11 | + // 注意优先级 |
| 12 | + "plugin:react/recommended", |
| 13 | + "plugin:@typescript-eslint/recommended", |
14 | 14 | "prettier", // 可能会覆盖eslint-config-airbnb的rule配置 不需要prettier/airbnb 理清楚这种关系 ===>基础配置
|
15 |
| - "prettier/react" |
| 15 | + "plugin:prettier/recommended" |
16 | 16 | ],
|
17 | 17 | "parser": "@typescript-eslint/parser",
|
18 | 18 | "parserOptions": {
|
|
23 | 23 | "sourceType": "module",
|
24 | 24 | "project": "./tsconfig.json"
|
25 | 25 | },
|
26 |
| - "plugins": ["react", "@typescript-eslint", "react-hooks", "prettier"], |
| 26 | + "plugins": ["react", "@typescript-eslint", "prettier", "import", "react-hooks"], |
| 27 | + "settings": { |
| 28 | + "react": { |
| 29 | + "pragma": "React", |
| 30 | + "version": "detect" |
| 31 | + } |
| 32 | + }, |
27 | 33 | "rules": {
|
28 |
| - "prettier/prettier": "error", |
29 |
| - "import/extensions": 0, |
30 |
| - "import/no-cycle": 0, |
31 |
| - "import/no-aextraneous-dependencies": ["error", { "devDependencies": true }], |
32 |
| - "import/no-named-as-default": 0, |
33 |
| - "react/jsx-props-no-spreading": 0, |
34 |
| - "import/prefer-default-export": 0, |
35 |
| - "react/button-has-type": 0, |
36 |
| - "react/require-default-props": 0, |
| 34 | + "@typescript-eslint/adjacent-overload-signatures": "error", |
| 35 | + "@typescript-eslint/array-type": "error", |
| 36 | + "@typescript-eslint/ban-types": "off", |
| 37 | + "@typescript-eslint/naming-convention": "off", |
| 38 | + "@typescript-eslint/consistent-type-assertions": "error", |
| 39 | + "@typescript-eslint/consistent-type-definitions": "error", |
| 40 | + "@typescript-eslint/explicit-member-accessibility": [ |
| 41 | + "error", |
| 42 | + { |
| 43 | + "accessibility": "no-public" |
| 44 | + } |
| 45 | + ], |
| 46 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 47 | + "@typescript-eslint/indent": "off", |
| 48 | + "@typescript-eslint/member-delimiter-style": [ |
| 49 | + "off", |
| 50 | + { |
| 51 | + "multiline": { |
| 52 | + "delimiter": "none", |
| 53 | + "requireLast": true |
| 54 | + }, |
| 55 | + "singleline": { |
| 56 | + "delimiter": "semi", |
| 57 | + "requireLast": false |
| 58 | + } |
| 59 | + } |
| 60 | + ], |
| 61 | + "@typescript-eslint/member-ordering": "error", |
| 62 | + "@typescript-eslint/no-empty-function": "error", |
| 63 | + "@typescript-eslint/no-empty-interface": "off", |
| 64 | + "@typescript-eslint/no-explicit-any": "off", |
| 65 | + "@typescript-eslint/no-misused-new": "error", |
| 66 | + "@typescript-eslint/no-namespace": "off", |
| 67 | + "@typescript-eslint/no-parameter-properties": "off", |
| 68 | + "@typescript-eslint/no-var-requires": "error", |
| 69 | + "@typescript-eslint/prefer-for-of": "error", |
| 70 | + "@typescript-eslint/prefer-function-type": "error", |
| 71 | + "@typescript-eslint/prefer-namespace-keyword": "off", |
| 72 | + "@typescript-eslint/quotes": "off", |
| 73 | + "@typescript-eslint/semi": ["off", null], |
| 74 | + "@typescript-eslint/space-within-parens": ["off", "never"], |
| 75 | + "@typescript-eslint/triple-slash-reference": [ |
| 76 | + "error", |
| 77 | + { |
| 78 | + "path": "always", |
| 79 | + "types": "always", |
| 80 | + "lib": "always" |
| 81 | + } |
| 82 | + ], |
| 83 | + "@typescript-eslint/type-annotation-spacing": "off", |
| 84 | + "@typescript-eslint/unified-signatures": "error", |
| 85 | + "arrow-body-style": "error", |
| 86 | + "arrow-parens": ["off", "as-needed"], |
| 87 | + "camelcase": "off", |
| 88 | + "comma-dangle": "off", |
| 89 | + "complexity": "off", |
| 90 | + "constructor-super": "error", |
| 91 | + "curly": "error", |
| 92 | + "dot-notation": "error", |
| 93 | + "eol-last": "off", |
| 94 | + "eqeqeq": ["error", "always"], |
| 95 | + "guard-for-in": "error", |
| 96 | + "id-blacklist": [ |
| 97 | + "error", |
| 98 | + "any", |
| 99 | + "Number", |
| 100 | + "number", |
| 101 | + "String", |
| 102 | + "string", |
| 103 | + "Boolean", |
| 104 | + "boolean", |
| 105 | + "Undefined", |
| 106 | + "undefined" |
| 107 | + ], |
| 108 | + "id-match": "error", |
| 109 | + "import/order": "off", |
| 110 | + "linebreak-style": "off", |
| 111 | + "max-classes-per-file": "off", |
| 112 | + "max-len": "off", |
| 113 | + "new-parens": "off", |
| 114 | + "newline-per-chained-call": "off", |
| 115 | + "no-bitwise": "error", |
| 116 | + "no-caller": "error", |
| 117 | + "no-cond-assign": "error", |
| 118 | + "no-console": "off", |
| 119 | + "no-debugger": "error", |
| 120 | + "no-empty": "error", |
| 121 | + "no-eval": "error", |
| 122 | + "no-extra-semi": "off", |
| 123 | + "no-fallthrough": "off", |
| 124 | + "no-invalid-this": "off", |
| 125 | + "no-irregular-whitespace": "off", |
| 126 | + "no-multiple-empty-lines": "off", |
| 127 | + "no-new-wrappers": "error", |
| 128 | + "no-shadow": [ |
| 129 | + "off", |
| 130 | + { |
| 131 | + "hoist": "all" |
| 132 | + } |
| 133 | + ], |
| 134 | + "no-throw-literal": "error", |
| 135 | + "no-trailing-spaces": "off", |
| 136 | + "no-undef-init": "error", |
| 137 | + "no-underscore-dangle": [ |
| 138 | + "error", |
| 139 | + { |
| 140 | + "allow": ["__INITIAL_DATA__", "__STORE__", "_insertCss"], |
| 141 | + "allowAfterThis": true, |
| 142 | + "allowAfterThisConstructor": true |
| 143 | + } |
| 144 | + ], |
| 145 | + "no-unsafe-finally": "error", |
| 146 | + "no-unused-expressions": [ |
| 147 | + "error", |
| 148 | + { |
| 149 | + "allowShortCircuit": true, |
| 150 | + "allowTernary": true |
| 151 | + } |
| 152 | + ], |
| 153 | + "no-use-before-define": "off", |
| 154 | + "no-unused-labels": "error", |
| 155 | + "no-var": "error", |
| 156 | + "object-shorthand": "error", |
| 157 | + "one-var": ["error", "never"], |
| 158 | + "prefer-arrow-callback": ["error", { "allowNamedFunctions": true }], |
| 159 | + "prefer-const": "error", |
| 160 | + "quote-props": "off", |
| 161 | + "radix": "error", |
| 162 | + "space-before-function-paren": "off", |
| 163 | + "spaced-comment": ["error", "always", { "markers": ["/"] }], |
| 164 | + "use-isnan": "error", |
| 165 | + "valid-typeof": "off", |
| 166 | + "react/jsx-no-target-blank": [ |
| 167 | + "error", |
| 168 | + { |
| 169 | + "enforceDynamicLinks": "always" |
| 170 | + } |
| 171 | + ], |
| 172 | + "no-restricted-syntax": "off", |
| 173 | + "import/extensions": "off", |
| 174 | + "import/no-unresolved": "off", |
| 175 | + "react/no-unused-state": "error", |
| 176 | + "react/self-closing-comp": "error", |
| 177 | + "react/boolean-prop-naming": ["error", { "rule": "^(is|has)[A-Z]([A-Za-z0-9]?)+" }], |
| 178 | + "react/no-direct-mutation-state": "error", |
| 179 | + "react/no-multi-comp": [ |
| 180 | + "error", |
| 181 | + { |
| 182 | + "ignoreStateless": true |
| 183 | + } |
| 184 | + ], |
| 185 | + "react/no-this-in-sfc": "error", |
| 186 | + "react/no-unsafe": [ |
| 187 | + "error", |
| 188 | + { |
| 189 | + "checkAliases": true |
| 190 | + } |
| 191 | + ], |
| 192 | + "react/state-in-constructor": ["error", "never"], |
| 193 | + "react/jsx-uses-vars": "error", |
| 194 | + "react/jsx-pascal-case": "error", |
| 195 | + "react/jsx-no-useless-fragment": "error", |
| 196 | + "react/jsx-no-bind": [ |
| 197 | + "error", |
| 198 | + { |
| 199 | + "allowArrowFunctions": true, |
| 200 | + "ignoreRefs": true |
| 201 | + } |
| 202 | + ], |
| 203 | + "react/jsx-no-duplicate-props": "error", |
| 204 | + "react/jsx-equals-spacing": [2, "never"], |
| 205 | + "react/jsx-boolean-value": ["error", "never"], |
| 206 | + "react/jsx-closing-tag-location": "error", |
| 207 | + "react/display-name": "off", |
| 208 | + "react/jsx-props-no-spreading": "off", |
37 | 209 | "react-hooks/rules-of-hooks": "error", // 检查 Hook 的规则
|
38 | 210 | "react-hooks/exhaustive-deps": "warn", // 检查 effect 的依赖
|
39 |
| - "no-console": "off", |
40 |
| - "no-void": "off", |
41 |
| - "@typescript-eslint/dot-notation": ["error"] |
| 211 | + "react/jsx-filename-extension": [2, { "extensions": [".js", ".jsx", ".ts", ".tsx"] }] |
42 | 212 | }
|
| 213 | + // "overrides": [ |
| 214 | + // { |
| 215 | + // "files": ["global.d.ts", "css.modules.d.ts", "pro-config.ts"], |
| 216 | + // "rules": { |
| 217 | + // "@typescript-eslint/naming-convention": "off" |
| 218 | + // } |
| 219 | + // } |
| 220 | + // ] |
43 | 221 | }
|
0 commit comments