|
1 | 1 | // @ts-check |
2 | 2 |
|
3 | | -import * as globals from "globals"; |
| 3 | +import globals from "globals"; |
4 | 4 |
|
| 5 | +import { defineConfig } from "eslint/config"; |
5 | 6 | import eslint from "@eslint/js"; |
6 | | -import tseslint from "typescript-eslint"; |
7 | | -import { flatConfigs as importPlugin } from "eslint-plugin-import"; |
| 7 | +import { configs as tseslint } from "typescript-eslint"; |
| 8 | +import { flatConfigs as importPlugin } from "eslint-plugin-import-x"; |
8 | 9 | import reactPlugin from "eslint-plugin-react"; |
9 | 10 | import reactHooksPlugin from "eslint-plugin-react-hooks"; |
10 | 11 | import jsxA11yPugin from "eslint-plugin-jsx-a11y"; |
11 | 12 | import prettierPlugin from "eslint-plugin-prettier/recommended"; |
12 | 13 |
|
13 | | -export default tseslint.config( |
| 14 | +import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript"; |
| 15 | + |
| 16 | +export default defineConfig( |
14 | 17 | { |
15 | 18 | ignores: [ |
16 | 19 | "**/.idea/", |
17 | 20 | "**/.vscode/", |
18 | 21 | "**/.docusaurus/", |
19 | 22 | "**/node_modules/", |
20 | 23 | "build/", |
| 24 | + ".netlify/", |
21 | 25 | ], |
22 | 26 | }, |
| 27 | + |
| 28 | + eslint.configs.recommended, |
| 29 | + tseslint.recommendedTypeChecked, |
| 30 | + importPlugin.recommended, |
| 31 | + importPlugin.typescript, |
| 32 | + reactPlugin.configs.flat?.recommended, |
| 33 | + reactPlugin.configs.flat?.["jsx-runtime"], |
| 34 | + reactHooksPlugin.configs.flat.recommended, |
| 35 | + jsxA11yPugin.flatConfigs.recommended, |
| 36 | + prettierPlugin, |
| 37 | + |
23 | 38 | { |
24 | | - extends: [ |
25 | | - eslint.configs.recommended, |
26 | | - ...tseslint.configs.recommendedTypeChecked, |
27 | | - importPlugin.recommended, |
28 | | - reactPlugin.configs.flat?.recommended, |
29 | | - reactPlugin.configs.flat?.["jsx-runtime"], |
30 | | - { |
31 | | - plugins: { "react-hooks": reactHooksPlugin }, |
32 | | - rules: { ...reactHooksPlugin.configs.recommended.rules }, |
33 | | - }, |
34 | | - jsxA11yPugin.flatConfigs.recommended, |
35 | | - prettierPlugin, |
36 | | - ], |
| 39 | + files: ["**/*.{js,jsx,ts,tsx,mjs}"], |
37 | 40 |
|
38 | 41 | languageOptions: { |
39 | 42 | ...reactPlugin.configs.flat?.recommended.languageOptions, |
40 | 43 |
|
41 | 44 | globals: { |
42 | 45 | ...globals.browser, |
43 | 46 | ...globals.node, |
| 47 | + ...globals.commonjs, |
| 48 | + ...globals.es2024, |
44 | 49 | window: true, |
45 | 50 | }, |
46 | 51 |
|
47 | | - ecmaVersion: 5, |
48 | | - sourceType: "commonjs", |
| 52 | + ecmaVersion: "latest", |
| 53 | + sourceType: "module", |
49 | 54 |
|
50 | 55 | parserOptions: { |
51 | | - // projectService: true, |
52 | | - projectService: { |
53 | | - // allowDefaultProject: ["eslint.config.mjs"], |
54 | | - defaultProject: "tsconfig.json", |
55 | | - }, |
56 | | - tsconfigRootDir: import.meta.dirname, |
| 56 | + projectService: true, |
57 | 57 | }, |
58 | 58 | }, |
59 | 59 |
|
60 | 60 | settings: { |
61 | 61 | react: { |
62 | 62 | version: "detect", |
63 | 63 | }, |
64 | | - |
65 | | - "import/extensions": [".ts", ".tsx"], |
66 | | - |
67 | | - "import/resolver": { |
68 | | - node: { |
69 | | - paths: ["front"], |
70 | | - }, |
71 | | - }, |
| 64 | + "import-x/resolver-next": [ |
| 65 | + createTypeScriptImportResolver({ |
| 66 | + alwaysTryTypes: true, |
| 67 | + project: "./tsconfig.json", |
| 68 | + // `@docusaurus/tsconfig` sets `baseUrl` to its own package dir under |
| 69 | + // `node_modules/`, which mis-anchors the `@site/*` -> `./*` mapping |
| 70 | + // there. Re-anchor at the project root. |
| 71 | + alias: { |
| 72 | + "@site": [import.meta.dirname], |
| 73 | + }, |
| 74 | + }), |
| 75 | + ], |
72 | 76 | }, |
73 | 77 |
|
74 | 78 | rules: { |
75 | | - "react/jsx-uses-react": 2, |
76 | | - "@typescript-eslint/no-unused-vars": 2, |
77 | | - |
78 | | - // TODO Need to fix the errors in project and delete all the rows below |
79 | | - // basic |
80 | | - "no-async-promise-executor": 0, |
81 | | - "import/no-unresolved": 0, |
82 | | - |
83 | | - // react |
84 | | - "react/prop-types": 0, |
85 | | - "react/no-find-dom-node": 0, |
86 | | - "react/no-unescaped-entities": 0, |
87 | | - "react-hooks/exhaustive-deps": 0, |
88 | | - |
89 | | - // ts |
90 | | - "@typescript-eslint/no-unsafe-member-access": 0, |
91 | | - "@typescript-eslint/no-unsafe-assignment": 0, |
92 | | - "@typescript-eslint/no-unsafe-call": 0, |
93 | | - "@typescript-eslint/no-unsafe-argument": 0, |
94 | | - "@typescript-eslint/no-unsafe-return": 0, |
95 | | - "@typescript-eslint/no-explicit-any": 0, |
96 | | - "@typescript-eslint/restrict-template-expressions": 0, |
97 | | - "@typescript-eslint/restrict-plus-operands": 0, |
98 | | - "@typescript-eslint/no-floating-promises": 0, |
99 | | - "@typescript-eslint/no-misused-promises": 0, |
100 | | - "@typescript-eslint/no-empty-interface": 0, |
101 | | - |
102 | | - // a11y |
103 | | - "jsx-a11y/click-events-have-key-events": 0, |
104 | | - "jsx-a11y/no-static-element-interactions": 0, |
105 | | - "jsx-a11y/img-redundant-alt": 0, |
106 | | - "jsx-a11y/alt-text": 0, |
107 | | - "jsx-a11y/interactive-supports-focus": 0, |
| 79 | + "react/jsx-uses-react": "error", |
| 80 | + "@typescript-eslint/no-unused-vars": "error", |
| 81 | + // Docusaurus virtual modules — declared as ambient types in |
| 82 | + // `@docusaurus/module-type-aliases` and resolved by webpack at build |
| 83 | + // time. They have no on-disk path for the resolver to find. |
| 84 | + "import-x/no-unresolved": [ |
| 85 | + "error", |
| 86 | + { ignore: ["^@theme-(original|init)/", "^@generated/"] }, |
| 87 | + ], |
108 | 88 | }, |
109 | 89 | }, |
110 | 90 | ); |
0 commit comments