-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy patheslint.config.js
111 lines (107 loc) · 2.77 KB
/
eslint.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import importPlugin from 'eslint-plugin-import';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import reactPlugin from 'eslint-plugin-react';
import typescriptParser from '@typescript-eslint/parser'; // 导入解析器
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
export default [
// Base configuration
{
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
parser: typescriptParser, // 使用解析器作为对象
globals: {
browser: true,
commonjs: true,
es6: true,
},
},
ignores: ["!**/.server", "!**/.client"], // 更新为 ignores
plugins: {
react: reactPlugin,
'jsx-a11y': jsxA11yPlugin, // 添加 jsx-a11y 插件并确保使用引号
'react-hooks': reactHooksPlugin, // 加入 react-hooks 插件
'@typescript-eslint': typescriptPlugin, // 使用插件时需要带引号
import: importPlugin,
},
rules: {
"no-console": "warn",
"no-unused-vars": "warn",
'react-hooks/exhaustive-deps': 'off', // 禁用该规则
},
},
// React 配置
{
files: ["**/*.{js,jsx,ts,tsx}"],
languageOptions: {
parser: typescriptParser, // 使用解析器作为对象
ecmaVersion: "latest",
sourceType: "module",
globals: {
jsx: true, // 将 jsx 移到 globals 中
},
},
plugins: {
react: reactPlugin,
'jsx-a11y': jsxA11yPlugin, // 添加 jsx-a11y 插件并确保使用引号
},
settings: {
react: {
version: "detect",
},
formComponents: ["Form"],
linkComponents: [
{ name: "Link", linkAttribute: "to" },
{ name: "NavLink", linkAttribute: "to" },
],
"import/resolver": {
typescript: {},
},
},
rules: {
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"jsx-a11y/anchor-is-valid": "warn",
},
},
// TypeScript 配置
{
files: ["**/*.{ts,tsx}"],
languageOptions: {
parser: typescriptParser, // 使用解析器作为对象
ecmaVersion: "latest",
sourceType: "module",
},
plugins: {
'@typescript-eslint': typescriptPlugin, // 使用插件时需要带引号
import: importPlugin,
},
settings: {
"import/internal-regex": "^~/",
"import/resolver": {
node: {
extensions: [".ts", ".tsx"],
},
typescript: {
alwaysTryTypes: true,
},
},
},
rules: {
"@typescript-eslint/no-unused-vars": "warn",
},
},
// Node 配置
{
files: [".eslintrc.cjs"],
languageOptions: {
globals: {
node: true,
},
},
rules: {
"no-console": "off",
},
},
];