-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy patheslint.config.js
More file actions
71 lines (70 loc) · 2.09 KB
/
Copy patheslint.config.js
File metadata and controls
71 lines (70 loc) · 2.09 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
const js = require('@eslint/js');
const tseslint = require('typescript-eslint');
const prettier = require('eslint-plugin-prettier');
const prettierConfig = require('eslint-config-prettier');
const jest = require('eslint-plugin-jest');
module.exports = [
js.configs.recommended,
...tseslint.configs.recommended,
prettierConfig,
// 通用配置
{
files: ['**/*.{js,mjs,ts}'],
languageOptions: {
parser: tseslint.parser,
ecmaVersion: 2020,
sourceType: 'module',
globals: {
...require('globals').node,
},
},
plugins: {
'@typescript-eslint': tseslint.plugin,
prettier: prettier,
},
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-require-imports': 'warn',
},
},
// Jest 测试文件配置
{
files: ['**/*.test.{js,ts}', '**/*.spec.{js,ts}', 'test/**/*.{js,ts}'],
languageOptions: {
parser: tseslint.parser,
ecmaVersion: 2020,
sourceType: 'module',
globals: {
...require('globals').node,
...require('globals').jest,
},
},
plugins: {
'@typescript-eslint': tseslint.plugin,
prettier: prettier,
jest: jest,
},
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-require-imports': 'warn',
// Jest 特定规则
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
'jest/valid-describe-callback': 'error',
'jest/no-conditional-expect': 'warn',
'jest/no-deprecated-functions': 'warn',
'jest/prefer-strict-equal': 'warn',
'jest/prefer-to-be': 'warn',
'jest/prefer-to-contain': 'warn',
},
},
];