1
1
import js from '@eslint/js'
2
- import prettierConfig from 'eslint-config-prettier'
2
+ import vitestPlugin from '@vitest/eslint-plugin'
3
+ import prettierConfig from 'eslint-config-prettier/flat'
4
+ import type { ConfigArray } from 'typescript-eslint'
3
5
import { config , configs , parser } from 'typescript-eslint'
4
6
5
- const ESLintConfig = config (
6
- { name : 'ignores' , ignores : [ '**/dist/' , '**/__testfixtures__/' ] } ,
7
- { name : 'javascript' , ...js . configs . recommended } ,
7
+ const eslintConfig : ConfigArray = config (
8
+ {
9
+ name : 'global-ignores' ,
10
+ ignores : [
11
+ '**/dist/' ,
12
+ '**/.yalc/' ,
13
+ '**/build/' ,
14
+ '**/lib/' ,
15
+ '**/temp/' ,
16
+ '**/.temp/' ,
17
+ '**/.tmp/' ,
18
+ '**/.yarn/' ,
19
+ '**/coverage/' ,
20
+ '**/__testfixtures__/' ,
21
+ ] ,
22
+ } ,
23
+ { name : `${ js . meta . name } /recommended` , ...js . configs . recommended } ,
8
24
...configs . recommended ,
9
25
...configs . stylistic ,
10
- { name : 'prettier-config ' , ...prettierConfig } ,
26
+ { name : 'vitest/recommended ' , ...vitestPlugin . configs . recommended } ,
11
27
{
12
28
name : 'main' ,
13
29
languageOptions : {
@@ -16,27 +32,58 @@ const ESLintConfig = config(
16
32
projectService : {
17
33
defaultProject : './tsconfig.json' ,
18
34
} ,
35
+ tsconfigRootDir : import . meta. dirname ,
19
36
ecmaVersion : 'latest' ,
20
37
} ,
21
38
} ,
22
39
rules : {
23
- 'no-undef' : [ 0 ] ,
24
40
'@typescript-eslint/consistent-type-imports' : [
25
41
2 ,
26
- { fixStyle : 'separate-type-imports' , disallowTypeAnnotations : false } ,
42
+ {
43
+ prefer : 'type-imports' ,
44
+ fixStyle : 'separate-type-imports' ,
45
+ disallowTypeAnnotations : true ,
46
+ } ,
47
+ ] ,
48
+ '@typescript-eslint/consistent-type-exports' : [
49
+ 2 ,
50
+ { fixMixedExportsWithInlineTypeSpecifier : false } ,
51
+ ] ,
52
+ '@typescript-eslint/no-explicit-any' : [
53
+ 2 ,
54
+ { fixToUnknown : false , ignoreRestArgs : false } ,
27
55
] ,
28
- '@typescript-eslint/consistent-type-exports' : [ 2 ] ,
29
- '@typescript-eslint/no-unused-vars' : [ 0 ] ,
30
- '@typescript-eslint/no-explicit-any' : [ 0 ] ,
31
56
'@typescript-eslint/no-empty-object-type' : [
32
57
2 ,
33
- { allowInterfaces : 'with-single-extends' } ,
58
+ { allowInterfaces : 'never' , allowObjectTypes : 'never' } ,
59
+ ] ,
60
+ '@typescript-eslint/no-restricted-types' : [
61
+ 2 ,
62
+ {
63
+ types : {
64
+ '{}' : {
65
+ message : `
66
+ - If you want to represent an empty object, use \`type EmptyObject = Record<string, never>\`.
67
+ - If you want to represent an object literal, use either \`type AnyObject = Record<string, any>\` or \`object\`.
68
+ - If you want to represent any non-nullish value, use \`type AnyNonNullishValue = NonNullable<unknown>\`.` ,
69
+ suggest : [
70
+ 'AnyNonNullishValue' ,
71
+ 'EmptyObject' ,
72
+ 'AnyObject' ,
73
+ 'object' ,
74
+ 'Record<string, never>' ,
75
+ 'Record<string, any>' ,
76
+ 'NonNullable<unknown>' ,
77
+ ] ,
78
+ } ,
79
+ } ,
80
+ } ,
34
81
] ,
35
82
'@typescript-eslint/no-namespace' : [
36
83
2 ,
37
- { allowDeclarations : true , allowDefinitionFiles : true } ,
84
+ { allowDeclarations : false , allowDefinitionFiles : true } ,
38
85
] ,
39
- '@typescript-eslint/ban-ts-comment ' : [ 0 ] ,
86
+ '@typescript-eslint/consistent-type-definitions ' : [ 2 , 'type' ] ,
40
87
'sort-imports' : [
41
88
2 ,
42
89
{
@@ -47,17 +94,76 @@ const ESLintConfig = config(
47
94
allowSeparatedGroups : true ,
48
95
} ,
49
96
] ,
97
+ '@typescript-eslint/unified-signatures' : [ 2 ] ,
98
+ '@typescript-eslint/no-unnecessary-type-parameters' : [ 2 ] ,
99
+ '@typescript-eslint/no-invalid-void-type' : [ 2 ] ,
100
+ '@typescript-eslint/no-confusing-void-expression' : [ 2 ] ,
101
+ '@typescript-eslint/no-duplicate-type-constituents' : [ 2 ] ,
102
+ '@typescript-eslint/require-await' : [ 2 ] ,
103
+ '@typescript-eslint/no-redundant-type-constituents' : [ 2 ] ,
104
+ '@typescript-eslint/no-unnecessary-type-arguments' : [ 2 ] ,
105
+ '@typescript-eslint/no-unnecessary-type-assertion' : [ 2 ] ,
106
+ '@typescript-eslint/prefer-nullish-coalescing' : [ 2 ] ,
107
+ '@typescript-eslint/no-inferrable-types' : [ 2 ] ,
108
+ 'object-shorthand' : [ 2 ] ,
109
+
110
+ 'no-undef' : [ 0 ] ,
111
+ '@typescript-eslint/no-unused-vars' : [
112
+ 0 ,
113
+ {
114
+ vars : 'all' ,
115
+ args : 'after-used' ,
116
+ caughtErrors : 'all' ,
117
+ ignoreRestSiblings : false ,
118
+ reportUsedIgnorePattern : false ,
119
+ } ,
120
+ ] ,
121
+ '@typescript-eslint/ban-ts-comment' : [
122
+ 0 ,
123
+ [
124
+ {
125
+ 'ts-expect-error' : 'allow-with-description' ,
126
+ 'ts-ignore' : true ,
127
+ 'ts-nocheck' : true ,
128
+ 'ts-check' : false ,
129
+ minimumDescriptionLength : 3 ,
130
+ } ,
131
+ ] ,
132
+ ] ,
133
+ 'vitest/valid-title' : [ 0 ] ,
134
+ 'vitest/no-alias-methods' : [ 2 ] ,
135
+ 'vitest/no-disabled-tests' : [ 2 ] ,
136
+ 'vitest/no-focused-tests' : [ 2 ] ,
137
+ 'vitest/no-test-prefixes' : [ 2 ] ,
138
+ 'vitest/no-test-return-statement' : [ 2 ] ,
139
+ 'vitest/prefer-each' : [ 2 ] ,
140
+ 'vitest/prefer-spy-on' : [ 2 ] ,
141
+ 'vitest/prefer-to-be' : [ 2 ] ,
142
+ 'vitest/prefer-to-contain' : [ 2 ] ,
143
+ 'vitest/prefer-to-have-length' : [ 2 ] ,
50
144
} ,
145
+
146
+ settings : {
147
+ vitest : {
148
+ typecheck : true ,
149
+ } ,
150
+ } ,
151
+
51
152
linterOptions : { reportUnusedDisableDirectives : 2 } ,
52
153
} ,
53
154
{
54
155
name : 'commonjs' ,
55
156
files : [ '**/*.c[jt]s' ] ,
56
157
languageOptions : { sourceType : 'commonjs' } ,
57
158
rules : {
58
- '@typescript-eslint/no-require-imports' : [ 0 ] ,
159
+ '@typescript-eslint/no-require-imports' : [
160
+ 0 ,
161
+ [ { allow : [ ] , allowAsImport : false } ] ,
162
+ ] ,
59
163
} ,
60
164
} ,
165
+
166
+ prettierConfig ,
61
167
)
62
168
63
- export default ESLintConfig
169
+ export default eslintConfig
0 commit comments