-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
121 lines (120 loc) · 3.36 KB
/
Copy patheslint.config.js
File metadata and controls
121 lines (120 loc) · 3.36 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
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
112
113
114
115
116
117
118
119
120
121
const js = require('@eslint/js')
const typescript = require('@typescript-eslint/eslint-plugin')
const typescriptParser = require('@typescript-eslint/parser')
const prettier = require('eslint-plugin-prettier')
module.exports = [
js.configs.recommended,
{
files: ['src/**/*.{ts,tsx}', 'client/**/*.{ts,tsx}', 'pages/**/*.{ts,tsx}'],
ignores: ['**/__tests__/**/*'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
project: './tsconfig.json'
},
globals: {
__dirname: 'readonly',
__filename: 'readonly',
process: 'readonly',
Buffer: 'readonly',
console: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly'
}
},
plugins: {
'@typescript-eslint': typescript,
prettier: prettier
},
rules: {
'no-console': 'off', // 允许 console 语句用于调试
'no-eval': 'off',
'no-undef': 'off',
'no-unused-vars': 'off', // 关闭原生规则,使用 TypeScript 版本
'no-case-declarations': 'off',
'no-fallthrough': 'off',
'prefer-const': 'warn',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
'no-unreachable': 'error',
'no-duplicate-imports': 'error',
'prefer-template': 'warn',
'prefer-arrow-callback': 'warn',
'@typescript-eslint/no-var-requires': 'off', // 允许 require
'@typescript-eslint/no-explicit-any': 'warn', // 警告但不报错
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_'
}
],
'@typescript-eslint/no-inferrable-types': 'warn',
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/no-explicit-any': 'off',
'prettier/prettier': 'off'
}
},
{
files: ['**/__tests__/**/*.{ts,tsx}', '**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module'
},
globals: {
describe: 'readonly',
test: 'readonly',
expect: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
beforeAll: 'readonly',
afterAll: 'readonly',
jest: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
process: 'readonly',
Buffer: 'readonly',
console: 'readonly'
}
},
plugins: {
'@typescript-eslint': typescript,
prettier: prettier
},
rules: {
'no-console': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'prettier/prettier': 'off'
}
},
{
files: ['**/*.js'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'commonjs',
globals: {
require: 'readonly',
module: 'readonly',
exports: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
process: 'readonly',
Buffer: 'readonly',
console: 'readonly'
}
},
rules: {
'no-console': 'off'
}
},
{
ignores: ['node_modules/**', 'lib/**', '.next/**', 'coverage/**', '*.config.js']
}
]