|
1 | 1 | import js from "@eslint/js"; |
2 | 2 | import globals from "globals"; |
| 3 | +import react from "eslint-plugin-react"; |
3 | 4 | import reactHooks from "eslint-plugin-react-hooks"; |
4 | 5 | import reactRefresh from "eslint-plugin-react-refresh"; |
5 | | -import tseslint from "typescript-eslint"; |
| 6 | +import tsPlugin from "@typescript-eslint/eslint-plugin"; |
| 7 | +import tsParser from "@typescript-eslint/parser"; |
6 | 8 |
|
7 | | -export default tseslint.config( |
8 | | - { ignores: ["dist"] }, |
| 9 | +export default [ |
9 | 10 | { |
10 | | - extends: [js.configs.recommended, ...tseslint.configs.recommended], |
11 | 11 | files: ["**/*.{ts,tsx}"], |
| 12 | + ignores: ["dist"], |
| 13 | + languageOptions: { |
| 14 | + parser: tsParser, |
| 15 | + parserOptions: { |
| 16 | + ecmaVersion: 2020, |
| 17 | + sourceType: "module", |
| 18 | + ecmaFeatures: { |
| 19 | + jsx: true, |
| 20 | + }, |
| 21 | + }, |
| 22 | + globals: globals.browser, |
| 23 | + }, |
| 24 | + plugins: { |
| 25 | + react, |
| 26 | + "react-hooks": reactHooks, |
| 27 | + "react-refresh": reactRefresh, |
| 28 | + "@typescript-eslint": tsPlugin, |
| 29 | + }, |
| 30 | + rules: { |
| 31 | + ...js.configs.recommended.rules, |
| 32 | + ...tsPlugin.configs.recommended.rules, |
| 33 | + ...reactHooks.configs.recommended.rules, |
| 34 | + |
| 35 | + // Catch missing JSX imports |
| 36 | + "react/jsx-no-undef": "error", |
| 37 | + |
| 38 | + // React Refresh |
| 39 | + "react-refresh/only-export-components": [ |
| 40 | + "warn", |
| 41 | + { allowConstantExport: true }, |
| 42 | + ], |
| 43 | + |
| 44 | + // Optional TypeScript stricter rules |
| 45 | + "@typescript-eslint/explicit-function-return-type": "warn", |
| 46 | + "@typescript-eslint/no-unused-vars": [ |
| 47 | + "error", |
| 48 | + { argsIgnorePattern: "^_" }, |
| 49 | + ], |
| 50 | + }, |
| 51 | + settings: { |
| 52 | + react: { |
| 53 | + version: "detect", |
| 54 | + }, |
| 55 | + }, |
| 56 | + }, |
| 57 | + { |
| 58 | + files: ["**/*.{js,jsx}"], |
12 | 59 | languageOptions: { |
13 | 60 | ecmaVersion: 2020, |
| 61 | + sourceType: "module", |
14 | 62 | globals: globals.browser, |
| 63 | + parserOptions: { ecmaFeatures: { jsx: true } }, |
15 | 64 | }, |
16 | 65 | plugins: { |
| 66 | + react, |
17 | 67 | "react-hooks": reactHooks, |
18 | 68 | "react-refresh": reactRefresh, |
19 | 69 | }, |
20 | 70 | rules: { |
| 71 | + ...js.configs.recommended.rules, |
21 | 72 | ...reactHooks.configs.recommended.rules, |
| 73 | + "react/jsx-no-undef": "error", |
22 | 74 | "react-refresh/only-export-components": [ |
23 | 75 | "warn", |
24 | 76 | { allowConstantExport: true }, |
25 | 77 | ], |
26 | 78 | }, |
| 79 | + settings: { react: { version: "detect" } }, |
27 | 80 | }, |
28 | | -); |
| 81 | +]; |
0 commit comments