@wistia/oxlint-config 0.0.1 → 0.3.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.
@@ -0,0 +1,324 @@
1
+ import type { RuleFile } from '../types.ts';
2
+
3
+ // NOTE: oxlint splits vitest-related rules across two plugin namespaces:
4
+ // - "vitest/" for rules that are vitest-specific (no Jest equivalent)
5
+ // - "jest/" for rules that originated in eslint-plugin-jest and are shared with vitest
6
+ // Both namespaces are used here for VITEST projects only. Despite the "jest/" prefix,
7
+ // these rules apply to vitest code. This is an oxlint naming convention, not a dependency on Jest.
8
+ export const vitestRules = {
9
+ plugins: ['vitest', 'jest'],
10
+ jsPlugins: [
11
+ { name: 'vitest-js', specifier: '@vitest/eslint-plugin' },
12
+ 'eslint-plugin-no-only-tests',
13
+ ],
14
+ rules: {
15
+ // -- vitest-specific rules (no Jest equivalent) --
16
+
17
+ // Require .test test file pattern
18
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md
19
+ 'vitest/consistent-test-filename': 'error',
20
+
21
+ // Enforce consistent usage of each with for...of
22
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-each-for.md
23
+ 'vitest/consistent-each-for': 'error',
24
+
25
+ // Enforce consistent usage of vi vs vitest
26
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-vitest-vi.md
27
+ 'vitest/consistent-vitest-vi': 'error',
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
+
33
+ // Disallow conditional tests
34
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-tests.md
35
+ 'vitest/no-conditional-tests': 'error',
36
+
37
+ // Disallow importing node:test
38
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-import-node-test.md
39
+ 'vitest/no-import-node-test': 'error',
40
+
41
+ // Prefer toHaveBeenCalledOnce() over toHaveBeenCalledTimes(1)
42
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-once.md
43
+ // decision: conflicts with prefer-called-times (jest plugin), which is enabled
44
+ 'vitest/prefer-called-once': 'off',
45
+
46
+ // Prefer toHaveBeenCalledTimes over multiple assertions
47
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-times.md
48
+ 'vitest/prefer-called-times': 'error',
49
+
50
+ // Enforce describe titles to match function names
51
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-describe-function-title.md
52
+ 'vitest/prefer-describe-function-title': 'error',
53
+
54
+ // Prefer expect.typeOf() usage
55
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-type-of.md
56
+ 'vitest/prefer-expect-type-of': 'error',
57
+
58
+ // Prefer vi.importActual/vi.importMock in vi.mock factories
59
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-import-in-mock.md
60
+ // decision: potentially helpful but causes too many type errors
61
+ 'vitest/prefer-import-in-mock': 'off',
62
+
63
+ // Prefer strict boolean matchers (toBe(true) over toBeTruthy())
64
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-boolean-matchers.md
65
+ 'vitest/prefer-strict-boolean-matchers': 'error',
66
+
67
+ // Suggest using toBeFalsy()
68
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-falsy.md
69
+ // decision: not necessary to be prescriptive here
70
+ 'vitest/prefer-to-be-falsy': 'off',
71
+
72
+ // Prefer toBeObject()
73
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-object.md
74
+ 'vitest/prefer-to-be-object': 'error',
75
+
76
+ // Suggest using toBeTruthy
77
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be-truthy.md
78
+ // decision: not necessary to be prescriptive here
79
+ 'vitest/prefer-to-be-truthy': 'off',
80
+
81
+ // Require local Test Context for concurrent snapshot tests
82
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-local-test-context-for-concurrent-snapshots.md
83
+ 'vitest/require-local-test-context-for-concurrent-snapshots': 'error',
84
+
85
+ // -- Shared vitest/jest rules (oxlint uses the "jest/" prefix for these) --
86
+
87
+ // Prefer test or it but not both
88
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md
89
+ 'jest/consistent-test-it': 'error',
90
+
91
+ // Enforce having expectation in test body
92
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/expect-expect.md
93
+ 'jest/expect-expect': 'error',
94
+
95
+ // Enforce a maximum number of expect per test
96
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md
97
+ 'jest/max-expects': [
98
+ 'error',
99
+ {
100
+ max: 15,
101
+ },
102
+ ],
103
+
104
+ // Nested describe block should be less than set max value or default value
105
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md
106
+ 'jest/max-nested-describe': 'error',
107
+
108
+ // Disallow alias methods
109
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-alias-methods.md
110
+ 'jest/no-alias-methods': 'error',
111
+
112
+ // Disallow commented out tests
113
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-commented-out-tests.md
114
+ 'jest/no-commented-out-tests': 'error',
115
+
116
+ // Disallow conditional expects
117
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md
118
+ 'jest/no-conditional-expect': 'error',
119
+
120
+ // Disallow conditional tests
121
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md
122
+ // decision: disabled in oxlint — the native jest/ prefix doesn't match existing
123
+ // `eslint-disable vitest/no-conditional-in-test` comments, and the jsPlugin vitest-js/
124
+ // alias has the same problem. Eslint still enforces this rule.
125
+ 'jest/no-conditional-in-test': 'off',
126
+
127
+ // Disallow disabled tests
128
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md
129
+ // decision: it is often useful to be allowed to add a .skip
130
+ 'jest/no-disabled-tests': 'off',
131
+
132
+ // Disallow duplicate hooks and teardown hooks
133
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-duplicate-hooks.md
134
+ 'jest/no-duplicate-hooks': 'error',
135
+
136
+ // Disallow focused tests
137
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-focused-tests.md
138
+ 'jest/no-focused-tests': 'error',
139
+
140
+ // Disallow setup and teardown hooks
141
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md
142
+ 'jest/no-hooks': 'off',
143
+
144
+ // Disallow identical titles
145
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-identical-title.md
146
+ 'jest/no-identical-title': 'error',
147
+
148
+ // Disallow string interpolation in snapshots
149
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md
150
+ 'jest/no-interpolation-in-snapshots': 'error',
151
+
152
+ // Disallow large snapshots
153
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-large-snapshots.md
154
+ 'jest/no-large-snapshots': [
155
+ 'error',
156
+ {
157
+ maxSize: 500,
158
+ },
159
+ ],
160
+
161
+ // Disallow importing from mocks directory
162
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-mocks-import.md
163
+ 'jest/no-mocks-import': 'error',
164
+
165
+ // Disallow the use of certain matchers
166
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md
167
+ 'jest/no-restricted-matchers': 'error',
168
+
169
+ // Disallow using expect outside of it or test blocks
170
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md
171
+ 'jest/no-standalone-expect': 'error',
172
+
173
+ // Disallow using test as a prefix
174
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-test-prefixes.md
175
+ 'jest/no-test-prefixes': 'error',
176
+
177
+ // Disallow return statements in tests
178
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-test-return-statement.md
179
+ 'jest/no-test-return-statement': 'error',
180
+
181
+ // Disallow unnecessary async in expect functions
182
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-unneeded-async-expect-function.md
183
+ 'jest/no-unneeded-async-expect-function': 'error',
184
+
185
+ // Enforce padding around test blocks
186
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-test-blocks.md
187
+ 'jest/padding-around-test-blocks': 'error',
188
+
189
+ // Suggest using toBeCalledWith() or toHaveBeenCalledWith()
190
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-with.md
191
+ 'jest/prefer-called-with': 'error',
192
+
193
+ // Suggest using the built-in comparison matchers
194
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-comparison-matcher.md
195
+ 'jest/prefer-comparison-matcher': 'error',
196
+
197
+ // Prefer each rather than manual loops
198
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-each.md
199
+ 'jest/prefer-each': 'error',
200
+
201
+ // Suggest using the built-in equality matchers
202
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-equality-matcher.md
203
+ 'jest/prefer-equality-matcher': 'error',
204
+
205
+ // Suggest using expect().resolves over expect(await ...) syntax
206
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-expect-resolves.md
207
+ 'jest/prefer-expect-resolves': 'error',
208
+
209
+ // Prefer having hooks in consistent order
210
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-in-order.md
211
+ 'jest/prefer-hooks-in-order': 'error',
212
+
213
+ // Suggest having hooks before any test cases
214
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-hooks-on-top.md
215
+ 'jest/prefer-hooks-on-top': 'error',
216
+
217
+ // Enforce lowercase titles
218
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-lowercase-title.md
219
+ 'vitest/prefer-lowercase-title': 'off',
220
+
221
+ // Prefer mock resolved/rejected shorthands for promises
222
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-promise-shorthand.md
223
+ 'jest/prefer-mock-promise-shorthand': 'error',
224
+
225
+ // Prefer mock return shorthands
226
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-mock-return-shorthand.md
227
+ 'jest/prefer-mock-return-shorthand': 'error',
228
+
229
+ // Suggest using vi.spyOn
230
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-spy-on.md
231
+ 'jest/prefer-spy-on': 'error',
232
+
233
+ // Prefer strict equal over equal
234
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-strict-equal.md
235
+ 'jest/prefer-strict-equal': 'error',
236
+
237
+ // Suggest using toBe()
238
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-be.md
239
+ 'jest/prefer-to-be': 'error',
240
+
241
+ // Prefer using toContain()
242
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-contain.md
243
+ 'jest/prefer-to-contain': 'error',
244
+
245
+ // Suggest using toHaveLength()
246
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-to-have-length.md
247
+ 'jest/prefer-to-have-length': 'error',
248
+
249
+ // Suggest using test.todo
250
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-todo.md
251
+ 'jest/prefer-todo': 'error',
252
+
253
+ // Require setup and teardown to be within a hook
254
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-hook.md
255
+ 'jest/require-hook': 'error',
256
+
257
+ // Require toThrow() to be called with an error message
258
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-to-throw-message.md
259
+ 'jest/require-to-throw-message': 'error',
260
+
261
+ // Enforce that all tests are in a top-level describe
262
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-top-level-describe.md
263
+ 'jest/require-top-level-describe': 'error',
264
+
265
+ // Enforce valid describe callback
266
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-describe-callback.md
267
+ 'jest/valid-describe-callback': 'error',
268
+
269
+ // Enforce valid expect() usage
270
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-expect.md
271
+ 'jest/valid-expect': 'error',
272
+
273
+ // Enforce valid titles
274
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/valid-title.md
275
+ // decision: `allowArguments` avoids conflict with `prefer-describe-function-title` rule, which is enabled
276
+ 'jest/valid-title': ['error', { allowArguments: true }],
277
+
278
+ // -- Rules via jsPlugins (@vitest/eslint-plugin + no-only-tests) --
279
+
280
+ // Disallow .only tests
281
+ // https://github.com/levibuzolic/eslint-plugin-no-only-tests
282
+ 'eslint-plugin-no-only-tests/no-only-tests': 'error',
283
+
284
+ // Disallow the use of certain vi methods
285
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-vi-methods.md
286
+ 'vitest-js/no-restricted-vi-methods': 'error',
287
+
288
+ // Prefer toHaveBeenCalledExactlyOnceWith over manual assertions
289
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-exactly-once-with.md
290
+ 'vitest-js/prefer-called-exactly-once-with': 'error',
291
+
292
+ // Prefer importing vitest globals
293
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-importing-vitest-globals.md
294
+ 'vitest-js/prefer-importing-vitest-globals': 'error',
295
+
296
+ // Prefer snapshot hint for inline/external snapshots
297
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-snapshot-hint.md
298
+ 'vitest-js/prefer-snapshot-hint': 'error',
299
+
300
+ // Enforce padding around afterAll blocks
301
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-after-all-blocks.md
302
+ 'vitest-js/padding-around-after-all-blocks': 'error',
303
+
304
+ // Enforce padding around afterEach blocks
305
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-after-each-blocks.md
306
+ 'vitest-js/padding-around-after-each-blocks': 'error',
307
+
308
+ // Enforce padding around beforeAll blocks
309
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-before-all-blocks.md
310
+ 'vitest-js/padding-around-before-all-blocks': 'error',
311
+
312
+ // Enforce padding around beforeEach blocks
313
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-before-each-blocks.md
314
+ 'vitest-js/padding-around-before-each-blocks': 'error',
315
+
316
+ // Enforce padding around expect groups
317
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-expect-groups.md
318
+ 'vitest-js/padding-around-expect-groups': 'error',
319
+
320
+ // Enforce padding around describe blocks
321
+ // https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/padding-around-describe-blocks.md
322
+ 'vitest-js/padding-around-describe-blocks': 'error',
323
+ },
324
+ } satisfies RuleFile;
package/types.ts ADDED
@@ -0,0 +1,24 @@
1
+ import type { DummyRule, ExternalPluginEntry } from 'oxlint';
2
+
3
+ type LintPlugin =
4
+ | 'eslint'
5
+ | 'import'
6
+ | 'jest'
7
+ | 'jsdoc'
8
+ | 'jsx-a11y'
9
+ | 'nextjs'
10
+ | 'node'
11
+ | 'oxc'
12
+ | 'promise'
13
+ | 'react'
14
+ | 'react-perf'
15
+ | 'typescript'
16
+ | 'unicorn'
17
+ | 'vitest'
18
+ | 'vue';
19
+
20
+ export type RuleFile = {
21
+ plugins?: LintPlugin[];
22
+ jsPlugins?: ExternalPluginEntry[];
23
+ rules: Record<string, DummyRule>;
24
+ };
package/.tool-versions DELETED
@@ -1 +0,0 @@
1
- nodejs 24.14.1