-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtypescript-strict.mjs
More file actions
71 lines (62 loc) · 1.75 KB
/
typescript-strict.mjs
File metadata and controls
71 lines (62 loc) · 1.75 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
import { defineConfig } from 'eslint/config'
import importPlugin from 'eslint-plugin-import'
import tseslint from 'typescript-eslint'
import { JAVASCRIPT_FILES, TYPESCRIPT_FILES } from '../constants.mjs'
export default defineConfig(
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked,
{
name: 'prefer-code-style/typescript-strict/rules',
files: TYPESCRIPT_FILES,
extends: [importPlugin.flatConfigs.typescript],
languageOptions: {
parserOptions: {
projectService: true,
},
},
rules: {
'import/no-duplicates': [1, { 'prefer-inline': true }],
'@typescript-eslint/consistent-type-imports': [
1,
{
prefer: 'type-imports',
fixStyle: 'inline-type-imports',
disallowTypeAnnotations: true,
},
],
'@typescript-eslint/no-explicit-any': 1,
'@typescript-eslint/no-floating-promises': 1,
'@typescript-eslint/no-unsafe-argument': 1,
'@typescript-eslint/no-unsafe-call': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/prefer-nullish-coalescing': [
1,
{
ignorePrimitives: {
string: true,
},
},
],
'@typescript-eslint/no-use-before-define': [
1,
{
functions: true,
classes: true,
variables: true,
typedefs: false, // 允许类型在定义前使用
},
],
'@typescript-eslint/restrict-template-expressions': [
1,
{
allowNumber: true,
},
],
},
},
{
name: 'prefer-code-style/typescript-strict/disable-type-checked',
files: JAVASCRIPT_FILES,
extends: [tseslint.configs.disableTypeChecked],
},
)