-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.ts
More file actions
52 lines (51 loc) · 1.56 KB
/
eslint.config.ts
File metadata and controls
52 lines (51 loc) · 1.56 KB
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
import eslintPluginReact from 'eslint-plugin-react';
import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
import eslintPluginReactRefresh from 'eslint-plugin-react-refresh';
import eslintPluginOxlint from 'eslint-plugin-oxlint';
import js from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import tsParser from '@typescript-eslint/parser';
export default tseslint.config([
// 全局忽略
{
ignores: ['**/node_modules/**', '**/dist/**', 'pnpm-lock.yaml', '*.md'],
},
// 主配置
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
ecmaFeatures: { jsx: true },
},
globals: globals.browser,
},
plugins: {
react: eslintPluginReact,
'react-hooks': eslintPluginReactHooks,
'react-refresh': eslintPluginReactRefresh,
},
settings: {
react: { version: 'detect' },
},
extends: [js.configs.recommended, ...eslintPluginOxlint.configs['flat/react']],
rules: {
// ESLint 相关规则
'no-unused-vars': 'off',
'no-multiple-empty-lines': ['warn', { max: 1, maxEOF: 0 }],
'no-trailing-spaces': 'error',
// React 相关
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'react/jsx-uses-vars': 'error',
'react/jsx-key': 'error',
// React Hooks
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
},
]);