|
| 1 | +import js from "@eslint/js"; |
| 2 | +import ts from "@typescript-eslint/eslint-plugin"; |
| 3 | +import tsParser from "@typescript-eslint/parser"; |
| 4 | +import react from "eslint-plugin-react"; |
| 5 | +import reactHooks from "eslint-plugin-react-hooks"; |
| 6 | +import jsxA11y from "eslint-plugin-jsx-a11y"; |
| 7 | +import compat from "eslint-plugin-compat"; |
| 8 | +import globals from "globals"; |
| 9 | + |
| 10 | +export default [ |
| 11 | + { |
| 12 | + ignores: ["node_modules/**", "dist/**"], |
| 13 | + }, |
| 14 | + js.configs.recommended, |
| 15 | + { |
| 16 | + files: ["src/**/*.{js,jsx,ts,tsx}"], |
| 17 | + languageOptions: { |
| 18 | + ecmaVersion: 2024, |
| 19 | + sourceType: "module", |
| 20 | + globals: { |
| 21 | + ...globals.browser, |
| 22 | + }, |
| 23 | + parserOptions: { |
| 24 | + ecmaFeatures: { jsx: true }, |
| 25 | + }, |
| 26 | + }, |
| 27 | + plugins: { |
| 28 | + react, |
| 29 | + "react-hooks": reactHooks, |
| 30 | + "jsx-a11y": jsxA11y, |
| 31 | + compat, |
| 32 | + "@typescript-eslint": ts, |
| 33 | + }, |
| 34 | + settings: { |
| 35 | + react: { version: "detect" }, |
| 36 | + }, |
| 37 | + rules: { |
| 38 | + eqeqeq: "error", |
| 39 | + }, |
| 40 | + }, |
| 41 | + { |
| 42 | + files: ["src/**/*.{ts,tsx}"], |
| 43 | + languageOptions: { |
| 44 | + parser: tsParser, |
| 45 | + parserOptions: { |
| 46 | + // Enables type-aware linting without listing tsconfig files manually |
| 47 | + projectService: true, |
| 48 | + ecmaFeatures: { jsx: true }, |
| 49 | + }, |
| 50 | + }, |
| 51 | + ...ts.configs.recommendedTypeChecked, |
| 52 | + rules: { |
| 53 | + // Prefer TS rules; disable base ones that conflict |
| 54 | + "no-unused-vars": "off", |
| 55 | + "no-redeclare": "off", |
| 56 | + "@typescript-eslint/no-unused-vars": [ |
| 57 | + "warn", |
| 58 | + { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }, |
| 59 | + ], |
| 60 | + "@typescript-eslint/no-redeclare": "error", |
| 61 | + "@typescript-eslint/no-explicit-any": ["warn", { ignoreRestArgs: true }], |
| 62 | + }, |
| 63 | + }, |
| 64 | + { |
| 65 | + files: ["src/**/*.{js,jsx}"], |
| 66 | + rules: { |
| 67 | + "@typescript-eslint/no-unused-vars": "off", |
| 68 | + "@typescript-eslint/no-redeclare": "off", |
| 69 | + "@typescript-eslint/no-explicit-any": "off", |
| 70 | + }, |
| 71 | + }, |
| 72 | + { |
| 73 | + files: ["src/**/*.{jsx,tsx}"], |
| 74 | + rules: { |
| 75 | + ...react.configs.recommended.rules, |
| 76 | + ...jsxA11y.configs.recommended.rules, |
| 77 | + "react-hooks/rules-of-hooks": "error", |
| 78 | + "react-hooks/exhaustive-deps": "warn", |
| 79 | + "react/prop-types": "off", |
| 80 | + "react/jsx-key": "error", |
| 81 | + }, |
| 82 | + }, |
| 83 | + { |
| 84 | + files: ["src/**/*.{js,jsx,ts,tsx}"], |
| 85 | + rules: { |
| 86 | + ...compat.configs.recommended.rules, |
| 87 | + }, |
| 88 | + }, |
| 89 | +]; |
0 commit comments