|
| 1 | +import typeScriptConfig from '@strv/eslint-config-typescript' |
| 2 | +import expoConfig from 'eslint-config-expo/flat.js' |
| 3 | +import { defineConfig, globalIgnores } from 'eslint/config' |
| 4 | + |
| 5 | +/** Globally ignored */ |
| 6 | +const ignores = globalIgnores(['.expo/', 'expo-env.d.ts']) |
| 7 | + |
| 8 | +/** @type {import("eslint").Linter.Config} */ |
| 9 | +const common = { |
| 10 | + rules: { |
| 11 | + // Very expensive check, see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/namespace.md |
| 12 | + 'import/namespace': 'off', |
| 13 | + // Very expensive check, see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md |
| 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', |
| 24 | + }, |
| 25 | +} |
| 26 | + |
| 27 | +/** @type {import("eslint").Linter.Config} */ |
| 28 | +const react = { |
| 29 | + files: ['**/*.jsx', '**/*.tsx'], |
| 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 |
| 32 | + 'react/jsx-sort-props': [ |
| 33 | + 'error', |
| 34 | + { |
| 35 | + multiline: 'first', |
| 36 | + reservedFirst: ['key'], |
| 37 | + callbacksLast: true, |
| 38 | + shorthandLast: true, |
| 39 | + }, |
| 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 |
| 42 | + 'react/display-name': 'off', |
| 43 | + }, |
| 44 | +} |
| 45 | + |
| 46 | +/** @type {import("eslint").Linter.Config} */ |
| 47 | +const typescript = defineConfig([typeScriptConfig, { |
| 48 | + files: ['**/*.ts', '**/*.tsx'], |
| 49 | + rules: { |
| 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/ |
| 52 | + '@typescript-eslint/no-unused-vars': 'off', |
| 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/ |
| 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', |
| 58 | + |
| 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 | + ], |
| 79 | + }, |
| 80 | +}]) |
| 81 | + |
| 82 | +export default defineConfig([ |
| 83 | + expoConfig, |
| 84 | + ignores, |
| 85 | + common, |
| 86 | + typescript, |
| 87 | + react, |
| 88 | +]) |
0 commit comments