|
| 1 | +// @ts-check |
| 2 | +import eslintJs from "@eslint/js"; |
| 3 | +import eslintReact from "@eslint-react/eslint-plugin"; |
| 4 | +import eslintPluginReactHooks from "eslint-plugin-react-hooks"; |
| 5 | +import eslintPluginReactRefresh from "eslint-plugin-react-refresh"; |
| 6 | +import globals from "globals"; |
| 7 | +import * as tsBlankEslintParser from "ts-blank-eslint-parser"; |
| 8 | + |
| 9 | +import TSCONFIG from "./tsconfig.json" with { type: "json" }; |
| 10 | +import TSCONFIG_NODE from "./tsconfig.node.json" with { type: "json" }; |
| 11 | + |
| 12 | +const GLOB_TS = ["**/*.ts", "**/*.tsx"]; |
| 13 | + |
| 14 | +export default [ |
| 15 | + // base configuration for browser environment source files |
| 16 | + { |
| 17 | + files: TSCONFIG.include, |
| 18 | + languageOptions: { |
| 19 | + globals: { |
| 20 | + ...globals.browser, |
| 21 | + }, |
| 22 | + parser: tsBlankEslintParser, |
| 23 | + parserOptions: { |
| 24 | + jsxPragma: "React", |
| 25 | + sourceType: "module", |
| 26 | + }, |
| 27 | + }, |
| 28 | + rules: { |
| 29 | + ...eslintJs.configs.recommended.rules, |
| 30 | + }, |
| 31 | + }, |
| 32 | + // base configuration for node environment source files (*.config.js, etc.) |
| 33 | + { |
| 34 | + files: TSCONFIG_NODE.include, |
| 35 | + ignores: TSCONFIG_NODE.exclude, |
| 36 | + languageOptions: { |
| 37 | + globals: { |
| 38 | + ...globals.node, |
| 39 | + }, |
| 40 | + parser: tsBlankEslintParser, |
| 41 | + parserOptions: { |
| 42 | + sourceType: "module", |
| 43 | + }, |
| 44 | + }, |
| 45 | + rules: { |
| 46 | + ...eslintJs.configs.recommended.rules, |
| 47 | + "no-console": "off", |
| 48 | + }, |
| 49 | + }, |
| 50 | + // React configuration |
| 51 | + { |
| 52 | + files: TSCONFIG.include, |
| 53 | + ...eslintReact.configs.recommended, |
| 54 | + }, |
| 55 | + // React Hooks configuration |
| 56 | + { |
| 57 | + files: TSCONFIG.include, |
| 58 | + plugins: { |
| 59 | + "react-hooks": eslintPluginReactHooks, |
| 60 | + }, |
| 61 | + rules: eslintPluginReactHooks.configs.recommended.rules, |
| 62 | + }, |
| 63 | + // React Refresh configuration |
| 64 | + { |
| 65 | + files: TSCONFIG.include, |
| 66 | + plugins: { |
| 67 | + "react-refresh": eslintPluginReactRefresh, |
| 68 | + }, |
| 69 | + rules: { |
| 70 | + "react-refresh/only-export-components": "warn", |
| 71 | + }, |
| 72 | + }, |
| 73 | +]; |
0 commit comments