File
Blob: eslint.config.js
| 1 | import js from "@eslint/js"; |
| 2 | import { defineConfig } from "eslint/config"; |
| 3 | import reactHooks from "eslint-plugin-react-hooks"; |
| 4 | import reactRefresh from "eslint-plugin-react-refresh"; |
| 5 | import globals from "globals"; |
| 6 | import tseslint from "typescript-eslint"; |
| 7 | |
| 8 | export default defineConfig( |
| 9 | { |
| 10 | ignores: [ |
| 11 | "dist/**", |
| 12 | "node_modules/**", |
| 13 | ".reference/**", |
| 14 | "playwright-report/**", |
| 15 | "test-results/**", |
| 16 | "worker-configuration.d.ts", |
| 17 | "src/client/lib/emoji/generated/**", |
| 18 | ], |
| 19 | }, |
| 20 | { |
| 21 | files: ["**/*.{js,mjs,cjs,ts,tsx}"], |
| 22 | languageOptions: { |
| 23 | ecmaVersion: "latest", |
| 24 | sourceType: "module", |
| 25 | globals: { |
| 26 | ...globals.browser, |
| 27 | ...globals.node, |
| 28 | }, |
| 29 | }, |
| 30 | }, |
| 31 | js.configs.recommended, |
| 32 | ...tseslint.configs.recommended, |
| 33 | { |
| 34 | files: ["**/*.{ts,tsx}"], |
| 35 | languageOptions: { |
| 36 | parserOptions: { |
| 37 | ecmaFeatures: { |
| 38 | jsx: true, |
| 39 | }, |
| 40 | }, |
| 41 | }, |
| 42 | rules: { |
| 43 | // TypeScript's noUnusedLocals/noUnusedParameters are authoritative here. |
| 44 | // Keep ESLint focused on React Compiler and runtime-safety rules. |
| 45 | "no-unused-vars": "off", |
| 46 | "@typescript-eslint/no-unused-vars": "off", |
| 47 | }, |
| 48 | }, |
| 49 | { |
| 50 | files: ["src/client/**/*.{js,ts,tsx}"], |
| 51 | rules: { |
| 52 | "no-restricted-imports": [ |
| 53 | "error", |
| 54 | { |
| 55 | patterns: [ |
| 56 | { |
| 57 | group: ["@/sites/**", "@/worker/**"], |
| 58 | message: "Client code must use shared contracts instead of importing Sites server or Worker modules.", |
| 59 | }, |
| 60 | ], |
| 61 | }, |
| 62 | ], |
| 63 | }, |
| 64 | }, |
| 65 | { |
| 66 | files: ["src/sites/**/*.{js,ts,tsx}", "src/worker/**/*.{js,ts,tsx}"], |
| 67 | rules: { |
| 68 | "no-restricted-imports": [ |
| 69 | "error", |
| 70 | { |
| 71 | patterns: [ |
| 72 | { |
| 73 | group: ["@/client/**", "@/shared/browser/**"], |
| 74 | message: "Worker and Sites server code must stay free of client and browser-only shared modules.", |
| 75 | }, |
| 76 | ], |
| 77 | }, |
| 78 | ], |
| 79 | }, |
| 80 | }, |
| 81 | { |
| 82 | files: ["src/shared/**/*.{js,ts,tsx}"], |
| 83 | rules: { |
| 84 | "no-restricted-imports": [ |
| 85 | "error", |
| 86 | { |
| 87 | patterns: [ |
| 88 | { |
| 89 | group: ["@/client/**", "@/sites/**", "@/worker/**"], |
| 90 | message: "Shared modules must not depend on runtime-specific client, Sites server, or Worker modules.", |
| 91 | }, |
| 92 | ], |
| 93 | }, |
| 94 | ], |
| 95 | }, |
| 96 | }, |
| 97 | { |
| 98 | files: ["src/client/**/*.{ts,tsx}", "src/shared/browser/**/*.{ts,tsx}"], |
| 99 | ...reactHooks.configs.flat["recommended-latest"], |
| 100 | }, |
| 101 | { |
| 102 | files: ["src/client/**/*.tsx"], |
| 103 | ...reactRefresh.configs.vite, |
| 104 | }, |
| 105 | ); |