-
Notifications
You must be signed in to change notification settings - Fork 43
/
.eslintrc.js
148 lines (148 loc) · 4.56 KB
/
.eslintrc.js
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: ['standard-with-typescript', 'prettier'],
plugins: ['unused-imports', 'unicorn', 'simple-import-sort'],
parserOptions: {
ecmaVersion: 13,
sourceType: 'module',
},
settings: {
'import/internal-regex': '^@bangumi/',
},
rules: {
curly: 'error',
'no-unused-vars': 'off',
'no-else-return': ['error', { allowElseIf: false }],
'unused-imports/no-unused-imports': 'error',
'unicorn/prefer-node-protocol': 'error',
'import/first': 'error',
'import/no-duplicates': 'error',
'import/newline-after-import': 'error',
'simple-import-sort/imports': [
'error',
{
groups: [
// Side effect imports.
['^\\u0000'],
// Node.js builtins prefixed with `node:`.
['^node:'],
// Absolute imports and other imports such as Vue-style `@/foo`.
// Anything not matched in another group.
['^'],
// Packages.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
['^@bangumi/.*'],
// Relative imports.
// Anything that starts with a dot.
['^\\.\\.', '^\\.'],
],
},
],
'import/order': 'off',
},
overrides: [
{
files: ['*.ts', '*.mts', '*.cts', '*.tsx'],
extends: [
'standard-with-typescript',
'standard-jsx',
'standard-react',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/strict',
'prettier',
],
parser: '@typescript-eslint/parser',
plugins: ['react', '@typescript-eslint'],
parserOptions: {
project: './tsconfig.json',
},
settings: {
react: {
version: 'detect',
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts'],
},
'import/extensions': ['.js', '.ts', '.mjs'],
'import/resolver': {
typescript: {
project: ['tsconfig.json'],
},
node: {
project: ['tsconfig.json'],
},
},
},
rules: {
'@typescript-eslint/return-await': ['error', 'in-try-catch'],
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/ban-types': [
'error',
{
types: {
// un-ban a type that's banned by default
Object: false,
'{}': false,
},
extendDefaults: true,
},
],
'@typescript-eslint/ban-ts-comment': 'off',
curly: 'error',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-misused-promises': [
'error',
{
checksVoidReturn: {
attributes: false,
},
},
],
'@typescript-eslint/no-use-before-define': ['error'],
'@typescript-eslint/strict-boolean-expressions': [
'error',
{
allowString: true,
allowNumber: true,
allowNullableNumber: true,
allowNullableString: true,
allowNullableBoolean: true,
allowNullableObject: true,
},
],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/no-implicit-any-catch': 'error',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
// 限制了一些不需要显示指明类型的场景,比如自动推导,导致了一些多余代码
'@typescript-eslint/explicit-function-return-type': 'off',
'react/jsx-closing-tag-location': 'off',
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
},
},
{
files: ['*.tsx'],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
{
files: ['*.spec.tsx', '*.test.tsx', '*.stories.tsx'],
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }],
'@typescript-eslint/consistent-type-assertions': 'off',
},
},
],
};