Skip to content

Commit a3ea5da

Browse files
committed
chore(eslint): 更新 ESLint 配置以使用新 API 格式
- 将配置从 defineConfig 函数调用转换为数组格式 - 添加 react-hooks 和 react-refresh 插件配置 - 集成 TypeScript ESLint 配置到前端项目 - 保留推荐的 ESLint 规则并添加 react-refresh 规则 - 移除 globalIgnores 函数,使用 ignores 属性配置忽略文件 - 更新 React Hooks 推荐规则并添加组件导出检查
1 parent bd6a416 commit a3ea5da

2 files changed

Lines changed: 31 additions & 21 deletions

File tree

himarket-web/himarket-admin/eslint.config.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import js from '@eslint/js'
22
import globals from 'globals'
33
import reactHooks from 'eslint-plugin-react-hooks'
44
import reactRefresh from 'eslint-plugin-react-refresh'
5-
import { defineConfig, globalIgnores } from 'eslint/config'
65

7-
export default defineConfig([
8-
globalIgnores(['dist']),
6+
export default [
7+
{
8+
ignores: ['dist'],
9+
},
10+
js.configs.recommended,
911
{
1012
files: ['**/*.{js,jsx}'],
11-
extends: [
12-
js.configs.recommended,
13-
reactHooks.configs['recommended-latest'],
14-
reactRefresh.configs.vite,
15-
],
13+
plugins: {
14+
'react-hooks': reactHooks,
15+
'react-refresh': reactRefresh,
16+
},
1617
languageOptions: {
1718
ecmaVersion: 2020,
1819
globals: globals.browser,
@@ -23,7 +24,12 @@ export default defineConfig([
2324
},
2425
},
2526
rules: {
27+
...reactHooks.configs.recommended.rules,
28+
'react-refresh/only-export-components': [
29+
'warn',
30+
{ allowConstantExport: true },
31+
],
2632
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
2733
},
2834
},
29-
])
35+
]

himarket-web/himarket-frontend/eslint.config.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@ import globals from 'globals'
33
import reactHooks from 'eslint-plugin-react-hooks'
44
import reactRefresh from 'eslint-plugin-react-refresh'
55
import tseslint from 'typescript-eslint'
6-
import { defineConfig } from 'eslint/config'
76

8-
export default defineConfig(
9-
tseslint.configs.recommended,
10-
reactHooks.configs['recommended-latest'],
11-
{
12-
extends: [
13-
reactRefresh.configs.vite
14-
]
15-
},
7+
export default [
8+
...tseslint.configs.recommended,
169
{
10+
plugins: {
11+
'react-hooks': reactHooks,
12+
'react-refresh': reactRefresh,
13+
},
14+
rules: {
15+
...reactHooks.configs.recommended.rules,
16+
'react-refresh/only-export-components': [
17+
'warn',
18+
{ allowConstantExport: true },
19+
],
20+
},
1721
languageOptions: {
1822
globals: globals.browser,
19-
}
20-
}
21-
)
23+
},
24+
},
25+
]
2226

0 commit comments

Comments
 (0)