|
1 | | -import { defineConfig } from "eslint/config"; |
2 | | -import js from '@eslint/js' |
| 1 | +import { resolve } from "node:path"; |
| 2 | +import { cwd } from "node:process"; |
3 | 3 | import globals from 'globals' |
4 | | -import reactHooks from 'eslint-plugin-react-hooks' |
5 | | -import reactRefresh from 'eslint-plugin-react-refresh' |
| 4 | +import { defineConfig } from "eslint/config"; |
| 5 | +import eslint from '@eslint/js' |
6 | 6 | import tseslint from 'typescript-eslint' |
| 7 | +import tsParser from "@typescript-eslint/parser"; |
| 8 | +import reactRefreshPlugin from 'eslint-plugin-react-refresh' |
| 9 | +import reactHooksPlugin from 'eslint-plugin-react-hooks' |
| 10 | + |
| 11 | +const PACKAGE_ROOT = resolve(cwd()); |
7 | 12 |
|
8 | 13 | export default defineConfig( |
9 | | - { ignores: ['dist'] }, |
| 14 | + eslint.configs.recommended, |
| 15 | + ...tseslint.configs.recommended, |
| 16 | + reactHooksPlugin.configs.flat.recommended, |
| 17 | + { |
| 18 | + languageOptions: { |
| 19 | + parserOptions: { |
| 20 | + tsconfigRootDir: PACKAGE_ROOT, |
| 21 | + projectService: true, |
| 22 | + }, |
| 23 | + }, |
| 24 | + }, |
10 | 25 | { |
11 | | - extends: [js.configs.recommended, ...tseslint.configs.recommended], |
12 | 26 | files: ['**/*.{ts,tsx}'], |
13 | 27 | languageOptions: { |
14 | | - ecmaVersion: 2020, |
15 | | - globals: globals.browser, |
| 28 | + parser: tsParser, |
| 29 | + parserOptions: { |
| 30 | + project: ["tsconfig.json"], |
| 31 | + tsconfigRootDir: cwd(), |
| 32 | + projectService: true, |
| 33 | + |
| 34 | + ecmaVersion: "latest", |
| 35 | + sourceType: "module", |
| 36 | + globals: { ...globals.browser, ...globals.es2020 }, |
| 37 | + } |
16 | 38 | }, |
17 | 39 | plugins: { |
18 | | - 'react-hooks': reactHooks, |
19 | | - 'react-refresh': reactRefresh, |
| 40 | + 'react-hooks': reactHooksPlugin, |
| 41 | + 'react-refresh': reactRefreshPlugin, |
20 | 42 | }, |
21 | 43 | rules: { |
22 | | - ...reactHooks.configs.recommended.rules, |
| 44 | + ...reactHooksPlugin.configs.recommended.rules, |
23 | 45 | 'react-refresh/only-export-components': [ |
24 | 46 | 'warn', |
25 | 47 | { allowConstantExport: true }, |
26 | 48 | ], |
27 | 49 | }, |
28 | 50 | }, |
| 51 | + { |
| 52 | + files: ["*.js", "*.cjs", "*.mjs"], |
| 53 | + extends: [tseslint.configs.disableTypeChecked], |
| 54 | + }, |
| 55 | + { |
| 56 | + ignores: ["dist/**"], |
| 57 | + }, |
29 | 58 | ) |
0 commit comments