|
| 1 | +import typeScriptConfig from '@strv/eslint-config-typescript' |
1 | 2 | import expoConfig from 'eslint-config-expo/flat.js' |
2 | 3 | import { defineConfig, globalIgnores } from 'eslint/config' |
3 | 4 |
|
4 | 5 | /** Globally ignored */ |
5 | | -const ignores = globalIgnores(['.expo/']) |
| 6 | +const ignores = globalIgnores(['.expo/', 'expo-env.d.ts']) |
6 | 7 |
|
7 | 8 | /** @type {import("eslint").Linter.Config} */ |
8 | 9 | const common = { |
9 | 10 | rules: { |
10 | | - // Very expensive check |
| 11 | + // Very expensive check, see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/namespace.md |
11 | 12 | 'import/namespace': 'off', |
12 | | - // Very expensive check |
| 13 | + // Very expensive check, see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md |
13 | 14 | 'import/no-duplicates': 'off', |
| 15 | + // Handled by TypeScript, see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-unresolved.md |
| 16 | + 'import/no-unresolved': 'off', |
| 17 | + // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-named-as-default.md |
| 18 | + 'import/no-named-as-default': 'off', |
| 19 | + // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-named-as-default-member.md |
| 20 | + 'import/no-named-as-default-member': 'off', |
| 21 | + // Handled by TypeScript. Enable noUnusedLocals in your tsconfig.json, see https://www.typescriptlang.org/tsconfig/#noUnusedLocals |
| 22 | + // https://eslint.org/docs/latest/rules/no-unused-vars |
| 23 | + 'no-unused-vars': 'off', |
14 | 24 | }, |
15 | 25 | } |
16 | 26 |
|
17 | 27 | /** @type {import("eslint").Linter.Config} */ |
18 | 28 | const react = { |
| 29 | + files: ['**/*.jsx', '**/*.tsx'], |
19 | 30 | rules: { |
| 31 | + // Enforce alphabetical sorting of props for better readability, see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md |
20 | 32 | 'react/jsx-sort-props': [ |
21 | | - 'warn', |
| 33 | + 'error', |
22 | 34 | { |
23 | 35 | multiline: 'first', |
24 | 36 | reservedFirst: ['key'], |
25 | 37 | callbacksLast: true, |
26 | 38 | shorthandLast: true, |
27 | 39 | }, |
28 | 40 | ], |
| 41 | + // DisplayName is not required for React Native components, see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md |
29 | 42 | 'react/display-name': 'off', |
30 | 43 | }, |
31 | 44 | } |
32 | 45 |
|
33 | 46 | /** @type {import("eslint").Linter.Config} */ |
34 | | -const typescript = { |
| 47 | +const typescript = defineConfig([typeScriptConfig, { |
| 48 | + files: ['**/*.ts', '**/*.tsx'], |
35 | 49 | rules: { |
36 | | - // Handled by TypeScript, see https://www.typescriptlang.org/tsconfig/#noUnusedLocals |
| 50 | + // Handled by TypeScript. Enable noUnusedLocals in your tsconfig.json, see https://www.typescriptlang.org/tsconfig/#noUnusedLocals |
| 51 | + // https://typescript-eslint.io/rules/no-unused-vars/ |
37 | 52 | '@typescript-eslint/no-unused-vars': 'off', |
38 | 53 | // Its common in React Native to import types using require syntax, see https://reactnative.dev/docs/images#static-image-resources |
| 54 | + // https://typescript-eslint.io/rules/no-require-imports/ |
39 | 55 | '@typescript-eslint/no-require-imports': 'off', |
| 56 | + // Very expensive check, see https://typescript-eslint.io/rules/promise-function-async/ |
| 57 | + '@typescript-eslint/promise-function-async': 'off', |
40 | 58 |
|
41 | | - // '@typescript-eslint/consistent-type-imports': [ |
42 | | - // 'warn', |
43 | | - // { prefer: 'type-imports', fixStyle: 'inline-type-imports' }, |
44 | | - // ], |
| 59 | + // Allows variable shadowing in TypeScript contexts, see https://typescript-eslint.io/rules/no-shadow/ |
| 60 | + '@typescript-eslint/no-shadow': 'off', |
| 61 | + // Allows both interface and type definitions, see https://typescript-eslint.io/rules/consistent-type-definitions/ |
| 62 | + '@typescript-eslint/consistent-type-definitions': 'off', |
| 63 | + // Allows Promises in places where they might not be handled properly, see https://typescript-eslint.io/rules/no-misused-promises/ |
| 64 | + '@typescript-eslint/no-misused-promises': 'off', |
| 65 | + // Allows assignments of any typed values, see https://typescript-eslint.io/rules/no-unsafe-assignment/ |
| 66 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 67 | + // Allows returning any typed values from functions, see https://typescript-eslint.io/rules/no-unsafe-return/ |
| 68 | + '@typescript-eslint/no-unsafe-return': 'off', |
| 69 | + // Allows unbound method references that may lose 'this' context, see https://typescript-eslint.io/rules/unbound-method/ |
| 70 | + '@typescript-eslint/unbound-method': 'off', |
| 71 | + // Allows member access on any typed values, see https://typescript-eslint.io/rules/no-unsafe-member-access/ |
| 72 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 73 | + |
| 74 | + // Enforce consistent type imports with inline style, see https://typescript-eslint.io/rules/consistent-type-imports/ |
| 75 | + '@typescript-eslint/consistent-type-imports': [ |
| 76 | + 'error', |
| 77 | + { prefer: 'type-imports', fixStyle: 'inline-type-imports' }, |
| 78 | + ], |
45 | 79 | }, |
46 | | -} |
| 80 | +}]) |
47 | 81 |
|
48 | 82 | export default defineConfig([ |
49 | 83 | expoConfig, |
|
0 commit comments