|
| 1 | +const { |
| 2 | + defineConfig, |
| 3 | + globalIgnores, |
| 4 | +} = require("eslint/config"); |
| 5 | + |
| 6 | +const globals = require("globals"); |
| 7 | + |
| 8 | +const { |
| 9 | + fixupConfigRules, |
| 10 | +} = require("@eslint/compat"); |
| 11 | + |
| 12 | +const tsParser = require("@typescript-eslint/parser"); |
| 13 | +const reactRefresh = require("eslint-plugin-react-refresh"); |
| 14 | +const js = require("@eslint/js"); |
| 15 | + |
| 16 | +const { |
| 17 | + FlatCompat, |
| 18 | +} = require("@eslint/eslintrc"); |
| 19 | + |
| 20 | +const compat = new FlatCompat({ |
| 21 | + baseDirectory: __dirname, |
| 22 | + recommendedConfig: js.configs.recommended, |
| 23 | + allConfig: js.configs.all |
| 24 | +}); |
| 25 | + |
| 26 | +module.exports = defineConfig([{ |
| 27 | + languageOptions: { |
| 28 | + globals: { |
| 29 | + ...globals.browser, |
| 30 | + }, |
| 31 | + |
| 32 | + parser: tsParser, |
| 33 | + ecmaVersion: "latest", |
| 34 | + sourceType: "module", |
| 35 | + |
| 36 | + parserOptions: { |
| 37 | + project: ["./tsconfig.json", "./tsconfig.node.json"], |
| 38 | + tsconfigRootDir: __dirname, |
| 39 | + ecmaFeatures: { |
| 40 | + jsx: true |
| 41 | + } |
| 42 | + }, |
| 43 | + }, |
| 44 | + |
| 45 | + extends: fixupConfigRules(compat.extends( |
| 46 | + "eslint:recommended", |
| 47 | + "plugin:@typescript-eslint/recommended", |
| 48 | + "plugin:@typescript-eslint/stylistic", |
| 49 | + "plugin:react-hooks/recommended", |
| 50 | + "plugin:react/recommended", |
| 51 | + "plugin:react/jsx-runtime", |
| 52 | + "plugin:import/recommended", |
| 53 | + "prettier", |
| 54 | + )), |
| 55 | + |
| 56 | + plugins: { |
| 57 | + "react-refresh": reactRefresh, |
| 58 | + }, |
| 59 | + |
| 60 | + rules: { |
| 61 | + "react-refresh/only-export-components": ["warn", { |
| 62 | + allowConstantExport: true, |
| 63 | + }], |
| 64 | + |
| 65 | + "import/order": ["error", { |
| 66 | + groups: ["builtin", "external", "internal", "parent", "sibling"], |
| 67 | + "newlines-between": "always", |
| 68 | + }], |
| 69 | + }, |
| 70 | + |
| 71 | + settings: { |
| 72 | + "react": { |
| 73 | + "version": "detect" |
| 74 | + }, |
| 75 | + "import/resolver": { |
| 76 | + alias: { |
| 77 | + map: [ |
| 78 | + ["@components", "./src/components"], |
| 79 | + ["@routes", "./src/routes"], |
| 80 | + ["@assets", "./src/assets"], |
| 81 | + ["@", "./src"], |
| 82 | + ], |
| 83 | + |
| 84 | + extensions: [".ts", ".tsx", ".js", ".jsx", ".json"], |
| 85 | + }, |
| 86 | + }, |
| 87 | + }, |
| 88 | +}, globalIgnores([ |
| 89 | + "**/dist", |
| 90 | + "**/.eslintrc.cjs", |
| 91 | + "**/tailwind.config.js", |
| 92 | + "**/postcss.config.js", |
| 93 | +])]); |
0 commit comments