|
1 | 1 | {
|
| 2 | + "root": true, |
2 | 3 | "parser": "babel-eslint",
|
| 4 | + "plugins": ["react", "react-hooks", "jest", "import"], |
| 5 | + "env": { |
| 6 | + "browser": true, |
| 7 | + "commonjs": true, |
| 8 | + "es6": true, |
| 9 | + "node": true |
| 10 | + }, |
3 | 11 | "parserOptions": {
|
4 | 12 | "ecmaVersion": 2018,
|
5 | 13 | "sourceType": "module",
|
6 | 14 | "ecmaFeatures": {
|
7 | 15 | "jsx": true
|
8 | 16 | }
|
9 | 17 | },
|
10 |
| - "env": { "es6": true, "node": true, "browser": true }, |
11 |
| - "extends": ["eslint:recommended", "plugin:react/recommended"] |
| 18 | + "settings": { |
| 19 | + "react": { |
| 20 | + "version": "detect" |
| 21 | + } |
| 22 | + }, |
| 23 | + "overrides": [ |
| 24 | + { |
| 25 | + "files": ["test/**/*.test.js"], |
| 26 | + "extends": ["plugin:jest/recommended"], |
| 27 | + "rules": { |
| 28 | + "jest/expect-expect": "off", |
| 29 | + "jest/no-disabled-tests": "off" |
| 30 | + } |
| 31 | + }, |
| 32 | + { "files": ["**/__tests__/**"], "env": { "jest": true } }, |
| 33 | + { |
| 34 | + "files": ["**/*.ts", "**/*.tsx"], |
| 35 | + "parser": "@typescript-eslint/parser", |
| 36 | + "parserOptions": { |
| 37 | + "ecmaVersion": 2018, |
| 38 | + "sourceType": "module", |
| 39 | + "ecmaFeatures": { |
| 40 | + "jsx": true |
| 41 | + }, |
| 42 | + "warnOnUnsupportedTypeScriptVersion": false |
| 43 | + }, |
| 44 | + "plugins": ["@typescript-eslint"], |
| 45 | + "rules": { |
| 46 | + // Already handled by TS |
| 47 | + "no-dupe-class-members": "off", |
| 48 | + "no-undef": "off", |
| 49 | + |
| 50 | + // Add TypeScript specific rules (and turn off ESLint equivalents) |
| 51 | + "@typescript-eslint/consistent-type-assertions": "warn", |
| 52 | + "no-array-constructor": "off", |
| 53 | + "@typescript-eslint/no-array-constructor": "warn", |
| 54 | + "@typescript-eslint/no-namespace": "error", |
| 55 | + "no-use-before-define": "off", |
| 56 | + "@typescript-eslint/no-use-before-define": [ |
| 57 | + "warn", |
| 58 | + { |
| 59 | + "functions": false, |
| 60 | + "classes": false, |
| 61 | + "variables": false, |
| 62 | + "typedefs": false |
| 63 | + } |
| 64 | + ], |
| 65 | + "no-unused-vars": "off", |
| 66 | + "@typescript-eslint/no-unused-vars": [ |
| 67 | + "warn", |
| 68 | + { |
| 69 | + "args": "none", |
| 70 | + "ignoreRestSiblings": true |
| 71 | + } |
| 72 | + ], |
| 73 | + "no-unused-expressions": "off", |
| 74 | + "@typescript-eslint/no-unused-expressions": [ |
| 75 | + "error", |
| 76 | + { |
| 77 | + "allowShortCircuit": true, |
| 78 | + "allowTernary": true, |
| 79 | + "allowTaggedTemplates": true |
| 80 | + } |
| 81 | + ], |
| 82 | + "no-useless-constructor": "off", |
| 83 | + "@typescript-eslint/no-useless-constructor": "warn" |
| 84 | + } |
| 85 | + }, |
| 86 | + { |
| 87 | + "files": [ |
| 88 | + "test/**/*", |
| 89 | + "examples/**/*", |
| 90 | + "packages/create-next-app/templates/**/*" |
| 91 | + ], |
| 92 | + "rules": { "react/react-in-jsx-scope": "off" } |
| 93 | + }, |
| 94 | + { |
| 95 | + "files": ["examples/**/*"], |
| 96 | + "rules": { |
| 97 | + "import/no-anonymous-default-export": [ |
| 98 | + "error", |
| 99 | + { |
| 100 | + // React components: |
| 101 | + "allowArrowFunction": false, |
| 102 | + "allowAnonymousClass": false, |
| 103 | + "allowAnonymousFunction": false, |
| 104 | + |
| 105 | + // Non-React stuff: |
| 106 | + "allowArray": true, |
| 107 | + "allowCallExpression": true, |
| 108 | + "allowLiteral": true, |
| 109 | + "allowObject": true |
| 110 | + } |
| 111 | + ] |
| 112 | + } |
| 113 | + }, |
| 114 | + { |
| 115 | + "files": ["packages/**"], |
| 116 | + "rules": { |
| 117 | + "no-shadow": ["warn", { "builtinGlobals": false }], |
| 118 | + "import/no-extraneous-dependencies": [ |
| 119 | + "error", |
| 120 | + { "devDependencies": false } |
| 121 | + ] |
| 122 | + } |
| 123 | + }, |
| 124 | + { |
| 125 | + "files": ["packages/**/*.tsx", "packages/**/*.ts"], |
| 126 | + "rules": { |
| 127 | + "@typescript-eslint/no-unused-vars": [ |
| 128 | + "warn", |
| 129 | + { |
| 130 | + "args": "all", |
| 131 | + "argsIgnorePattern": "^_", |
| 132 | + "ignoreRestSiblings": true |
| 133 | + } |
| 134 | + ] |
| 135 | + } |
| 136 | + } |
| 137 | + ], |
| 138 | + "rules": { |
| 139 | + "array-callback-return": "warn", |
| 140 | + "default-case": ["warn", { "commentPattern": "^no default$" }], |
| 141 | + "dot-location": ["warn", "property"], |
| 142 | + "eqeqeq": ["warn", "smart"], |
| 143 | + "new-parens": "warn", |
| 144 | + "no-array-constructor": "warn", |
| 145 | + "no-caller": "warn", |
| 146 | + "no-cond-assign": ["warn", "except-parens"], |
| 147 | + "no-const-assign": "warn", |
| 148 | + "no-control-regex": "warn", |
| 149 | + "no-delete-var": "warn", |
| 150 | + "no-dupe-args": "warn", |
| 151 | + "no-dupe-class-members": "warn", |
| 152 | + "no-dupe-keys": "warn", |
| 153 | + "no-duplicate-case": "warn", |
| 154 | + "no-empty-character-class": "warn", |
| 155 | + "no-empty-pattern": "warn", |
| 156 | + "no-eval": "warn", |
| 157 | + "no-ex-assign": "warn", |
| 158 | + "no-extend-native": "warn", |
| 159 | + "no-extra-bind": "warn", |
| 160 | + "no-extra-label": "warn", |
| 161 | + "no-fallthrough": "warn", |
| 162 | + "no-func-assign": "warn", |
| 163 | + "no-implied-eval": "warn", |
| 164 | + "no-invalid-regexp": "warn", |
| 165 | + "no-iterator": "warn", |
| 166 | + "no-label-var": "warn", |
| 167 | + "no-labels": ["warn", { "allowLoop": true, "allowSwitch": false }], |
| 168 | + "no-lone-blocks": "warn", |
| 169 | + "no-loop-func": "warn", |
| 170 | + "no-mixed-operators": [ |
| 171 | + "warn", |
| 172 | + { |
| 173 | + "groups": [ |
| 174 | + ["&", "|", "^", "~", "<<", ">>", ">>>"], |
| 175 | + ["==", "!=", "===", "!==", ">", ">=", "<", "<="], |
| 176 | + ["&&", "||"], |
| 177 | + ["in", "instanceof"] |
| 178 | + ], |
| 179 | + "allowSamePrecedence": false |
| 180 | + } |
| 181 | + ], |
| 182 | + "no-multi-str": "warn", |
| 183 | + "no-native-reassign": "warn", |
| 184 | + "no-negated-in-lhs": "warn", |
| 185 | + "no-new-func": "warn", |
| 186 | + "no-new-object": "warn", |
| 187 | + "no-new-symbol": "warn", |
| 188 | + "no-new-wrappers": "warn", |
| 189 | + "no-obj-calls": "warn", |
| 190 | + "no-octal": "warn", |
| 191 | + "no-octal-escape": "warn", |
| 192 | + "no-redeclare": ["warn", { "builtinGlobals": false }], |
| 193 | + "no-regex-spaces": "warn", |
| 194 | + "no-restricted-syntax": ["warn", "WithStatement"], |
| 195 | + "no-script-url": "warn", |
| 196 | + "no-self-assign": "warn", |
| 197 | + "no-self-compare": "warn", |
| 198 | + "no-sequences": "warn", |
| 199 | + "no-shadow-restricted-names": "warn", |
| 200 | + "no-sparse-arrays": "warn", |
| 201 | + "no-template-curly-in-string": "error", |
| 202 | + "no-this-before-super": "warn", |
| 203 | + "no-throw-literal": "warn", |
| 204 | + "no-undef": "error", |
| 205 | + "no-unexpected-multiline": "warn", |
| 206 | + "no-unreachable": "warn", |
| 207 | + "no-unused-expressions": [ |
| 208 | + "error", |
| 209 | + { |
| 210 | + "allowShortCircuit": true, |
| 211 | + "allowTernary": true, |
| 212 | + "allowTaggedTemplates": true |
| 213 | + } |
| 214 | + ], |
| 215 | + "no-unused-labels": "warn", |
| 216 | + "no-unused-vars": [ |
| 217 | + "warn", |
| 218 | + { |
| 219 | + "args": "none", |
| 220 | + "ignoreRestSiblings": true |
| 221 | + } |
| 222 | + ], |
| 223 | + "no-use-before-define": [ |
| 224 | + "warn", |
| 225 | + { |
| 226 | + "functions": false, |
| 227 | + "classes": false, |
| 228 | + "variables": false |
| 229 | + } |
| 230 | + ], |
| 231 | + "no-useless-computed-key": "warn", |
| 232 | + "no-useless-concat": "warn", |
| 233 | + "no-useless-constructor": "warn", |
| 234 | + "no-useless-escape": "warn", |
| 235 | + "no-useless-rename": [ |
| 236 | + "warn", |
| 237 | + { |
| 238 | + "ignoreDestructuring": false, |
| 239 | + "ignoreImport": false, |
| 240 | + "ignoreExport": false |
| 241 | + } |
| 242 | + ], |
| 243 | + "no-with": "warn", |
| 244 | + "no-whitespace-before-property": "warn", |
| 245 | + "react-hooks/exhaustive-deps": "warn", |
| 246 | + "require-yield": "warn", |
| 247 | + "rest-spread-spacing": ["warn", "never"], |
| 248 | + "strict": ["warn", "never"], |
| 249 | + "unicode-bom": ["warn", "never"], |
| 250 | + "use-isnan": "warn", |
| 251 | + "valid-typeof": "warn", |
| 252 | + "getter-return": "warn", |
| 253 | + "react/forbid-foreign-prop-types": ["warn", { "allowInPropTypes": true }], |
| 254 | + "react/jsx-no-comment-textnodes": "warn", |
| 255 | + "react/jsx-no-duplicate-props": "warn", |
| 256 | + "react/jsx-no-target-blank": "warn", |
| 257 | + "react/jsx-no-undef": "error", |
| 258 | + "react/jsx-pascal-case": [ |
| 259 | + "warn", |
| 260 | + { |
| 261 | + "allowAllCaps": true, |
| 262 | + "ignore": [] |
| 263 | + } |
| 264 | + ], |
| 265 | + "react/jsx-uses-react": "warn", |
| 266 | + "react/jsx-uses-vars": "warn", |
| 267 | + "react/no-danger-with-children": "warn", |
| 268 | + "react/no-deprecated": "warn", |
| 269 | + "react/no-direct-mutation-state": "warn", |
| 270 | + "react/no-is-mounted": "warn", |
| 271 | + "react/no-typos": "error", |
| 272 | + "react/react-in-jsx-scope": "error", |
| 273 | + "react/require-render-return": "error", |
| 274 | + "react/style-prop-object": "warn", |
| 275 | + "react-hooks/rules-of-hooks": "error" |
| 276 | + } |
12 | 277 | }
|
0 commit comments