@wistia/oxlint-config 0.7.2 → 0.7.3
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/README.md +4 -4
- package/package.json +1 -1
- package/rules/vitest.mjs +153 -150
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ yarn add -D @wistia/oxlint-config oxlint
|
|
|
19
19
|
|
|
20
20
|
Create an `oxlint.config.ts` in your project root:
|
|
21
21
|
|
|
22
|
-
**TypeScript project** (most common):
|
|
22
|
+
**TypeScript & React project** (most common):
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
25
|
import { defineConfig } from 'oxlint';
|
|
@@ -58,11 +58,11 @@ Feature configs wrap their rules in `overrides` with default file patterns, so t
|
|
|
58
58
|
| ------------------------ | ----------------------------------------- | ------------------------------------- |
|
|
59
59
|
| `reactConfig` | all files (global) | React component + accessibility rules |
|
|
60
60
|
| `styledComponentsConfig` | all files (global) | Styled Components accessibility rules |
|
|
61
|
-
| `vitestConfig` | `**/*.{test,spec,vitest}.{ts,tsx,js,jsx}` | Vitest testing rules |
|
|
62
|
-
| `testingLibraryConfig` | `**/*.{test,spec,vitest}.{ts,tsx,js,jsx}` | Testing Library + jest-dom rules |
|
|
63
|
-
| `storybookConfig` | `**/*.stories.{ts,tsx,js,jsx}` | Storybook story conventions |
|
|
64
61
|
| `nodeConfig` | `**/*.{mts,mjs,cjs}` | Node.js-specific rules |
|
|
62
|
+
| `vitestConfig` | `**/*.{test,vitest}.{ts,tsx,js,jsx}` | Vitest testing rules |
|
|
63
|
+
| `testingLibraryConfig` | `**/*.{test,vitest}.{ts,tsx,js,jsx}` | Testing Library + jest-dom rules |
|
|
65
64
|
| `playwrightConfig` | `**/*.spec.{ts,tsx,js}`, `**/e2e/**/*.ts` | Playwright E2E testing rules |
|
|
65
|
+
| `storybookConfig` | `**/*.stories.{ts,tsx,js,jsx}` | Storybook story conventions |
|
|
66
66
|
|
|
67
67
|
**Composing configs:**
|
|
68
68
|
|
package/package.json
CHANGED
package/rules/vitest.mjs
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
// - "vitest/" for rules that are vitest-specific (no Jest equivalent)
|
|
3
|
-
// - "jest/" for rules that originated in eslint-plugin-jest and are shared with vitest
|
|
4
|
-
// Both namespaces are used here for VITEST projects only. Despite the "jest/" prefix,
|
|
5
|
-
// these rules apply to vitest code. This is an oxlint naming convention, not a dependency on Jest.
|
|
1
|
+
// Native oxlint vitest rules + jsPlugin rules from @vitest/eslint-plugin and eslint-plugin-no-only-tests
|
|
6
2
|
export const vitestRules = {
|
|
7
|
-
plugins: ['vitest'
|
|
3
|
+
plugins: ['vitest'],
|
|
8
4
|
jsPlugins: [
|
|
9
5
|
{ name: 'vitest-js', specifier: '@vitest/eslint-plugin' },
|
|
10
6
|
'eslint-plugin-no-only-tests',
|
|
@@ -40,7 +36,7 @@ export const vitestRules = {
|
|
|
40
36
|
|
|
41
37
|
// Prefer toHaveBeenCalledOnce() over toHaveBeenCalledTimes(1)
|
|
42
38
|
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-called-once.html
|
|
43
|
-
// decision: conflicts with prefer-called-times (
|
|
39
|
+
// decision: conflicts with prefer-called-times (vitest plugin), which is enabled
|
|
44
40
|
'vitest/prefer-called-once': 'off',
|
|
45
41
|
|
|
46
42
|
// Prefer toHaveBeenCalledTimes over multiple assertions
|
|
@@ -110,197 +106,200 @@ export const vitestRules = {
|
|
|
110
106
|
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-snapshot-hint.html
|
|
111
107
|
'vitest/prefer-snapshot-hint': 'error',
|
|
112
108
|
|
|
113
|
-
//
|
|
109
|
+
// Disallow importing vitest globals
|
|
110
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-importing-vitest-globals.html
|
|
111
|
+
// decision: prefer-importing-vitest-globals is already enabled, which serves opposite purpose
|
|
112
|
+
'vitest/no-importing-vitest-globals': 'off',
|
|
113
|
+
|
|
114
|
+
// Suggest using expect.assertions
|
|
115
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-expect-assertions.html
|
|
116
|
+
// decision: too strict for general use, matching vitest-js/prefer-expect-assertions
|
|
117
|
+
'vitest/prefer-expect-assertions': 'off',
|
|
118
|
+
|
|
119
|
+
// Prefer toHaveBeenCalledTimes over multiple assertions
|
|
120
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-to-have-been-called-times.html
|
|
121
|
+
'vitest/prefer-to-have-been-called-times': 'error',
|
|
122
|
+
|
|
123
|
+
// Require test timeout
|
|
124
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/require-test-timeout.html
|
|
125
|
+
// decision: too strict for general use, matching vitest-js/require-test-timeout
|
|
126
|
+
'vitest/require-test-timeout': 'off',
|
|
127
|
+
|
|
128
|
+
// Enforce valid expect in promise
|
|
129
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/valid-expect-in-promise.html
|
|
130
|
+
// decision: too strict for general use, matching vitest-js/valid-expect-in-promise
|
|
131
|
+
'vitest/valid-expect-in-promise': 'off',
|
|
114
132
|
|
|
115
133
|
// Prefer test or it but not both
|
|
116
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
117
|
-
'
|
|
134
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/consistent-test-it.html
|
|
135
|
+
'vitest/consistent-test-it': 'error',
|
|
118
136
|
|
|
119
137
|
// Enforce having expectation in test body
|
|
120
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
121
|
-
'
|
|
138
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/expect-expect.html
|
|
139
|
+
'vitest/expect-expect': 'error',
|
|
122
140
|
|
|
123
141
|
// Enforce a maximum number of expect per test
|
|
124
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
125
|
-
'
|
|
126
|
-
'error',
|
|
127
|
-
{
|
|
128
|
-
max: 15,
|
|
129
|
-
},
|
|
130
|
-
],
|
|
142
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/max-expects.html
|
|
143
|
+
'vitest/max-expects': ['error', { max: 15 }],
|
|
131
144
|
|
|
132
145
|
// Nested describe block should be less than set max value or default value
|
|
133
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
134
|
-
'
|
|
146
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/max-nested-describe.html
|
|
147
|
+
'vitest/max-nested-describe': 'error',
|
|
135
148
|
|
|
136
149
|
// Disallow alias methods
|
|
137
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
138
|
-
'
|
|
150
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-alias-methods.html
|
|
151
|
+
'vitest/no-alias-methods': 'error',
|
|
139
152
|
|
|
140
153
|
// Disallow commented out tests
|
|
141
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
142
|
-
'
|
|
154
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-commented-out-tests.html
|
|
155
|
+
'vitest/no-commented-out-tests': 'error',
|
|
143
156
|
|
|
144
157
|
// Disallow conditional expects
|
|
145
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
146
|
-
'
|
|
158
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-conditional-expect.html
|
|
159
|
+
'vitest/no-conditional-expect': 'error',
|
|
147
160
|
|
|
148
161
|
// Disallow disabled tests
|
|
149
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
162
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-disabled-tests.html
|
|
150
163
|
// decision: it is often useful to be allowed to add a .skip
|
|
151
|
-
'
|
|
164
|
+
'vitest/no-disabled-tests': 'off',
|
|
152
165
|
|
|
153
166
|
// Disallow duplicate hooks and teardown hooks
|
|
154
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
155
|
-
'
|
|
167
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-duplicate-hooks.html
|
|
168
|
+
'vitest/no-duplicate-hooks': 'error',
|
|
156
169
|
|
|
157
170
|
// Disallow focused tests
|
|
158
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
159
|
-
'
|
|
171
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-focused-tests.html
|
|
172
|
+
'vitest/no-focused-tests': 'error',
|
|
160
173
|
|
|
161
174
|
// Disallow setup and teardown hooks
|
|
162
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
163
|
-
'
|
|
175
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-hooks.html
|
|
176
|
+
'vitest/no-hooks': 'off',
|
|
164
177
|
|
|
165
178
|
// Disallow identical titles
|
|
166
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
167
|
-
'
|
|
179
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-identical-title.html
|
|
180
|
+
'vitest/no-identical-title': 'error',
|
|
168
181
|
|
|
169
182
|
// Disallow string interpolation in snapshots
|
|
170
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
171
|
-
'
|
|
183
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-interpolation-in-snapshots.html
|
|
184
|
+
'vitest/no-interpolation-in-snapshots': 'error',
|
|
172
185
|
|
|
173
186
|
// Disallow large snapshots
|
|
174
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
175
|
-
'
|
|
176
|
-
'error',
|
|
177
|
-
{
|
|
178
|
-
maxSize: 500,
|
|
179
|
-
},
|
|
180
|
-
],
|
|
187
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-large-snapshots.html
|
|
188
|
+
'vitest/no-large-snapshots': ['error', { maxSize: 500 }],
|
|
181
189
|
|
|
182
190
|
// Disallow importing from mocks directory
|
|
183
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
184
|
-
'
|
|
191
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-mocks-import.html
|
|
192
|
+
'vitest/no-mocks-import': 'error',
|
|
185
193
|
|
|
186
194
|
// Disallow the use of certain matchers
|
|
187
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
188
|
-
'
|
|
195
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-restricted-matchers.html
|
|
196
|
+
'vitest/no-restricted-matchers': 'error',
|
|
189
197
|
|
|
190
198
|
// Disallow using expect outside of it or test blocks
|
|
191
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
192
|
-
'
|
|
199
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-standalone-expect.html
|
|
200
|
+
'vitest/no-standalone-expect': 'error',
|
|
193
201
|
|
|
194
202
|
// Disallow using test as a prefix
|
|
195
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
196
|
-
'
|
|
203
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-test-prefixes.html
|
|
204
|
+
'vitest/no-test-prefixes': 'error',
|
|
197
205
|
|
|
198
206
|
// Disallow return statements in tests
|
|
199
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
200
|
-
'
|
|
207
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-test-return-statement.html
|
|
208
|
+
'vitest/no-test-return-statement': 'error',
|
|
201
209
|
|
|
202
210
|
// Disallow unnecessary async in expect functions
|
|
203
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
204
|
-
'
|
|
205
|
-
|
|
206
|
-
// Enforce padding around test blocks
|
|
207
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/jest/padding-around-test-blocks.html
|
|
208
|
-
'jest/padding-around-test-blocks': 'error',
|
|
211
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/no-unneeded-async-expect-function.html
|
|
212
|
+
'vitest/no-unneeded-async-expect-function': 'error',
|
|
209
213
|
|
|
210
214
|
// Suggest using toBeCalledWith() or toHaveBeenCalledWith()
|
|
211
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
212
|
-
'
|
|
215
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-called-with.html
|
|
216
|
+
'vitest/prefer-called-with': 'error',
|
|
213
217
|
|
|
214
218
|
// Suggest using the built-in comparison matchers
|
|
215
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
216
|
-
'
|
|
219
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-comparison-matcher.html
|
|
220
|
+
'vitest/prefer-comparison-matcher': 'error',
|
|
217
221
|
|
|
218
222
|
// Prefer each rather than manual loops
|
|
219
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
220
|
-
'
|
|
223
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-each.html
|
|
224
|
+
'vitest/prefer-each': 'error',
|
|
221
225
|
|
|
222
226
|
// Suggest using the built-in equality matchers
|
|
223
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
224
|
-
'
|
|
227
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-equality-matcher.html
|
|
228
|
+
'vitest/prefer-equality-matcher': 'error',
|
|
225
229
|
|
|
226
230
|
// Suggest using expect().resolves over expect(await ...) syntax
|
|
227
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
228
|
-
'
|
|
231
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-expect-resolves.html
|
|
232
|
+
'vitest/prefer-expect-resolves': 'error',
|
|
229
233
|
|
|
230
234
|
// Prefer having hooks in consistent order
|
|
231
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
232
|
-
'
|
|
235
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-hooks-in-order.html
|
|
236
|
+
'vitest/prefer-hooks-in-order': 'error',
|
|
233
237
|
|
|
234
238
|
// Suggest having hooks before any test cases
|
|
235
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
236
|
-
'
|
|
239
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-hooks-on-top.html
|
|
240
|
+
'vitest/prefer-hooks-on-top': 'error',
|
|
237
241
|
|
|
238
242
|
// Enforce lowercase titles
|
|
239
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
243
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-lowercase-title.html
|
|
240
244
|
'vitest/prefer-lowercase-title': 'off',
|
|
241
245
|
|
|
242
246
|
// Prefer mock resolved/rejected shorthands for promises
|
|
243
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
244
|
-
'
|
|
247
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-mock-promise-shorthand.html
|
|
248
|
+
'vitest/prefer-mock-promise-shorthand': 'error',
|
|
245
249
|
|
|
246
250
|
// Prefer mock return shorthands
|
|
247
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
248
|
-
'
|
|
251
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-mock-return-shorthand.html
|
|
252
|
+
'vitest/prefer-mock-return-shorthand': 'error',
|
|
249
253
|
|
|
250
254
|
// Suggest using vi.spyOn
|
|
251
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
252
|
-
'
|
|
255
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-spy-on.html
|
|
256
|
+
'vitest/prefer-spy-on': 'error',
|
|
253
257
|
|
|
254
258
|
// Prefer strict equal over equal
|
|
255
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
256
|
-
'
|
|
259
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-strict-equal.html
|
|
260
|
+
'vitest/prefer-strict-equal': 'error',
|
|
257
261
|
|
|
258
262
|
// Suggest using toBe()
|
|
259
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
260
|
-
'
|
|
263
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-to-be.html
|
|
264
|
+
'vitest/prefer-to-be': 'error',
|
|
261
265
|
|
|
262
266
|
// Prefer using toContain()
|
|
263
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
264
|
-
'
|
|
267
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-to-contain.html
|
|
268
|
+
'vitest/prefer-to-contain': 'error',
|
|
265
269
|
|
|
266
270
|
// Suggest using toHaveLength()
|
|
267
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
268
|
-
'
|
|
271
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-to-have-length.html
|
|
272
|
+
'vitest/prefer-to-have-length': 'error',
|
|
269
273
|
|
|
270
274
|
// Suggest using test.todo
|
|
271
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
272
|
-
'
|
|
275
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-todo.html
|
|
276
|
+
'vitest/prefer-todo': 'error',
|
|
273
277
|
|
|
274
278
|
// Require setup and teardown to be within a hook
|
|
275
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
276
|
-
'
|
|
279
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/require-hook.html
|
|
280
|
+
'vitest/require-hook': 'error',
|
|
277
281
|
|
|
278
282
|
// Require toThrow() to be called with an error message
|
|
279
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
280
|
-
'
|
|
283
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/require-to-throw-message.html
|
|
284
|
+
'vitest/require-to-throw-message': 'error',
|
|
281
285
|
|
|
282
286
|
// Enforce that all tests are in a top-level describe
|
|
283
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
284
|
-
'
|
|
287
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/require-top-level-describe.html
|
|
288
|
+
'vitest/require-top-level-describe': 'error',
|
|
285
289
|
|
|
286
290
|
// Enforce valid describe callback
|
|
287
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
288
|
-
'
|
|
291
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/valid-describe-callback.html
|
|
292
|
+
'vitest/valid-describe-callback': 'error',
|
|
289
293
|
|
|
290
294
|
// Enforce valid expect() usage
|
|
291
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/
|
|
292
|
-
'
|
|
295
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/valid-expect.html
|
|
296
|
+
'vitest/valid-expect': 'error',
|
|
293
297
|
|
|
294
|
-
// Enforce valid titles
|
|
298
|
+
// Enforce valid titles
|
|
295
299
|
// https://oxc.rs/docs/guide/usage/linter/rules/vitest/valid-title.html
|
|
296
300
|
// decision: `allowArguments` avoids conflict with `prefer-describe-function-title` rule, which is enabled
|
|
297
301
|
'vitest/valid-title': ['error', { allowArguments: true }],
|
|
298
302
|
|
|
299
|
-
// Enforce valid titles (jest-specific duplicate of vitest/valid-title)
|
|
300
|
-
// https://oxc.rs/docs/guide/usage/linter/rules/jest/valid-title.html
|
|
301
|
-
// decision: this is covered by `vitest/valid-title`
|
|
302
|
-
'jest/valid-title': 'off',
|
|
303
|
-
|
|
304
303
|
//rules via jsPlugins (@vitest/eslint-plugin + no-only-tests)
|
|
305
304
|
|
|
306
305
|
// Disallow .only tests
|
|
@@ -363,7 +362,7 @@ export const vitestRules = {
|
|
|
363
362
|
|
|
364
363
|
// Prefer test or it but not both
|
|
365
364
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md
|
|
366
|
-
// decision: handled by native
|
|
365
|
+
// decision: handled by native vitest/consistent-test-it
|
|
367
366
|
'vitest-js/consistent-test-it': 'off',
|
|
368
367
|
|
|
369
368
|
// Enforce consistent usage of vi vs vitest
|
|
@@ -373,7 +372,7 @@ export const vitestRules = {
|
|
|
373
372
|
|
|
374
373
|
// Enforce having expectation in test body
|
|
375
374
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md
|
|
376
|
-
// decision: handled by native
|
|
375
|
+
// decision: handled by native vitest/expect-expect
|
|
377
376
|
'vitest-js/expect-expect': 'off',
|
|
378
377
|
|
|
379
378
|
// Ensure hoisted APIs (vi.mock, vi.hoisted, etc.) are at the top
|
|
@@ -383,27 +382,27 @@ export const vitestRules = {
|
|
|
383
382
|
|
|
384
383
|
// Enforce a maximum number of expect per test
|
|
385
384
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md
|
|
386
|
-
// decision: handled by native
|
|
385
|
+
// decision: handled by native vitest/max-expects
|
|
387
386
|
'vitest-js/max-expects': 'off',
|
|
388
387
|
|
|
389
388
|
// Nested describe block should be less than set max value or default value
|
|
390
389
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md
|
|
391
|
-
// decision: handled by native
|
|
390
|
+
// decision: handled by native vitest/max-nested-describe
|
|
392
391
|
'vitest-js/max-nested-describe': 'off',
|
|
393
392
|
|
|
394
393
|
// Disallow alias methods
|
|
395
394
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-alias-methods.md
|
|
396
|
-
// decision: handled by native
|
|
395
|
+
// decision: handled by native vitest/no-alias-methods
|
|
397
396
|
'vitest-js/no-alias-methods': 'off',
|
|
398
397
|
|
|
399
398
|
// Disallow commented out tests
|
|
400
399
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-commented-out-tests.md
|
|
401
|
-
// decision: handled by native
|
|
400
|
+
// decision: handled by native vitest/no-commented-out-tests
|
|
402
401
|
'vitest-js/no-commented-out-tests': 'off',
|
|
403
402
|
|
|
404
403
|
// Disallow conditional expects
|
|
405
404
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md
|
|
406
|
-
// decision: handled by native
|
|
405
|
+
// decision: handled by native vitest/no-conditional-expect
|
|
407
406
|
'vitest-js/no-conditional-expect': 'off',
|
|
408
407
|
|
|
409
408
|
// Disallow conditional tests
|
|
@@ -418,27 +417,31 @@ export const vitestRules = {
|
|
|
418
417
|
|
|
419
418
|
// Disallow disabled tests
|
|
420
419
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md
|
|
421
|
-
// decision: handled by native
|
|
420
|
+
// decision: handled by native vitest/no-disabled-tests
|
|
422
421
|
'vitest-js/no-disabled-tests': 'off',
|
|
423
422
|
|
|
423
|
+
// Disallow done callbacks in tests
|
|
424
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-done-callback.md
|
|
425
|
+
'vitest-js/no-done-callback': 'error',
|
|
426
|
+
|
|
424
427
|
// Disallow duplicate hooks and teardown hooks
|
|
425
428
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-duplicate-hooks.md
|
|
426
|
-
// decision: handled by native
|
|
429
|
+
// decision: handled by native vitest/no-duplicate-hooks
|
|
427
430
|
'vitest-js/no-duplicate-hooks': 'off',
|
|
428
431
|
|
|
429
432
|
// Disallow focused tests
|
|
430
433
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md
|
|
431
|
-
// decision: handled by native
|
|
434
|
+
// decision: handled by native vitest/no-focused-tests
|
|
432
435
|
'vitest-js/no-focused-tests': 'off',
|
|
433
436
|
|
|
434
437
|
// Disallow setup and teardown hooks
|
|
435
438
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md
|
|
436
|
-
// decision: handled by native
|
|
439
|
+
// decision: handled by native vitest/no-hooks
|
|
437
440
|
'vitest-js/no-hooks': 'off',
|
|
438
441
|
|
|
439
442
|
// Disallow identical titles
|
|
440
443
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md
|
|
441
|
-
// decision: handled by native
|
|
444
|
+
// decision: handled by native vitest/no-identical-title
|
|
442
445
|
'vitest-js/no-identical-title': 'off',
|
|
443
446
|
|
|
444
447
|
// Disallow importing node:test
|
|
@@ -453,42 +456,42 @@ export const vitestRules = {
|
|
|
453
456
|
|
|
454
457
|
// Disallow string interpolation in snapshots
|
|
455
458
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md
|
|
456
|
-
// decision: handled by native
|
|
459
|
+
// decision: handled by native vitest/no-interpolation-in-snapshots
|
|
457
460
|
'vitest-js/no-interpolation-in-snapshots': 'off',
|
|
458
461
|
|
|
459
462
|
// Disallow large snapshots
|
|
460
463
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-large-snapshots.md
|
|
461
|
-
// decision: handled by native
|
|
464
|
+
// decision: handled by native vitest/no-large-snapshots
|
|
462
465
|
'vitest-js/no-large-snapshots': 'off',
|
|
463
466
|
|
|
464
467
|
// Disallow importing from mocks directory
|
|
465
468
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md
|
|
466
|
-
// decision: handled by native
|
|
469
|
+
// decision: handled by native vitest/no-mocks-import
|
|
467
470
|
'vitest-js/no-mocks-import': 'off',
|
|
468
471
|
|
|
469
472
|
// Disallow the use of certain matchers
|
|
470
473
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md
|
|
471
|
-
// decision: handled by native
|
|
474
|
+
// decision: handled by native vitest/no-restricted-matchers
|
|
472
475
|
'vitest-js/no-restricted-matchers': 'off',
|
|
473
476
|
|
|
474
477
|
// Disallow using expect outside of it or test blocks
|
|
475
478
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md
|
|
476
|
-
// decision: handled by native
|
|
479
|
+
// decision: handled by native vitest/no-standalone-expect
|
|
477
480
|
'vitest-js/no-standalone-expect': 'off',
|
|
478
481
|
|
|
479
482
|
// Disallow using test as a prefix
|
|
480
483
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-test-prefixes.md
|
|
481
|
-
// decision: handled by native
|
|
484
|
+
// decision: handled by native vitest/no-test-prefixes
|
|
482
485
|
'vitest-js/no-test-prefixes': 'off',
|
|
483
486
|
|
|
484
487
|
// Disallow return statements in tests
|
|
485
488
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md
|
|
486
|
-
// decision: handled by native
|
|
489
|
+
// decision: handled by native vitest/no-test-return-statement
|
|
487
490
|
'vitest-js/no-test-return-statement': 'off',
|
|
488
491
|
|
|
489
492
|
// Disallow unnecessary async in expect functions
|
|
490
493
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-unneeded-async-expect-function.md
|
|
491
|
-
// decision: handled by native
|
|
494
|
+
// decision: handled by native vitest/no-unneeded-async-expect-function
|
|
492
495
|
'vitest-js/no-unneeded-async-expect-function': 'off',
|
|
493
496
|
|
|
494
497
|
// Enforce padding around all blocks
|
|
@@ -498,7 +501,7 @@ export const vitestRules = {
|
|
|
498
501
|
|
|
499
502
|
// Enforce padding around test blocks
|
|
500
503
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-test-blocks.md
|
|
501
|
-
// decision: handled by native
|
|
504
|
+
// decision: handled by native vitest/padding-around-test-blocks
|
|
502
505
|
'vitest-js/padding-around-test-blocks': 'off',
|
|
503
506
|
|
|
504
507
|
// Prefer toHaveBeenCalledOnce() over toHaveBeenCalledTimes(1)
|
|
@@ -513,12 +516,12 @@ export const vitestRules = {
|
|
|
513
516
|
|
|
514
517
|
// Suggest using toBeCalledWith() or toHaveBeenCalledWith()
|
|
515
518
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md
|
|
516
|
-
// decision: handled by native
|
|
519
|
+
// decision: handled by native vitest/prefer-called-with
|
|
517
520
|
'vitest-js/prefer-called-with': 'off',
|
|
518
521
|
|
|
519
522
|
// Suggest using the built-in comparison matchers
|
|
520
523
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md
|
|
521
|
-
// decision: handled by native
|
|
524
|
+
// decision: handled by native vitest/prefer-comparison-matcher
|
|
522
525
|
'vitest-js/prefer-comparison-matcher': 'off',
|
|
523
526
|
|
|
524
527
|
// Enforce describe titles to match function names
|
|
@@ -528,12 +531,12 @@ export const vitestRules = {
|
|
|
528
531
|
|
|
529
532
|
// Prefer each rather than manual loops
|
|
530
533
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md
|
|
531
|
-
// decision: handled by native
|
|
534
|
+
// decision: handled by native vitest/prefer-each
|
|
532
535
|
'vitest-js/prefer-each': 'off',
|
|
533
536
|
|
|
534
537
|
// Suggest using the built-in equality matchers
|
|
535
538
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-equality-matcher.md
|
|
536
|
-
// decision: handled by native
|
|
539
|
+
// decision: handled by native vitest/prefer-equality-matcher
|
|
537
540
|
'vitest-js/prefer-equality-matcher': 'off',
|
|
538
541
|
|
|
539
542
|
// Suggest using expect.assertions
|
|
@@ -543,7 +546,7 @@ export const vitestRules = {
|
|
|
543
546
|
|
|
544
547
|
// Suggest using expect().resolves over expect(await ...) syntax
|
|
545
548
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md
|
|
546
|
-
// decision: handled by native
|
|
549
|
+
// decision: handled by native vitest/prefer-expect-resolves
|
|
547
550
|
'vitest-js/prefer-expect-resolves': 'off',
|
|
548
551
|
|
|
549
552
|
// Prefer expect.typeOf() usage
|
|
@@ -553,12 +556,12 @@ export const vitestRules = {
|
|
|
553
556
|
|
|
554
557
|
// Prefer having hooks in consistent order
|
|
555
558
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md
|
|
556
|
-
// decision: handled by native
|
|
559
|
+
// decision: handled by native vitest/prefer-hooks-in-order
|
|
557
560
|
'vitest-js/prefer-hooks-in-order': 'off',
|
|
558
561
|
|
|
559
562
|
// Suggest having hooks before any test cases
|
|
560
563
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md
|
|
561
|
-
// decision: handled by native
|
|
564
|
+
// decision: handled by native vitest/prefer-hooks-on-top
|
|
562
565
|
'vitest-js/prefer-hooks-on-top': 'off',
|
|
563
566
|
|
|
564
567
|
// Prefer vi.importActual/vi.importMock in vi.mock factories
|
|
@@ -573,12 +576,12 @@ export const vitestRules = {
|
|
|
573
576
|
|
|
574
577
|
// Prefer mock resolved/rejected shorthands for promises
|
|
575
578
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-promise-shorthand.md
|
|
576
|
-
// decision: handled by native
|
|
579
|
+
// decision: handled by native vitest/prefer-mock-promise-shorthand
|
|
577
580
|
'vitest-js/prefer-mock-promise-shorthand': 'off',
|
|
578
581
|
|
|
579
582
|
// Suggest using vi.spyOn
|
|
580
583
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md
|
|
581
|
-
// decision: handled by native
|
|
584
|
+
// decision: handled by native vitest/prefer-spy-on
|
|
582
585
|
'vitest-js/prefer-spy-on': 'off',
|
|
583
586
|
|
|
584
587
|
// Prefer strict boolean matchers (toBe(true) over toBeTruthy())
|
|
@@ -588,12 +591,12 @@ export const vitestRules = {
|
|
|
588
591
|
|
|
589
592
|
// Prefer strict equal over equal
|
|
590
593
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-equal.md
|
|
591
|
-
// decision: handled by native
|
|
594
|
+
// decision: handled by native vitest/prefer-strict-equal
|
|
592
595
|
'vitest-js/prefer-strict-equal': 'off',
|
|
593
596
|
|
|
594
597
|
// Suggest using toBe()
|
|
595
598
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be.md
|
|
596
|
-
// decision: handled by native
|
|
599
|
+
// decision: handled by native vitest/prefer-to-be
|
|
597
600
|
'vitest-js/prefer-to-be': 'off',
|
|
598
601
|
|
|
599
602
|
// Suggest using toBeFalsy()
|
|
@@ -613,7 +616,7 @@ export const vitestRules = {
|
|
|
613
616
|
|
|
614
617
|
// Prefer using toContain()
|
|
615
618
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-contain.md
|
|
616
|
-
// decision: handled by native
|
|
619
|
+
// decision: handled by native vitest/prefer-to-contain
|
|
617
620
|
'vitest-js/prefer-to-contain': 'off',
|
|
618
621
|
|
|
619
622
|
// Prefer toHaveBeenCalledTimes over multiple assertions
|
|
@@ -623,12 +626,12 @@ export const vitestRules = {
|
|
|
623
626
|
|
|
624
627
|
// Suggest using toHaveLength()
|
|
625
628
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-length.md
|
|
626
|
-
// decision: handled by native
|
|
629
|
+
// decision: handled by native vitest/prefer-to-have-length
|
|
627
630
|
'vitest-js/prefer-to-have-length': 'off',
|
|
628
631
|
|
|
629
632
|
// Suggest using test.todo
|
|
630
633
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-todo.md
|
|
631
|
-
// decision: handled by native
|
|
634
|
+
// decision: handled by native vitest/prefer-todo
|
|
632
635
|
'vitest-js/prefer-todo': 'off',
|
|
633
636
|
|
|
634
637
|
// Prefer vi.mocked() over type casting
|
|
@@ -642,7 +645,7 @@ export const vitestRules = {
|
|
|
642
645
|
|
|
643
646
|
// Require setup and teardown to be within a hook
|
|
644
647
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md
|
|
645
|
-
// decision: handled by native
|
|
648
|
+
// decision: handled by native vitest/require-hook
|
|
646
649
|
'vitest-js/require-hook': 'off',
|
|
647
650
|
|
|
648
651
|
// Require local Test Context for concurrent snapshot tests
|
|
@@ -662,12 +665,12 @@ export const vitestRules = {
|
|
|
662
665
|
|
|
663
666
|
// Require toThrow() to be called with an error message
|
|
664
667
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-to-throw-message.md
|
|
665
|
-
// decision: handled by native
|
|
668
|
+
// decision: handled by native vitest/require-to-throw-message
|
|
666
669
|
'vitest-js/require-to-throw-message': 'off',
|
|
667
670
|
|
|
668
671
|
// Enforce that all tests are in a top-level describe
|
|
669
672
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md
|
|
670
|
-
// decision: handled by native
|
|
673
|
+
// decision: handled by native vitest/require-top-level-describe
|
|
671
674
|
'vitest-js/require-top-level-describe': 'off',
|
|
672
675
|
|
|
673
676
|
// Enforce unbound methods are called with their expected scope
|
|
@@ -677,12 +680,12 @@ export const vitestRules = {
|
|
|
677
680
|
|
|
678
681
|
// Enforce valid describe callback
|
|
679
682
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-describe-callback.md
|
|
680
|
-
// decision: handled by native
|
|
683
|
+
// decision: handled by native vitest/valid-describe-callback
|
|
681
684
|
'vitest-js/valid-describe-callback': 'off',
|
|
682
685
|
|
|
683
686
|
// Enforce valid expect() usage
|
|
684
687
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-expect.md
|
|
685
|
-
// decision: handled by native
|
|
688
|
+
// decision: handled by native vitest/valid-expect
|
|
686
689
|
'vitest-js/valid-expect': 'off',
|
|
687
690
|
|
|
688
691
|
// Enforce valid expect in promise
|
|
@@ -692,7 +695,7 @@ export const vitestRules = {
|
|
|
692
695
|
|
|
693
696
|
// Enforce valid titles
|
|
694
697
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md
|
|
695
|
-
// decision: handled by native
|
|
698
|
+
// decision: handled by native vitest/valid-title
|
|
696
699
|
'vitest-js/valid-title': 'off',
|
|
697
700
|
},
|
|
698
701
|
};
|