|
| 1 | +import js from "@eslint/js"; |
| 2 | +import globals from "globals"; |
| 3 | +import vitest from "@vitest/eslint-plugin"; |
| 4 | +import reactHooks from "eslint-plugin-react-hooks"; |
| 5 | +import reactRefresh from "eslint-plugin-react-refresh"; |
| 6 | +import eslintConfigPrettier from "eslint-config-prettier"; |
| 7 | +import { defineConfig, globalIgnores } from "eslint/config"; |
| 8 | + |
| 9 | +const unusedVarsRule = ["error", { varsIgnorePattern: "^[A-Z_]|^_", argsIgnorePattern: "^_" }]; |
| 10 | +const commonRules = { |
| 11 | + "no-unused-vars": unusedVarsRule, |
| 12 | + "prefer-const": "error", |
| 13 | + "no-var": "error", |
| 14 | +}; |
| 15 | + |
| 16 | +export default defineConfig([ |
| 17 | + globalIgnores(["**/dist/**", "**/coverage/**", "**/node_modules/**", "charts/**/templates/**"]), |
| 18 | + |
| 19 | + // controllers + shared modules |
| 20 | + { |
| 21 | + files: [ |
| 22 | + "modules/**/*.{js,jsx}", |
| 23 | + "components/management-controller/**/*.{js,jsx}", |
| 24 | + "components/site-controller/**/*.{js,jsx}", |
| 25 | + "tests/**/*.{js,jsx}", |
| 26 | + "*.js", |
| 27 | + ], |
| 28 | + extends: [js.configs.recommended], |
| 29 | + languageOptions: { |
| 30 | + ecmaVersion: "latest", |
| 31 | + sourceType: "module", |
| 32 | + globals: globals.node, |
| 33 | + }, |
| 34 | + rules: { |
| 35 | + ...commonRules, |
| 36 | + }, |
| 37 | + }, |
| 38 | + |
| 39 | + // Console |
| 40 | + { |
| 41 | + files: ["components/console/**/*.{js,jsx}"], |
| 42 | + extends: [ |
| 43 | + js.configs.recommended, |
| 44 | + reactHooks.configs.flat.recommended, |
| 45 | + reactRefresh.configs.vite, |
| 46 | + ], |
| 47 | + languageOptions: { |
| 48 | + ecmaVersion: 2020, |
| 49 | + globals: globals.browser, |
| 50 | + parserOptions: { |
| 51 | + ecmaVersion: "latest", |
| 52 | + ecmaFeatures: { jsx: true }, |
| 53 | + sourceType: "module", |
| 54 | + }, |
| 55 | + }, |
| 56 | + rules: { |
| 57 | + ...commonRules, |
| 58 | + "react-hooks/immutability": "off", |
| 59 | + "react-hooks/set-state-in-effect": "off", |
| 60 | + "react-hooks/rules-of-hooks": "error", |
| 61 | + }, |
| 62 | + }, |
| 63 | + |
| 64 | + // Vitest tests |
| 65 | + { |
| 66 | + files: ["**/*.test.js"], |
| 67 | + extends: [js.configs.recommended, vitest.configs.recommended], |
| 68 | + languageOptions: { |
| 69 | + ecmaVersion: "latest", |
| 70 | + sourceType: "module", |
| 71 | + globals: { |
| 72 | + ...globals.node, |
| 73 | + ...vitest.environments.env.globals, |
| 74 | + }, |
| 75 | + }, |
| 76 | + rules: { |
| 77 | + ...commonRules, |
| 78 | + }, |
| 79 | + }, |
| 80 | + |
| 81 | + eslintConfigPrettier, |
| 82 | +]); |
0 commit comments