@wistia/eslint-config 2.1.0 → 2.2.0
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/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/src/configs/vitest.mjs +0 -4
- package/src/rules/vitest.mjs +88 -0
- package/test/__snapshots__/vitest.mjs.snap +72 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @wistia/eslint-config
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#440](https://github.com/wistia/eslint-config/pull/440) [`57cb9e5`](https://github.com/wistia/eslint-config/commit/57cb9e5613d00dbecdcf325072aea6762419d97e) Thanks [@okize](https://github.com/okize)! - feat: add additional vitest rules
|
|
8
|
+
|
|
9
|
+
## 2.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#438](https://github.com/wistia/eslint-config/pull/438) [`bd5eaaa`](https://github.com/wistia/eslint-config/commit/bd5eaaa1c65f68969a61d67871dbe177cecc94ca) Thanks [@okize](https://github.com/okize)! - fix: official vitest plugin includes formatting rules so we do not need to use `eslint-plugin-jest-formatting`
|
|
14
|
+
|
|
3
15
|
## 2.1.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/package.json
CHANGED
package/src/configs/vitest.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import globalsVitest from 'globals-vitest';
|
|
2
2
|
import vitestPlugin from '@vitest/eslint-plugin';
|
|
3
|
-
import jestFormattingPlugin from 'eslint-plugin-jest-formatting';
|
|
4
3
|
import noOnlyTestsPlugin from 'eslint-plugin-no-only-tests';
|
|
5
4
|
import vitestRules from '../rules/vitest.mjs';
|
|
6
|
-
import jestFormattingRules from '../rules/jest-formatting.mjs';
|
|
7
5
|
|
|
8
6
|
export default [
|
|
9
7
|
{
|
|
@@ -16,12 +14,10 @@ export default [
|
|
|
16
14
|
},
|
|
17
15
|
plugins: {
|
|
18
16
|
vitest: vitestPlugin,
|
|
19
|
-
'jest-formatting': jestFormattingPlugin,
|
|
20
17
|
'no-only-tests': noOnlyTestsPlugin,
|
|
21
18
|
},
|
|
22
19
|
rules: {
|
|
23
20
|
...vitestRules,
|
|
24
|
-
...jestFormattingRules,
|
|
25
21
|
},
|
|
26
22
|
},
|
|
27
23
|
];
|
package/src/rules/vitest.mjs
CHANGED
|
@@ -10,14 +10,26 @@ export default {
|
|
|
10
10
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md
|
|
11
11
|
'vitest/consistent-test-filename': 'error',
|
|
12
12
|
|
|
13
|
+
// Enforce consistent usage of each with for...of
|
|
14
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-each-for.md
|
|
15
|
+
'vitest/consistent-each-for': 'error',
|
|
16
|
+
|
|
13
17
|
// Prefer test or it but not both
|
|
14
18
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md
|
|
15
19
|
'vitest/consistent-test-it': 'error',
|
|
16
20
|
|
|
21
|
+
// Enforce consistent usage of vi vs vitest
|
|
22
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-vitest-vi.md
|
|
23
|
+
'vitest/consistent-vitest-vi': 'error',
|
|
24
|
+
|
|
17
25
|
// Enforce having expectation in test body
|
|
18
26
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md
|
|
19
27
|
'vitest/expect-expect': 'error',
|
|
20
28
|
|
|
29
|
+
// Ensure hoisted APIs (vi.mock, vi.hoisted, etc.) are at the top
|
|
30
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/hoisted-apis-on-top.md
|
|
31
|
+
'vitest/hoisted-apis-on-top': 'error',
|
|
32
|
+
|
|
21
33
|
// Enforce a maximum number of expect per test
|
|
22
34
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md
|
|
23
35
|
'vitest/max-expects': [
|
|
@@ -81,6 +93,10 @@ export default {
|
|
|
81
93
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-import-node-test.md
|
|
82
94
|
'vitest/no-import-node-test': 'error',
|
|
83
95
|
|
|
96
|
+
// Disallow importing vitest globals when using globals: true
|
|
97
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-importing-vitest-globals.md
|
|
98
|
+
'vitest/no-importing-vitest-globals': 'error',
|
|
99
|
+
|
|
84
100
|
// Disallow string interpolation in snapshots
|
|
85
101
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md
|
|
86
102
|
'vitest/no-interpolation-in-snapshots': 'error',
|
|
@@ -113,6 +129,54 @@ export default {
|
|
|
113
129
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md
|
|
114
130
|
'vitest/no-test-return-statement': 'error',
|
|
115
131
|
|
|
132
|
+
// Disallow unnecessary async in expect functions
|
|
133
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-unneeded-async-expect-function.md
|
|
134
|
+
'vitest/no-unneeded-async-expect-function': 'error',
|
|
135
|
+
|
|
136
|
+
// This rule enforces a line of padding before and after 1 or more `afterAll` statements.
|
|
137
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-after-all-blocks.md
|
|
138
|
+
'vitest/padding-around-after-all-blocks': 'error',
|
|
139
|
+
|
|
140
|
+
// This rule enforces a line of padding before and after 1 or more `afterEach` statements.
|
|
141
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-after-each-blocks.md
|
|
142
|
+
'vitest/padding-around-after-each-blocks': 'error',
|
|
143
|
+
|
|
144
|
+
// This rule enforces a line of padding before and after `beforeAll` statements.
|
|
145
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-before-all-blocks.md
|
|
146
|
+
'vitest/padding-around-before-all-blocks': 'error',
|
|
147
|
+
|
|
148
|
+
// This rule enforces a line of padding before and after 1 or more `beforeEach` statements
|
|
149
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-before-each-blocks.md
|
|
150
|
+
'vitest/padding-around-before-each-blocks': 'error',
|
|
151
|
+
|
|
152
|
+
// This rule enforces a line of padding before and after 1 or more `expect` statements
|
|
153
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-expect-groups.md
|
|
154
|
+
'vitest/padding-around-expect-groups': 'error',
|
|
155
|
+
|
|
156
|
+
// This rule enforces a line of padding before and after 1 or more `describe` statements
|
|
157
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-describe-blocks.md
|
|
158
|
+
'vitest/padding-around-describe-blocks': 'error',
|
|
159
|
+
|
|
160
|
+
// This rule enforces a line of padding before and after 1 or more `test`/`it` statements
|
|
161
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-test-blocks.md
|
|
162
|
+
'vitest/padding-around-test-blocks': 'error',
|
|
163
|
+
|
|
164
|
+
// This is a meta rule that simply enables all of the previous rules
|
|
165
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-all.md
|
|
166
|
+
'vitest/padding-around-all': 'off',
|
|
167
|
+
|
|
168
|
+
// Prefer toHaveBeenCalledExactlyOnceWith over separate assertions
|
|
169
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-exactly-once-with.md
|
|
170
|
+
'vitest/prefer-called-exactly-once-with': 'error',
|
|
171
|
+
|
|
172
|
+
// Prefer toHaveBeenCalledOnce() over toHaveBeenCalledTimes(1)
|
|
173
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-once.md
|
|
174
|
+
'vitest/prefer-called-once': 'error',
|
|
175
|
+
|
|
176
|
+
// Prefer toHaveBeenCalledTimes over multiple assertions
|
|
177
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-times.md
|
|
178
|
+
'vitest/prefer-called-times': 'error',
|
|
179
|
+
|
|
116
180
|
// Suggest using toBeCalledWith() or toHaveBeenCalledWith()
|
|
117
181
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md
|
|
118
182
|
'vitest/prefer-called-with': 'error',
|
|
@@ -121,6 +185,10 @@ export default {
|
|
|
121
185
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md
|
|
122
186
|
'vitest/prefer-comparison-matcher': 'error',
|
|
123
187
|
|
|
188
|
+
// Enforce describe titles to match function names
|
|
189
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-describe-function-title.md
|
|
190
|
+
'vitest/prefer-describe-function-title': 'error',
|
|
191
|
+
|
|
124
192
|
// Prefer each rather than manual loops
|
|
125
193
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md
|
|
126
194
|
'vitest/prefer-each': 'error',
|
|
@@ -137,6 +205,10 @@ export default {
|
|
|
137
205
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md
|
|
138
206
|
'vitest/prefer-expect-resolves': 'error',
|
|
139
207
|
|
|
208
|
+
// Prefer expect.typeOf() usage
|
|
209
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-type-of.md
|
|
210
|
+
'vitest/prefer-expect-type-of': 'error',
|
|
211
|
+
|
|
140
212
|
// Prefer having hooks in consistent order
|
|
141
213
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md
|
|
142
214
|
'vitest/prefer-hooks-in-order': 'error',
|
|
@@ -145,6 +217,14 @@ export default {
|
|
|
145
217
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md
|
|
146
218
|
'vitest/prefer-hooks-on-top': 'error',
|
|
147
219
|
|
|
220
|
+
// Prefer vi.importActual/vi.importMock in vi.mock factories
|
|
221
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-import-in-mock.md
|
|
222
|
+
'vitest/prefer-import-in-mock': 'error',
|
|
223
|
+
|
|
224
|
+
// Prefer importing vitest globals instead of using them implicitly
|
|
225
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-importing-vitest-globals.md
|
|
226
|
+
'vitest/prefer-importing-vitest-globals': 'error',
|
|
227
|
+
|
|
148
228
|
// Enforce lowercase titles
|
|
149
229
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-lowercase-title.md
|
|
150
230
|
'vitest/prefer-lowercase-title': 'off',
|
|
@@ -153,6 +233,10 @@ export default {
|
|
|
153
233
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-promise-shorthand.md
|
|
154
234
|
'vitest/prefer-mock-promise-shorthand': 'error',
|
|
155
235
|
|
|
236
|
+
// Prefer mock return shorthands
|
|
237
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-return-shorthand.md
|
|
238
|
+
'vitest/prefer-mock-return-shorthand': 'error',
|
|
239
|
+
|
|
156
240
|
// Prefer including a hint with external snapshots
|
|
157
241
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-snapshot-hint.md
|
|
158
242
|
'vitest/prefer-snapshot-hint': 'error',
|
|
@@ -161,6 +245,10 @@ export default {
|
|
|
161
245
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md
|
|
162
246
|
'vitest/prefer-spy-on': 'error',
|
|
163
247
|
|
|
248
|
+
// Prefer strict boolean matchers (toBe(true) over toBeTruthy())
|
|
249
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-boolean-matchers.md
|
|
250
|
+
'vitest/prefer-strict-boolean-matchers': 'error',
|
|
251
|
+
|
|
164
252
|
// Prefer strict equal over equal
|
|
165
253
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-equal.md
|
|
166
254
|
'vitest/prefer-strict-equal': 'error',
|
|
@@ -36,36 +36,15 @@
|
|
|
36
36
|
"plugins": [
|
|
37
37
|
"@",
|
|
38
38
|
"vitest:vitest@1.6.13",
|
|
39
|
-
"jest-formatting",
|
|
40
39
|
"no-only-tests",
|
|
41
40
|
],
|
|
42
41
|
"rules": {
|
|
43
|
-
"
|
|
44
|
-
2,
|
|
45
|
-
],
|
|
46
|
-
"jest-formatting/padding-around-after-each-blocks": [
|
|
47
|
-
2,
|
|
48
|
-
],
|
|
49
|
-
"jest-formatting/padding-around-all": [
|
|
50
|
-
0,
|
|
51
|
-
],
|
|
52
|
-
"jest-formatting/padding-around-before-all-blocks": [
|
|
53
|
-
2,
|
|
54
|
-
],
|
|
55
|
-
"jest-formatting/padding-around-before-each-blocks": [
|
|
56
|
-
2,
|
|
57
|
-
],
|
|
58
|
-
"jest-formatting/padding-around-describe-blocks": [
|
|
59
|
-
2,
|
|
60
|
-
],
|
|
61
|
-
"jest-formatting/padding-around-expect-groups": [
|
|
62
|
-
2,
|
|
63
|
-
],
|
|
64
|
-
"jest-formatting/padding-around-test-blocks": [
|
|
42
|
+
"no-only-tests/no-only-tests": [
|
|
65
43
|
2,
|
|
66
44
|
],
|
|
67
|
-
"
|
|
45
|
+
"vitest/consistent-each-for": [
|
|
68
46
|
2,
|
|
47
|
+
{},
|
|
69
48
|
],
|
|
70
49
|
"vitest/consistent-test-filename": [
|
|
71
50
|
2,
|
|
@@ -78,6 +57,12 @@
|
|
|
78
57
|
2,
|
|
79
58
|
{},
|
|
80
59
|
],
|
|
60
|
+
"vitest/consistent-vitest-vi": [
|
|
61
|
+
2,
|
|
62
|
+
{
|
|
63
|
+
"fn": "vi",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
81
66
|
"vitest/expect-expect": [
|
|
82
67
|
2,
|
|
83
68
|
{
|
|
@@ -88,6 +73,9 @@
|
|
|
88
73
|
],
|
|
89
74
|
},
|
|
90
75
|
],
|
|
76
|
+
"vitest/hoisted-apis-on-top": [
|
|
77
|
+
2,
|
|
78
|
+
],
|
|
91
79
|
"vitest/max-expects": [
|
|
92
80
|
2,
|
|
93
81
|
{
|
|
@@ -142,6 +130,9 @@
|
|
|
142
130
|
"vitest/no-import-node-test": [
|
|
143
131
|
2,
|
|
144
132
|
],
|
|
133
|
+
"vitest/no-importing-vitest-globals": [
|
|
134
|
+
2,
|
|
135
|
+
],
|
|
145
136
|
"vitest/no-interpolation-in-snapshots": [
|
|
146
137
|
2,
|
|
147
138
|
],
|
|
@@ -174,12 +165,51 @@
|
|
|
174
165
|
"vitest/no-test-return-statement": [
|
|
175
166
|
2,
|
|
176
167
|
],
|
|
168
|
+
"vitest/no-unneeded-async-expect-function": [
|
|
169
|
+
2,
|
|
170
|
+
],
|
|
171
|
+
"vitest/padding-around-after-all-blocks": [
|
|
172
|
+
2,
|
|
173
|
+
],
|
|
174
|
+
"vitest/padding-around-after-each-blocks": [
|
|
175
|
+
2,
|
|
176
|
+
],
|
|
177
|
+
"vitest/padding-around-all": [
|
|
178
|
+
0,
|
|
179
|
+
],
|
|
180
|
+
"vitest/padding-around-before-all-blocks": [
|
|
181
|
+
2,
|
|
182
|
+
],
|
|
183
|
+
"vitest/padding-around-before-each-blocks": [
|
|
184
|
+
2,
|
|
185
|
+
],
|
|
186
|
+
"vitest/padding-around-describe-blocks": [
|
|
187
|
+
2,
|
|
188
|
+
],
|
|
189
|
+
"vitest/padding-around-expect-groups": [
|
|
190
|
+
2,
|
|
191
|
+
],
|
|
192
|
+
"vitest/padding-around-test-blocks": [
|
|
193
|
+
2,
|
|
194
|
+
],
|
|
195
|
+
"vitest/prefer-called-exactly-once-with": [
|
|
196
|
+
2,
|
|
197
|
+
],
|
|
198
|
+
"vitest/prefer-called-once": [
|
|
199
|
+
2,
|
|
200
|
+
],
|
|
201
|
+
"vitest/prefer-called-times": [
|
|
202
|
+
2,
|
|
203
|
+
],
|
|
177
204
|
"vitest/prefer-called-with": [
|
|
178
205
|
2,
|
|
179
206
|
],
|
|
180
207
|
"vitest/prefer-comparison-matcher": [
|
|
181
208
|
2,
|
|
182
209
|
],
|
|
210
|
+
"vitest/prefer-describe-function-title": [
|
|
211
|
+
2,
|
|
212
|
+
],
|
|
183
213
|
"vitest/prefer-each": [
|
|
184
214
|
2,
|
|
185
215
|
],
|
|
@@ -197,12 +227,24 @@
|
|
|
197
227
|
"vitest/prefer-expect-resolves": [
|
|
198
228
|
2,
|
|
199
229
|
],
|
|
230
|
+
"vitest/prefer-expect-type-of": [
|
|
231
|
+
2,
|
|
232
|
+
],
|
|
200
233
|
"vitest/prefer-hooks-in-order": [
|
|
201
234
|
2,
|
|
202
235
|
],
|
|
203
236
|
"vitest/prefer-hooks-on-top": [
|
|
204
237
|
2,
|
|
205
238
|
],
|
|
239
|
+
"vitest/prefer-import-in-mock": [
|
|
240
|
+
2,
|
|
241
|
+
{
|
|
242
|
+
"fixable": true,
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
"vitest/prefer-importing-vitest-globals": [
|
|
246
|
+
2,
|
|
247
|
+
],
|
|
206
248
|
"vitest/prefer-lowercase-title": [
|
|
207
249
|
0,
|
|
208
250
|
{
|
|
@@ -215,6 +257,9 @@
|
|
|
215
257
|
"vitest/prefer-mock-promise-shorthand": [
|
|
216
258
|
2,
|
|
217
259
|
],
|
|
260
|
+
"vitest/prefer-mock-return-shorthand": [
|
|
261
|
+
2,
|
|
262
|
+
],
|
|
218
263
|
"vitest/prefer-snapshot-hint": [
|
|
219
264
|
2,
|
|
220
265
|
"multi",
|
|
@@ -222,6 +267,9 @@
|
|
|
222
267
|
"vitest/prefer-spy-on": [
|
|
223
268
|
2,
|
|
224
269
|
],
|
|
270
|
+
"vitest/prefer-strict-boolean-matchers": [
|
|
271
|
+
2,
|
|
272
|
+
],
|
|
225
273
|
"vitest/prefer-strict-equal": [
|
|
226
274
|
2,
|
|
227
275
|
],
|