@@ -24,13 +24,44 @@ export default tseslint.config(
2424 } ,
2525 rules : {
2626 ...reactHooks . configs . recommended . rules ,
27- 'react-refresh/only-export-components' : [ 'warn' , { allowConstantExport : true } ] ,
28- '@typescript-eslint/no-unused-vars' : 'off' , // 禁用 TypeScript 未使用变量的警告
29- 'react-refresh/only-export-components' : 'off' , // 禁用 react-refresh 插件中仅导出组件的规则
30- '@typescript-eslint/no-explicit-any' : 'off' , // 允许使用any
31- '@typescript-eslint/no-unused-expressions' : 'off' , // 关闭对未使用的表达式的检查
27+
28+ // React 相关规则
29+ 'react-refresh/only-export-components' : 'off' ,
3230 '@eslint-react/hooks-extra/no-unnecessary-use-prefix' : 'off' ,
33- // 'react-hooks/exhaustive-deps': 'off' // 关闭依赖项检查规则
31+
32+ // TypeScript 相关规则优化
33+ '@typescript-eslint/no-unused-vars' : [
34+ 'warn' ,
35+ {
36+ argsIgnorePattern : '^_' ,
37+ varsIgnorePattern : '^_' ,
38+ caughtErrorsIgnorePattern : '^_' ,
39+ } ,
40+ ] ,
41+ '@typescript-eslint/no-explicit-any' : 'off' ,
42+ '@typescript-eslint/no-unused-expressions' : [
43+ 'error' ,
44+ {
45+ allowShortCircuit : true ,
46+ allowTernary : true ,
47+ allowTaggedTemplates : true ,
48+ } ,
49+ ] ,
50+ '@typescript-eslint/prefer-nullish-coalescing' : 'off' ,
51+ '@typescript-eslint/prefer-optional-chain' : 'off' ,
52+ '@typescript-eslint/no-non-null-assertion' : 'off' ,
53+
54+ // 代码质量规则
55+ 'no-console' : [ 'warn' , { allow : [ 'warn' , 'error' ] } ] ,
56+ 'no-debugger' : 'error' ,
57+ 'prefer-const' : 'error' ,
58+ 'no-var' : 'error' ,
59+
60+ // React Hooks 规则
61+ 'react-hooks/exhaustive-deps' : 'warn' ,
62+
63+ // 导入规则
64+ 'no-duplicate-imports' : 'error' ,
3465 } ,
3566 languageOptions : {
3667 parser : tseslint . parser ,
0 commit comments