|
| 1 | +import js from "@eslint/js"; |
| 2 | +import tseslint 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 globals from "globals"; |
| 7 | + |
| 8 | +export default [ |
| 9 | + js.configs.recommended, |
| 10 | + { |
| 11 | + // Test files - add vitest globals |
| 12 | + files: ["**/*.test.{ts,tsx}", "**/*.spec.{ts,tsx}", "**/test/**/*.{ts,tsx}"], |
| 13 | + languageOptions: { |
| 14 | + parser: tsparser, |
| 15 | + parserOptions: { |
| 16 | + ecmaVersion: "latest", |
| 17 | + sourceType: "module", |
| 18 | + ecmaFeatures: { |
| 19 | + jsx: true, |
| 20 | + }, |
| 21 | + }, |
| 22 | + globals: { |
| 23 | + ...globals.browser, |
| 24 | + ...globals.node, |
| 25 | + // Vitest globals |
| 26 | + describe: "readonly", |
| 27 | + it: "readonly", |
| 28 | + test: "readonly", |
| 29 | + expect: "readonly", |
| 30 | + vi: "readonly", |
| 31 | + beforeEach: "readonly", |
| 32 | + afterEach: "readonly", |
| 33 | + beforeAll: "readonly", |
| 34 | + afterAll: "readonly", |
| 35 | + // Chrome extension |
| 36 | + chrome: "readonly", |
| 37 | + }, |
| 38 | + }, |
| 39 | + plugins: { |
| 40 | + "@typescript-eslint": tseslint, |
| 41 | + react: react, |
| 42 | + "react-hooks": reactHooks, |
| 43 | + }, |
| 44 | + rules: { |
| 45 | + "@typescript-eslint/no-unused-vars": [ |
| 46 | + "warn", |
| 47 | + { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }, |
| 48 | + ], |
| 49 | + "@typescript-eslint/no-explicit-any": "off", |
| 50 | + "no-unused-vars": "off", |
| 51 | + "no-empty": "off", |
| 52 | + }, |
| 53 | + }, |
| 54 | + { |
| 55 | + // Regular source files |
| 56 | + files: ["**/*.{ts,tsx}"], |
| 57 | + ignores: ["**/*.test.{ts,tsx}", "**/*.spec.{ts,tsx}", "**/test/**/*.{ts,tsx}", "*.config.ts", "*.config.js", "vite.config.*.ts", "vitest.config.*.ts"], |
| 58 | + languageOptions: { |
| 59 | + parser: tsparser, |
| 60 | + parserOptions: { |
| 61 | + ecmaVersion: "latest", |
| 62 | + sourceType: "module", |
| 63 | + ecmaFeatures: { |
| 64 | + jsx: true, |
| 65 | + }, |
| 66 | + }, |
| 67 | + globals: { |
| 68 | + ...globals.browser, |
| 69 | + // Chrome extension |
| 70 | + chrome: "readonly", |
| 71 | + // React 17+ JSX transform |
| 72 | + React: "readonly", |
| 73 | + }, |
| 74 | + }, |
| 75 | + plugins: { |
| 76 | + "@typescript-eslint": tseslint, |
| 77 | + react: react, |
| 78 | + "react-hooks": reactHooks, |
| 79 | + }, |
| 80 | + rules: { |
| 81 | + // TypeScript rules |
| 82 | + "@typescript-eslint/no-unused-vars": [ |
| 83 | + "warn", |
| 84 | + { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }, |
| 85 | + ], |
| 86 | + "@typescript-eslint/no-explicit-any": "warn", |
| 87 | + |
| 88 | + // React rules |
| 89 | + "react/react-in-jsx-scope": "off", |
| 90 | + "react/prop-types": "off", |
| 91 | + "react/jsx-uses-react": "off", |
| 92 | + "react/jsx-uses-vars": "error", |
| 93 | + |
| 94 | + // React Hooks rules |
| 95 | + "react-hooks/rules-of-hooks": "error", |
| 96 | + "react-hooks/exhaustive-deps": "warn", |
| 97 | + |
| 98 | + // General rules |
| 99 | + "no-unused-vars": "off", |
| 100 | + "no-console": "off", |
| 101 | + "no-empty": "off", |
| 102 | + }, |
| 103 | + settings: { |
| 104 | + react: { |
| 105 | + version: "detect", |
| 106 | + }, |
| 107 | + }, |
| 108 | + }, |
| 109 | + { |
| 110 | + // Config files (vite, vitest, tailwind, etc.) - Node.js environment |
| 111 | + files: ["*.config.ts", "*.config.js", "vite.config.*.ts", "vitest.config.*.ts"], |
| 112 | + languageOptions: { |
| 113 | + parser: tsparser, |
| 114 | + parserOptions: { |
| 115 | + ecmaVersion: "latest", |
| 116 | + sourceType: "module", |
| 117 | + }, |
| 118 | + globals: { |
| 119 | + ...globals.node, |
| 120 | + }, |
| 121 | + }, |
| 122 | + plugins: { |
| 123 | + "@typescript-eslint": tseslint, |
| 124 | + }, |
| 125 | + rules: { |
| 126 | + "@typescript-eslint/no-unused-vars": "off", |
| 127 | + "no-unused-vars": "off", |
| 128 | + }, |
| 129 | + }, |
| 130 | + { |
| 131 | + ignores: [ |
| 132 | + "node_modules/**", |
| 133 | + "dist/**", |
| 134 | + "coverage/**", |
| 135 | + "postcss.config.js", |
| 136 | + ], |
| 137 | + }, |
| 138 | +]; |
0 commit comments