|
1 | | -import js from "@eslint/js"; |
2 | 1 | import globals from "globals"; |
3 | 2 | import tseslint from "typescript-eslint"; |
4 | 3 | import pluginReact from "eslint-plugin-react"; |
5 | | -import { defineConfig } from "eslint/config"; |
| 4 | +import eslintPluginReactHooks from "eslint-plugin-react-hooks"; |
| 5 | +import eslintPluginReactRefresh from "eslint-plugin-react-refresh"; |
| 6 | +import js from "@eslint/js"; // For eslint:recommended |
6 | 7 |
|
7 | | - |
8 | | -export default defineConfig([ |
9 | | - { files: ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"], plugins: { js }, extends: ["js/recommended"] }, |
10 | | - { files: ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"], languageOptions: { globals: globals.browser } }, |
11 | | - tseslint.configs.recommended, |
12 | | - pluginReact.configs.flat.recommended, |
13 | | -]); |
| 8 | +export default [ |
| 9 | + { |
| 10 | + ignores: ["node_modules/", "dist/", "supabase/functions/**"], |
| 11 | + }, |
| 12 | + // Configuration for CJS config files (e.g., postcss.config.cjs, tailwind.config.cjs) |
| 13 | + { |
| 14 | + files: ["*.cjs"], |
| 15 | + languageOptions: { |
| 16 | + ecmaVersion: "latest", |
| 17 | + sourceType: "commonjs", |
| 18 | + globals: { |
| 19 | + ...globals.node, |
| 20 | + module: "writable", |
| 21 | + require: "writable", |
| 22 | + process: "readonly", |
| 23 | + console: "readonly", // adding console global for CJS files |
| 24 | + }, |
| 25 | + }, |
| 26 | + rules: { |
| 27 | + // specific rules for CJS if any, e.g. disable typescript specific rules if they bleed |
| 28 | + "@typescript-eslint/no-var-requires": "off", // Allow require in .cjs files |
| 29 | + "@typescript-eslint/no-require-imports": "off", // Allow require in .cjs files |
| 30 | + } |
| 31 | + }, |
| 32 | + // Configuration for eslint.config.js itself (ES Module) |
| 33 | + { |
| 34 | + files: ["eslint.config.js"], |
| 35 | + languageOptions: { |
| 36 | + ecmaVersion: "latest", |
| 37 | + sourceType: "module", |
| 38 | + globals: { |
| 39 | + ...globals.node, |
| 40 | + process: "readonly", |
| 41 | + }, |
| 42 | + }, |
| 43 | + plugins: { // Ensure typescript plugin is available for rules if needed, though less common for eslint.config.js |
| 44 | + "@typescript-eslint": tseslint.plugin, |
| 45 | + }, |
| 46 | + rules: { // Example: allow console in eslint.config.js |
| 47 | + "no-console": "off", |
| 48 | + "@typescript-eslint/no-var-requires": "off", |
| 49 | + "@typescript-eslint/no-require-imports": "off", |
| 50 | + } |
| 51 | + }, |
| 52 | + // Configuration for TypeScript and TSX files (main src project) |
| 53 | + { |
| 54 | + files: ["src/**/*.{ts,tsx}"], // More specific to src |
| 55 | + languageOptions: { |
| 56 | + parser: tseslint.parser, |
| 57 | + parserOptions: { |
| 58 | + project: "./tsconfig.json", |
| 59 | + ecmaFeatures: { jsx: true }, |
| 60 | + sourceType: "module", |
| 61 | + }, |
| 62 | + globals: { |
| 63 | + ...globals.browser, |
| 64 | + ...globals.es2021, |
| 65 | + }, |
| 66 | + }, |
| 67 | + plugins: { |
| 68 | + "@typescript-eslint": tseslint.plugin, |
| 69 | + "react": pluginReact, |
| 70 | + "react-hooks": eslintPluginReactHooks, |
| 71 | + "react-refresh": eslintPluginReactRefresh, |
| 72 | + }, |
| 73 | + rules: { |
| 74 | + ...js.configs.recommended.rules, // ESLint recommended rules |
| 75 | + ...tseslint.configs.recommended.rules, // TypeScript recommended |
| 76 | + ...pluginReact.configs.recommended.rules, // React recommended |
| 77 | + "react/react-in-jsx-scope": "off", |
| 78 | + "react/prop-types": "off", |
| 79 | + "react-refresh/only-export-components": [ |
| 80 | + "warn", |
| 81 | + { allowConstantExport: true }, |
| 82 | + ], |
| 83 | + "no-undef": "error", // Ensure this is active to catch undefined variables |
| 84 | + "no-unused-vars": "off", // Disable base rule as we use @typescript-eslint/no-unused-vars |
| 85 | + "@typescript-eslint/no-unused-vars": [ |
| 86 | + "error", |
| 87 | + { |
| 88 | + // 先頭に _ を付けた変数・引数は許容 |
| 89 | + varsIgnorePattern: "^_", |
| 90 | + argsIgnorePattern: "^_", |
| 91 | + caughtErrors: "all", |
| 92 | + }, |
| 93 | + ], |
| 94 | + }, |
| 95 | + settings: { |
| 96 | + react: { |
| 97 | + version: "detect", |
| 98 | + }, |
| 99 | + }, |
| 100 | + }, |
| 101 | + // Configuration for mcp project |
| 102 | + { |
| 103 | + files: ["mcp/src/**/*.{ts,tsx}"], // Adjust glob as needed |
| 104 | + languageOptions: { |
| 105 | + parser: tseslint.parser, |
| 106 | + parserOptions: { |
| 107 | + project: "./mcp/tsconfig.json", |
| 108 | + ecmaFeatures: { jsx: true }, // Assuming JSX might be used, adjust if not |
| 109 | + sourceType: "module", |
| 110 | + }, |
| 111 | + globals: { // Adjust globals as needed for mcp project |
| 112 | + ...globals.node, // Or browser, depending on mcp's environment |
| 113 | + }, |
| 114 | + }, |
| 115 | + plugins: { |
| 116 | + "@typescript-eslint": tseslint.plugin, |
| 117 | + // Add other plugins if mcp uses React, etc. |
| 118 | + }, |
| 119 | + rules: { |
| 120 | + ...js.configs.recommended.rules, |
| 121 | + ...tseslint.configs.recommended.rules, |
| 122 | + // Add or override rules specific to mcp project |
| 123 | + }, |
| 124 | + }, |
| 125 | + // Configuration for vite.config.ts |
| 126 | + { |
| 127 | + files: ["vite.config.ts"], |
| 128 | + languageOptions: { |
| 129 | + parser: tseslint.parser, |
| 130 | + parserOptions: { |
| 131 | + project: "./tsconfig.node.json", // Use the tsconfig for Node environment |
| 132 | + sourceType: "module", |
| 133 | + }, |
| 134 | + globals: { |
| 135 | + ...globals.node, |
| 136 | + }, |
| 137 | + }, |
| 138 | + plugins: { |
| 139 | + "@typescript-eslint": tseslint.plugin, |
| 140 | + }, |
| 141 | + rules: { |
| 142 | + ...js.configs.recommended.rules, |
| 143 | + ...tseslint.configs.recommended.rules, |
| 144 | + // Add or override rules specific to vite.config.ts |
| 145 | + }, |
| 146 | + }, |
| 147 | +]; |
0 commit comments