@w5s/eslint-config 3.1.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +322 -148
- package/dist/index.js +203 -5
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/rules/esRules/es6.ts +173 -0
- package/src/rules/esRules/strict.ts +6 -0
- package/src/rules/esRules/variables.ts +58 -0
- package/src/rules/esRules.ts +9 -0
- package/src/typegen/jsdoc.d.ts +23 -0
- package/src/typegen/style.d.ts +2 -1
- package/src/typegen/test.d.ts +111 -5
- package/src/typegen/ts.d.ts +25 -0
- package/src/typegen/unicorn.d.ts +161 -142
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/eslint-config",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "ESLint configuration presets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -49,16 +49,16 @@
|
|
|
49
49
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
50
50
|
"@typescript-eslint/parser": "^8.0.0",
|
|
51
51
|
"@vitest/eslint-plugin": "^1.0.0",
|
|
52
|
-
"@w5s/dev": "^3.1.
|
|
53
|
-
"@w5s/prettier-config": "^3.0.
|
|
52
|
+
"@w5s/dev": "^3.1.2",
|
|
53
|
+
"@w5s/prettier-config": "^3.0.3",
|
|
54
54
|
"eslint-plugin-import": "^2.25.0",
|
|
55
55
|
"eslint-plugin-jsdoc": "^61.0.0",
|
|
56
56
|
"eslint-plugin-jsonc": "^2.4.0",
|
|
57
57
|
"eslint-plugin-n": "^17.0.0",
|
|
58
|
-
"eslint-plugin-unicorn": "^
|
|
58
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
59
59
|
"eslint-plugin-yml": "^1.1.0",
|
|
60
60
|
"find-up": "^8.0.0",
|
|
61
|
-
"globals": "^
|
|
61
|
+
"globals": "^17.0.0",
|
|
62
62
|
"jsonc-eslint-parser": "^2.0.0",
|
|
63
63
|
"parse-gitignore": "^2.0.0",
|
|
64
64
|
"yaml-eslint-parser": "^1.0.0"
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
84
|
"sideEffect": false,
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "648be101c2d4f915b97ed7e318da47a6ac19eb5c"
|
|
86
86
|
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
|
|
3
|
+
export const es6 = () => ({
|
|
4
|
+
// enforces no braces where they can be omitted
|
|
5
|
+
// https://eslint.org/docs/rules/arrow-body-style
|
|
6
|
+
// TODO: enable requireReturnForObjectLiteral?
|
|
7
|
+
'arrow-body-style': ['error', 'as-needed', {
|
|
8
|
+
requireReturnForObjectLiteral: false,
|
|
9
|
+
}],
|
|
10
|
+
|
|
11
|
+
// require parens in arrow function arguments
|
|
12
|
+
// https://eslint.org/docs/rules/arrow-parens
|
|
13
|
+
'arrow-parens': ['error', 'always'],
|
|
14
|
+
|
|
15
|
+
// require space before/after arrow function's arrow
|
|
16
|
+
// https://eslint.org/docs/rules/arrow-spacing
|
|
17
|
+
'arrow-spacing': ['error', { before: true, after: true }],
|
|
18
|
+
|
|
19
|
+
// verify super() callings in constructors
|
|
20
|
+
'constructor-super': 'error',
|
|
21
|
+
|
|
22
|
+
// enforce the spacing around the * in generator functions
|
|
23
|
+
// https://eslint.org/docs/rules/generator-star-spacing
|
|
24
|
+
'generator-star-spacing': ['error', { before: false, after: true }],
|
|
25
|
+
|
|
26
|
+
// disallow modifying variables of class declarations
|
|
27
|
+
// https://eslint.org/docs/rules/no-class-assign
|
|
28
|
+
'no-class-assign': 'error',
|
|
29
|
+
|
|
30
|
+
// disallow arrow functions where they could be confused with comparisons
|
|
31
|
+
// https://eslint.org/docs/rules/no-confusing-arrow
|
|
32
|
+
'no-confusing-arrow': ['error', {
|
|
33
|
+
allowParens: true,
|
|
34
|
+
}],
|
|
35
|
+
|
|
36
|
+
// disallow modifying variables that are declared using const
|
|
37
|
+
'no-const-assign': 'error',
|
|
38
|
+
|
|
39
|
+
// disallow duplicate class members
|
|
40
|
+
// https://eslint.org/docs/rules/no-dupe-class-members
|
|
41
|
+
'no-dupe-class-members': 'error',
|
|
42
|
+
|
|
43
|
+
// disallow importing from the same path more than once
|
|
44
|
+
// https://eslint.org/docs/rules/no-duplicate-imports
|
|
45
|
+
// replaced by https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
|
|
46
|
+
'no-duplicate-imports': 'off',
|
|
47
|
+
|
|
48
|
+
// disallow symbol constructor
|
|
49
|
+
// https://eslint.org/docs/rules/no-new-symbol
|
|
50
|
+
'no-new-symbol': 'error',
|
|
51
|
+
|
|
52
|
+
// Disallow specified names in exports
|
|
53
|
+
// https://eslint.org/docs/rules/no-restricted-exports
|
|
54
|
+
'no-restricted-exports': ['error', {
|
|
55
|
+
restrictedNamedExports: [
|
|
56
|
+
'default', // use `export default` to provide a default export
|
|
57
|
+
'then', // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
|
|
58
|
+
],
|
|
59
|
+
}],
|
|
60
|
+
|
|
61
|
+
// disallow specific imports
|
|
62
|
+
// https://eslint.org/docs/rules/no-restricted-imports
|
|
63
|
+
'no-restricted-imports': ['off', {
|
|
64
|
+
paths: [],
|
|
65
|
+
patterns: [],
|
|
66
|
+
}],
|
|
67
|
+
|
|
68
|
+
// disallow to use this/super before super() calling in constructors.
|
|
69
|
+
// https://eslint.org/docs/rules/no-this-before-super
|
|
70
|
+
'no-this-before-super': 'error',
|
|
71
|
+
|
|
72
|
+
// disallow useless computed property keys
|
|
73
|
+
// https://eslint.org/docs/rules/no-useless-computed-key
|
|
74
|
+
'no-useless-computed-key': 'error',
|
|
75
|
+
|
|
76
|
+
// disallow unnecessary constructor
|
|
77
|
+
// https://eslint.org/docs/rules/no-useless-constructor
|
|
78
|
+
'no-useless-constructor': 'error',
|
|
79
|
+
|
|
80
|
+
// disallow renaming import, export, and destructured assignments to the same name
|
|
81
|
+
// https://eslint.org/docs/rules/no-useless-rename
|
|
82
|
+
'no-useless-rename': ['error', {
|
|
83
|
+
ignoreDestructuring: false,
|
|
84
|
+
ignoreImport: false,
|
|
85
|
+
ignoreExport: false,
|
|
86
|
+
}],
|
|
87
|
+
|
|
88
|
+
// require let or const instead of var
|
|
89
|
+
'no-var': 'error',
|
|
90
|
+
|
|
91
|
+
// require method and property shorthand syntax for object literals
|
|
92
|
+
// https://eslint.org/docs/rules/object-shorthand
|
|
93
|
+
'object-shorthand': ['error', 'always', {
|
|
94
|
+
ignoreConstructors: false,
|
|
95
|
+
avoidQuotes: true,
|
|
96
|
+
}],
|
|
97
|
+
|
|
98
|
+
// suggest using arrow functions as callbacks
|
|
99
|
+
'prefer-arrow-callback': ['error', {
|
|
100
|
+
allowNamedFunctions: false,
|
|
101
|
+
allowUnboundThis: true,
|
|
102
|
+
}],
|
|
103
|
+
|
|
104
|
+
// suggest using of const declaration for variables that are never modified after declared
|
|
105
|
+
'prefer-const': ['error', {
|
|
106
|
+
destructuring: 'any',
|
|
107
|
+
ignoreReadBeforeAssign: true,
|
|
108
|
+
}],
|
|
109
|
+
|
|
110
|
+
// Prefer destructuring from arrays and objects
|
|
111
|
+
// https://eslint.org/docs/rules/prefer-destructuring
|
|
112
|
+
'prefer-destructuring': ['error', {
|
|
113
|
+
VariableDeclarator: {
|
|
114
|
+
array: false,
|
|
115
|
+
object: true,
|
|
116
|
+
},
|
|
117
|
+
AssignmentExpression: {
|
|
118
|
+
array: true,
|
|
119
|
+
object: false,
|
|
120
|
+
},
|
|
121
|
+
}, {
|
|
122
|
+
enforceForRenamedProperties: false,
|
|
123
|
+
}],
|
|
124
|
+
|
|
125
|
+
// disallow parseInt() in favor of binary, octal, and hexadecimal literals
|
|
126
|
+
// https://eslint.org/docs/rules/prefer-numeric-literals
|
|
127
|
+
'prefer-numeric-literals': 'error',
|
|
128
|
+
|
|
129
|
+
// suggest using Reflect methods where applicable
|
|
130
|
+
// https://eslint.org/docs/rules/prefer-reflect
|
|
131
|
+
'prefer-reflect': 'off',
|
|
132
|
+
|
|
133
|
+
// use rest parameters instead of arguments
|
|
134
|
+
// https://eslint.org/docs/rules/prefer-rest-params
|
|
135
|
+
'prefer-rest-params': 'error',
|
|
136
|
+
|
|
137
|
+
// suggest using the spread syntax instead of .apply()
|
|
138
|
+
// https://eslint.org/docs/rules/prefer-spread
|
|
139
|
+
'prefer-spread': 'error',
|
|
140
|
+
|
|
141
|
+
// suggest using template literals instead of string concatenation
|
|
142
|
+
// https://eslint.org/docs/rules/prefer-template
|
|
143
|
+
'prefer-template': 'error',
|
|
144
|
+
|
|
145
|
+
// disallow generator functions that do not have yield
|
|
146
|
+
// https://eslint.org/docs/rules/require-yield
|
|
147
|
+
'require-yield': 'error',
|
|
148
|
+
|
|
149
|
+
// enforce spacing between object rest-spread
|
|
150
|
+
// https://eslint.org/docs/rules/rest-spread-spacing
|
|
151
|
+
'rest-spread-spacing': ['error', 'never'],
|
|
152
|
+
|
|
153
|
+
// import sorting
|
|
154
|
+
// https://eslint.org/docs/rules/sort-imports
|
|
155
|
+
'sort-imports': ['off', {
|
|
156
|
+
ignoreCase: false,
|
|
157
|
+
ignoreDeclarationSort: false,
|
|
158
|
+
ignoreMemberSort: false,
|
|
159
|
+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
|
|
160
|
+
}],
|
|
161
|
+
|
|
162
|
+
// require a Symbol description
|
|
163
|
+
// https://eslint.org/docs/rules/symbol-description
|
|
164
|
+
'symbol-description': 'error',
|
|
165
|
+
|
|
166
|
+
// enforce usage of spacing in template strings
|
|
167
|
+
// https://eslint.org/docs/rules/template-curly-spacing
|
|
168
|
+
'template-curly-spacing': 'error',
|
|
169
|
+
|
|
170
|
+
// enforce spacing around the * in yield* expressions
|
|
171
|
+
// https://eslint.org/docs/rules/yield-star-spacing
|
|
172
|
+
'yield-star-spacing': ['error', 'after'],
|
|
173
|
+
} satisfies Linter.RulesRecord);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
|
|
3
|
+
export const variables = () => ({
|
|
4
|
+
// enforce or disallow variable initializations at definition
|
|
5
|
+
'init-declarations': 'off',
|
|
6
|
+
|
|
7
|
+
// disallow the catch clause parameter name being the same as a variable in the outer scope
|
|
8
|
+
'no-catch-shadow': 'off',
|
|
9
|
+
|
|
10
|
+
// disallow deletion of variables
|
|
11
|
+
'no-delete-var': 'error',
|
|
12
|
+
|
|
13
|
+
// disallow labels that share a name with a variable
|
|
14
|
+
// https://eslint.org/docs/rules/no-label-var
|
|
15
|
+
'no-label-var': 'error',
|
|
16
|
+
|
|
17
|
+
// disallow specific globals
|
|
18
|
+
'no-restricted-globals': [
|
|
19
|
+
'error',
|
|
20
|
+
{
|
|
21
|
+
name: 'isFinite',
|
|
22
|
+
message:
|
|
23
|
+
'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'isNaN',
|
|
27
|
+
message:
|
|
28
|
+
'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
|
|
29
|
+
},
|
|
30
|
+
// ...confusingBrowserGlobals.map((g) => ({
|
|
31
|
+
// name: g,
|
|
32
|
+
// message: `Use window.${g} instead. https://github.com/facebook/create-react-app/blob/HEAD/packages/confusing-browser-globals/README.md`,
|
|
33
|
+
// })),
|
|
34
|
+
],
|
|
35
|
+
|
|
36
|
+
// disallow declaration of variables already declared in the outer scope
|
|
37
|
+
'no-shadow': 'error',
|
|
38
|
+
|
|
39
|
+
// disallow shadowing of names such as arguments
|
|
40
|
+
'no-shadow-restricted-names': 'error',
|
|
41
|
+
|
|
42
|
+
// disallow use of undeclared variables unless mentioned in a /*global */ block
|
|
43
|
+
'no-undef': 'error',
|
|
44
|
+
|
|
45
|
+
// disallow use of undefined when initializing variables
|
|
46
|
+
'no-undef-init': 'error',
|
|
47
|
+
|
|
48
|
+
// disallow use of undefined variable
|
|
49
|
+
// https://eslint.org/docs/rules/no-undefined
|
|
50
|
+
// TODO: enable?
|
|
51
|
+
'no-undefined': 'off',
|
|
52
|
+
|
|
53
|
+
// disallow declaration of variables that are not used in the code
|
|
54
|
+
'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
|
|
55
|
+
|
|
56
|
+
// disallow use of variables before they are defined
|
|
57
|
+
'no-use-before-define': ['error', { functions: true, classes: true, variables: true }],
|
|
58
|
+
} satisfies Linter.RulesRecord);
|
package/src/rules/esRules.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { bestPractices } from './esRules/bestPractices.js';
|
|
2
2
|
import { errors } from './esRules/errors.js';
|
|
3
|
+
import { es6 } from './esRules/es6.js';
|
|
3
4
|
import { overrides } from './esRules/overrides.js';
|
|
5
|
+
import { strict } from './esRules/strict.js';
|
|
6
|
+
import { variables } from './esRules/variables.js';
|
|
7
|
+
|
|
4
8
|
export const esRules = () => ({
|
|
5
9
|
...bestPractices(),
|
|
6
10
|
...errors(),
|
|
11
|
+
...es6(),
|
|
12
|
+
...strict(),
|
|
13
|
+
...variables(),
|
|
14
|
+
|
|
15
|
+
// Must be last
|
|
7
16
|
...overrides(),
|
|
8
17
|
});
|
package/src/typegen/jsdoc.d.ts
CHANGED
|
@@ -264,6 +264,11 @@ export interface RuleOptions {
|
|
|
264
264
|
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-type.md#repos-sticky-header
|
|
265
265
|
*/
|
|
266
266
|
'jsdoc/require-property-type'?: Linter.RuleEntry<[]>
|
|
267
|
+
/**
|
|
268
|
+
* Requires that Promise rejections are documented with `@rejects` tags.
|
|
269
|
+
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-rejects.md#repos-sticky-header
|
|
270
|
+
*/
|
|
271
|
+
'jsdoc/require-rejects'?: Linter.RuleEntry<JsdocRequireRejects>
|
|
267
272
|
/**
|
|
268
273
|
* Requires that returns are documented with `@returns`.
|
|
269
274
|
* @see https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns.md#repos-sticky-header
|
|
@@ -412,6 +417,8 @@ type JsdocCheckExamples = []|[{
|
|
|
412
417
|
// ----- jsdoc/check-indentation -----
|
|
413
418
|
type JsdocCheckIndentation = []|[{
|
|
414
419
|
|
|
420
|
+
allowIndentedSections?: boolean
|
|
421
|
+
|
|
415
422
|
excludeTags?: string[]
|
|
416
423
|
}]
|
|
417
424
|
// ----- jsdoc/check-line-alignment -----
|
|
@@ -797,6 +804,8 @@ type JsdocRequireHyphenBeforeParamDescription = []|[("always" | "never")]|[("alw
|
|
|
797
804
|
// ----- jsdoc/require-jsdoc -----
|
|
798
805
|
type JsdocRequireJsdoc = []|[{
|
|
799
806
|
|
|
807
|
+
checkAllFunctionExpressions?: boolean
|
|
808
|
+
|
|
800
809
|
checkConstructors?: boolean
|
|
801
810
|
|
|
802
811
|
checkGetters?: (boolean | "no-setter")
|
|
@@ -917,6 +926,16 @@ type JsdocRequireParamType = []|[{
|
|
|
917
926
|
|
|
918
927
|
setDefaultDestructuredRootType?: boolean
|
|
919
928
|
}]
|
|
929
|
+
// ----- jsdoc/require-rejects -----
|
|
930
|
+
type JsdocRequireRejects = []|[{
|
|
931
|
+
|
|
932
|
+
contexts?: (string | {
|
|
933
|
+
comment?: string
|
|
934
|
+
context?: string
|
|
935
|
+
})[]
|
|
936
|
+
|
|
937
|
+
exemptedBy?: string[]
|
|
938
|
+
}]
|
|
920
939
|
// ----- jsdoc/require-returns -----
|
|
921
940
|
type JsdocRequireReturns = []|[{
|
|
922
941
|
|
|
@@ -1041,6 +1060,10 @@ type JsdocSortTags = []|[{
|
|
|
1041
1060
|
|
|
1042
1061
|
reportTagGroupSpacing?: boolean
|
|
1043
1062
|
|
|
1063
|
+
tagExceptions?: {
|
|
1064
|
+
[k: string]: number
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1044
1067
|
tagSequence?: {
|
|
1045
1068
|
|
|
1046
1069
|
tags?: string[]
|
package/src/typegen/style.d.ts
CHANGED
|
@@ -214,6 +214,7 @@ export interface RuleOptions {
|
|
|
214
214
|
/**
|
|
215
215
|
* Enforce props alphabetical sorting
|
|
216
216
|
* @see https://eslint.style/rules/jsx-sort-props
|
|
217
|
+
* @deprecated
|
|
217
218
|
*/
|
|
218
219
|
'style/jsx-sort-props'?: Linter.RuleEntry<StyleJsxSortProps>
|
|
219
220
|
/**
|
|
@@ -1718,7 +1719,7 @@ type StyleTypeAnnotationSpacing = []|[{
|
|
|
1718
1719
|
after?: boolean
|
|
1719
1720
|
overrides?: {
|
|
1720
1721
|
colon?: _StyleTypeAnnotationSpacing_SpacingConfig
|
|
1721
|
-
arrow?: _StyleTypeAnnotationSpacing_SpacingConfig
|
|
1722
|
+
arrow?: ("ignore" | _StyleTypeAnnotationSpacing_SpacingConfig)
|
|
1722
1723
|
variable?: _StyleTypeAnnotationSpacing_SpacingConfig
|
|
1723
1724
|
parameter?: _StyleTypeAnnotationSpacing_SpacingConfig
|
|
1724
1725
|
property?: _StyleTypeAnnotationSpacing_SpacingConfig
|
package/src/typegen/test.d.ts
CHANGED
|
@@ -10,7 +10,12 @@ declare module 'eslint' {
|
|
|
10
10
|
|
|
11
11
|
export interface RuleOptions {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* enforce using `.each` or `.for` consistently
|
|
14
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-each-for.md
|
|
15
|
+
*/
|
|
16
|
+
'test/consistent-each-for'?: Linter.RuleEntry<TestConsistentEachFor>
|
|
17
|
+
/**
|
|
18
|
+
* require test file pattern
|
|
14
19
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md
|
|
15
20
|
*/
|
|
16
21
|
'test/consistent-test-filename'?: Linter.RuleEntry<TestConsistentTestFilename>
|
|
@@ -19,11 +24,21 @@ export interface RuleOptions {
|
|
|
19
24
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md
|
|
20
25
|
*/
|
|
21
26
|
'test/consistent-test-it'?: Linter.RuleEntry<TestConsistentTestIt>
|
|
27
|
+
/**
|
|
28
|
+
* enforce using vitest or vi but not both
|
|
29
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-vitest-vi.md
|
|
30
|
+
*/
|
|
31
|
+
'test/consistent-vitest-vi'?: Linter.RuleEntry<TestConsistentVitestVi>
|
|
22
32
|
/**
|
|
23
33
|
* enforce having expectation in test body
|
|
24
34
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md
|
|
25
35
|
*/
|
|
26
36
|
'test/expect-expect'?: Linter.RuleEntry<TestExpectExpect>
|
|
37
|
+
/**
|
|
38
|
+
* enforce hoisted APIs to be on top of the file
|
|
39
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/hoisted-apis-on-top.md
|
|
40
|
+
*/
|
|
41
|
+
'test/hoisted-apis-on-top'?: Linter.RuleEntry<[]>
|
|
27
42
|
/**
|
|
28
43
|
* enforce a maximum number of expect per test
|
|
29
44
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md
|
|
@@ -48,7 +63,7 @@ export interface RuleOptions {
|
|
|
48
63
|
* disallow conditional expects
|
|
49
64
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md
|
|
50
65
|
*/
|
|
51
|
-
'test/no-conditional-expect'?: Linter.RuleEntry<
|
|
66
|
+
'test/no-conditional-expect'?: Linter.RuleEntry<TestNoConditionalExpect>
|
|
52
67
|
/**
|
|
53
68
|
* disallow conditional tests
|
|
54
69
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md
|
|
@@ -95,6 +110,11 @@ export interface RuleOptions {
|
|
|
95
110
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-import-node-test.md
|
|
96
111
|
*/
|
|
97
112
|
'test/no-import-node-test'?: Linter.RuleEntry<[]>
|
|
113
|
+
/**
|
|
114
|
+
* disallow importing Vitest globals
|
|
115
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-importing-vitest-globals.md
|
|
116
|
+
*/
|
|
117
|
+
'test/no-importing-vitest-globals'?: Linter.RuleEntry<[]>
|
|
98
118
|
/**
|
|
99
119
|
* disallow string interpolation in snapshots
|
|
100
120
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md
|
|
@@ -126,7 +146,7 @@ export interface RuleOptions {
|
|
|
126
146
|
*/
|
|
127
147
|
'test/no-standalone-expect'?: Linter.RuleEntry<TestNoStandaloneExpect>
|
|
128
148
|
/**
|
|
129
|
-
* disallow using `
|
|
149
|
+
* disallow using the `f` and `x` prefixes in favour of `.only` and `.skip`
|
|
130
150
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-test-prefixes.md
|
|
131
151
|
*/
|
|
132
152
|
'test/no-test-prefixes'?: Linter.RuleEntry<[]>
|
|
@@ -135,6 +155,11 @@ export interface RuleOptions {
|
|
|
135
155
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md
|
|
136
156
|
*/
|
|
137
157
|
'test/no-test-return-statement'?: Linter.RuleEntry<[]>
|
|
158
|
+
/**
|
|
159
|
+
* Disallow unnecessary async function wrapper for expected promises
|
|
160
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-unneeded-async-expect-function.md
|
|
161
|
+
*/
|
|
162
|
+
'test/no-unneeded-async-expect-function'?: Linter.RuleEntry<[]>
|
|
138
163
|
/**
|
|
139
164
|
* Enforce padding around `afterAll` blocks
|
|
140
165
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-after-all-blocks.md
|
|
@@ -175,6 +200,21 @@ export interface RuleOptions {
|
|
|
175
200
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-test-blocks.md
|
|
176
201
|
*/
|
|
177
202
|
'test/padding-around-test-blocks'?: Linter.RuleEntry<[]>
|
|
203
|
+
/**
|
|
204
|
+
* Prefer `toHaveBeenCalledExactlyOnceWith` over `toHaveBeenCalledOnce` and `toHaveBeenCalledWith`
|
|
205
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-exactly-once-with.md
|
|
206
|
+
*/
|
|
207
|
+
'test/prefer-called-exactly-once-with'?: Linter.RuleEntry<[]>
|
|
208
|
+
/**
|
|
209
|
+
* enforce using `toBeCalledOnce()` or `toHaveBeenCalledOnce()`
|
|
210
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-once.md
|
|
211
|
+
*/
|
|
212
|
+
'test/prefer-called-once'?: Linter.RuleEntry<[]>
|
|
213
|
+
/**
|
|
214
|
+
* enforce using `toBeCalledTimes(1)` or `toHaveBeenCalledTimes(1)`
|
|
215
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-times.md
|
|
216
|
+
*/
|
|
217
|
+
'test/prefer-called-times'?: Linter.RuleEntry<[]>
|
|
178
218
|
/**
|
|
179
219
|
* enforce using `toBeCalledWith()` or `toHaveBeenCalledWith()`
|
|
180
220
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md
|
|
@@ -185,13 +225,18 @@ export interface RuleOptions {
|
|
|
185
225
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md
|
|
186
226
|
*/
|
|
187
227
|
'test/prefer-comparison-matcher'?: Linter.RuleEntry<[]>
|
|
228
|
+
/**
|
|
229
|
+
* enforce using a function as a describe title over an equivalent string
|
|
230
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-describe-function-title.md
|
|
231
|
+
*/
|
|
232
|
+
'test/prefer-describe-function-title'?: Linter.RuleEntry<[]>
|
|
188
233
|
/**
|
|
189
234
|
* enforce using `each` rather than manual loops
|
|
190
235
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md
|
|
191
236
|
*/
|
|
192
237
|
'test/prefer-each'?: Linter.RuleEntry<[]>
|
|
193
238
|
/**
|
|
194
|
-
* enforce using the built-in
|
|
239
|
+
* enforce using the built-in equality matchers
|
|
195
240
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-equality-matcher.md
|
|
196
241
|
*/
|
|
197
242
|
'test/prefer-equality-matcher'?: Linter.RuleEntry<[]>
|
|
@@ -205,6 +250,11 @@ export interface RuleOptions {
|
|
|
205
250
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md
|
|
206
251
|
*/
|
|
207
252
|
'test/prefer-expect-resolves'?: Linter.RuleEntry<[]>
|
|
253
|
+
/**
|
|
254
|
+
* enforce using `expectTypeOf` instead of `expect(typeof ...)`
|
|
255
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-type-of.md
|
|
256
|
+
*/
|
|
257
|
+
'test/prefer-expect-type-of'?: Linter.RuleEntry<[]>
|
|
208
258
|
/**
|
|
209
259
|
* enforce having hooks in consistent order
|
|
210
260
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md
|
|
@@ -215,6 +265,16 @@ export interface RuleOptions {
|
|
|
215
265
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md
|
|
216
266
|
*/
|
|
217
267
|
'test/prefer-hooks-on-top'?: Linter.RuleEntry<[]>
|
|
268
|
+
/**
|
|
269
|
+
* prefer dynamic import in mock
|
|
270
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-import-in-mock.md
|
|
271
|
+
*/
|
|
272
|
+
'test/prefer-import-in-mock'?: Linter.RuleEntry<TestPreferImportInMock>
|
|
273
|
+
/**
|
|
274
|
+
* enforce importing Vitest globals
|
|
275
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-importing-vitest-globals.md
|
|
276
|
+
*/
|
|
277
|
+
'test/prefer-importing-vitest-globals'?: Linter.RuleEntry<[]>
|
|
218
278
|
/**
|
|
219
279
|
* enforce lowercase titles
|
|
220
280
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-lowercase-title.md
|
|
@@ -225,6 +285,11 @@ export interface RuleOptions {
|
|
|
225
285
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-promise-shorthand.md
|
|
226
286
|
*/
|
|
227
287
|
'test/prefer-mock-promise-shorthand'?: Linter.RuleEntry<[]>
|
|
288
|
+
/**
|
|
289
|
+
* Prefer mock return shorthands
|
|
290
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-return-shorthand.md
|
|
291
|
+
*/
|
|
292
|
+
'test/prefer-mock-return-shorthand'?: Linter.RuleEntry<[]>
|
|
228
293
|
/**
|
|
229
294
|
* enforce including a hint with external snapshots
|
|
230
295
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-snapshot-hint.md
|
|
@@ -270,6 +335,11 @@ export interface RuleOptions {
|
|
|
270
335
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-contain.md
|
|
271
336
|
*/
|
|
272
337
|
'test/prefer-to-contain'?: Linter.RuleEntry<[]>
|
|
338
|
+
/**
|
|
339
|
+
* Suggest using `toHaveBeenCalledTimes()`
|
|
340
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-been-called-times.md
|
|
341
|
+
*/
|
|
342
|
+
'test/prefer-to-have-been-called-times'?: Linter.RuleEntry<[]>
|
|
273
343
|
/**
|
|
274
344
|
* enforce using toHaveLength()
|
|
275
345
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-length.md
|
|
@@ -285,6 +355,11 @@ export interface RuleOptions {
|
|
|
285
355
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-vi-mocked.md
|
|
286
356
|
*/
|
|
287
357
|
'test/prefer-vi-mocked'?: Linter.RuleEntry<[]>
|
|
358
|
+
/**
|
|
359
|
+
* ensure that every `expect.poll` call is awaited
|
|
360
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-awaited-expect-poll.md
|
|
361
|
+
*/
|
|
362
|
+
'test/require-awaited-expect-poll'?: Linter.RuleEntry<[]>
|
|
288
363
|
/**
|
|
289
364
|
* require setup and teardown to be within a hook
|
|
290
365
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md
|
|
@@ -300,6 +375,11 @@ export interface RuleOptions {
|
|
|
300
375
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-mock-type-parameters.md
|
|
301
376
|
*/
|
|
302
377
|
'test/require-mock-type-parameters'?: Linter.RuleEntry<TestRequireMockTypeParameters>
|
|
378
|
+
/**
|
|
379
|
+
* require tests to declare a timeout
|
|
380
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-test-timeout.md
|
|
381
|
+
*/
|
|
382
|
+
'test/require-test-timeout'?: Linter.RuleEntry<[]>
|
|
303
383
|
/**
|
|
304
384
|
* require toThrow() to be called with an error message
|
|
305
385
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-to-throw-message.md
|
|
@@ -330,9 +410,21 @@ export interface RuleOptions {
|
|
|
330
410
|
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md
|
|
331
411
|
*/
|
|
332
412
|
'test/valid-title'?: Linter.RuleEntry<TestValidTitle>
|
|
413
|
+
/**
|
|
414
|
+
* disallow `.todo` usage
|
|
415
|
+
* @see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/warn-todo.md
|
|
416
|
+
*/
|
|
417
|
+
'test/warn-todo'?: Linter.RuleEntry<[]>
|
|
333
418
|
}
|
|
334
419
|
|
|
335
420
|
/* ======= Declarations ======= */
|
|
421
|
+
// ----- test/consistent-each-for -----
|
|
422
|
+
type TestConsistentEachFor = []|[{
|
|
423
|
+
test?: ("each" | "for")
|
|
424
|
+
it?: ("each" | "for")
|
|
425
|
+
describe?: ("each" | "for")
|
|
426
|
+
suite?: ("each" | "for")
|
|
427
|
+
}]
|
|
336
428
|
// ----- test/consistent-test-filename -----
|
|
337
429
|
type TestConsistentTestFilename = []|[{
|
|
338
430
|
pattern?: string
|
|
@@ -343,6 +435,10 @@ type TestConsistentTestIt = []|[{
|
|
|
343
435
|
fn?: ("test" | "it")
|
|
344
436
|
withinDescribe?: ("test" | "it")
|
|
345
437
|
}]
|
|
438
|
+
// ----- test/consistent-vitest-vi -----
|
|
439
|
+
type TestConsistentVitestVi = []|[{
|
|
440
|
+
fn?: ("vi" | "vitest")
|
|
441
|
+
}]
|
|
346
442
|
// ----- test/expect-expect -----
|
|
347
443
|
type TestExpectExpect = []|[{
|
|
348
444
|
assertFunctionNames?: string[]
|
|
@@ -356,13 +452,19 @@ type TestMaxExpects = []|[{
|
|
|
356
452
|
type TestMaxNestedDescribe = []|[{
|
|
357
453
|
max?: number
|
|
358
454
|
}]
|
|
455
|
+
// ----- test/no-conditional-expect -----
|
|
456
|
+
type TestNoConditionalExpect = []|[{
|
|
457
|
+
|
|
458
|
+
expectAssertions?: boolean
|
|
459
|
+
}]
|
|
359
460
|
// ----- test/no-focused-tests -----
|
|
360
461
|
type TestNoFocusedTests = []|[{
|
|
361
462
|
fixable?: boolean
|
|
362
463
|
}]
|
|
363
464
|
// ----- test/no-hooks -----
|
|
364
465
|
type TestNoHooks = []|[{
|
|
365
|
-
|
|
466
|
+
|
|
467
|
+
allow?: ("beforeAll" | "beforeEach" | "afterAll" | "afterEach")[]
|
|
366
468
|
}]
|
|
367
469
|
// ----- test/no-large-snapshots -----
|
|
368
470
|
type TestNoLargeSnapshots = []|[{
|
|
@@ -390,6 +492,10 @@ type TestPreferExpectAssertions = []|[{
|
|
|
390
492
|
onlyFunctionsWithExpectInLoop?: boolean
|
|
391
493
|
onlyFunctionsWithExpectInCallback?: boolean
|
|
392
494
|
}]
|
|
495
|
+
// ----- test/prefer-import-in-mock -----
|
|
496
|
+
type TestPreferImportInMock = []|[{
|
|
497
|
+
fixable?: boolean
|
|
498
|
+
}]
|
|
393
499
|
// ----- test/prefer-lowercase-title -----
|
|
394
500
|
type TestPreferLowercaseTitle = []|[{
|
|
395
501
|
ignore?: ("describe" | "test" | "it")[]
|