|
| 1 | +import eslint from "@eslint/js"; |
| 2 | +import { defineConfig } from "eslint/config"; |
| 3 | +import jsxA11y from "eslint-plugin-jsx-a11y"; |
| 4 | +import prettier from "eslint-plugin-prettier/recommended"; |
| 5 | +import react from "eslint-plugin-react"; |
| 6 | +import reactHooks from "eslint-plugin-react-hooks"; |
| 7 | +import importSort from "eslint-plugin-simple-import-sort"; |
| 8 | +import ts from "typescript-eslint"; |
| 9 | +import R from "react/package.json" with { type: "json" }; |
| 10 | +import jest from "eslint-plugin-jest"; |
| 11 | +import reactNative from "@react-native/eslint-config"; |
| 12 | +import testingLibrary from "eslint-plugin-testing-library"; |
| 13 | + |
| 14 | +export default defineConfig( |
| 15 | + { |
| 16 | + // Note: there should be no other properties in this object |
| 17 | + // docs: https://eslint.org/docs/latest/use/configure/migration-guide#ignore-files |
| 18 | + ignores: [ |
| 19 | + "examples/", |
| 20 | + "coverage/", |
| 21 | + ".yarn/", |
| 22 | + "node_modules/", |
| 23 | + "eslint.config.mjs", |
| 24 | + ], |
| 25 | + }, |
| 26 | + eslint.configs.recommended, |
| 27 | + ts.configs.strict, |
| 28 | + ts.configs.stylistic, |
| 29 | + react.configs.flat.recommended, |
| 30 | + react.configs.flat["jsx-runtime"], |
| 31 | + { |
| 32 | + settings: { |
| 33 | + react: { version: R.version }, |
| 34 | + }, |
| 35 | + }, |
| 36 | + reactHooks.configs.flat.recommended, |
| 37 | + jsxA11y.flatConfigs.recommended, |
| 38 | + { |
| 39 | + ...jest.configs["flat/recommended"], |
| 40 | + ...jest.configs["flat/style"], |
| 41 | + files: ["**/*.test.{ts,tsx,js,jsx}"], |
| 42 | + }, |
| 43 | + { |
| 44 | + ...testingLibrary.configs["flat/react"], |
| 45 | + files: ["**/*.test.{ts,tsx,js,jsx}"], |
| 46 | + }, |
| 47 | + { |
| 48 | + rules: { |
| 49 | + "react-hooks/immutability": "off", |
| 50 | + }, |
| 51 | + files: ["**/*.test.{ts,tsx,js,jsx}"], |
| 52 | + }, |
| 53 | + prettier, // Have to be in the end |
| 54 | + { |
| 55 | + plugins: { |
| 56 | + "simple-import-sort": importSort, |
| 57 | + }, |
| 58 | + rules: { |
| 59 | + "simple-import-sort/imports": [ |
| 60 | + "error", |
| 61 | + { |
| 62 | + // https://github.com/lydell/eslint-plugin-simple-import-sort#custom-grouping |
| 63 | + groups: [ |
| 64 | + // Packages. `react` related packages come first. |
| 65 | + ["^react", "^@?\\w"], |
| 66 | + // Side effect imports. |
| 67 | + ["^\\u0000"], |
| 68 | + // Parent imports. Put `..` last. |
| 69 | + ["^\\.\\.(?!/?$)", "^\\.\\./?$"], |
| 70 | + // Other relative imports. Put same-folder imports and `.` last. |
| 71 | + ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"], |
| 72 | + ], |
| 73 | + }, |
| 74 | + ], |
| 75 | + }, |
| 76 | + }, |
| 77 | + { |
| 78 | + files: ["**/*.{js,ts,tsx}"], |
| 79 | + languageOptions: { |
| 80 | + globals: reactNative.globals, |
| 81 | + }, |
| 82 | + rules: { |
| 83 | + "@typescript-eslint/no-require-imports": "off", // allow to use `require()` |
| 84 | + "@typescript-eslint/no-unused-vars": [ |
| 85 | + "error", |
| 86 | + { |
| 87 | + argsIgnorePattern: "^_", |
| 88 | + varsIgnorePattern: "^_", |
| 89 | + }, |
| 90 | + ], |
| 91 | + }, |
| 92 | + }, |
| 93 | + { |
| 94 | + files: ["**/*.{js,ts,tsx}"], |
| 95 | + rules: { |
| 96 | + "@typescript-eslint/no-explicit-any": "off", |
| 97 | + }, |
| 98 | + }, |
| 99 | +); |
0 commit comments