Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3426060

Browse files
authoredDec 27, 2024··
Merge branch 'main' into chore/ci
2 parents 79ae711 + b73cd8e commit 3426060

File tree

4 files changed

+59
-60
lines changed

4 files changed

+59
-60
lines changed
 

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@typescript-eslint/parser": "8.18.2",
5151
"@typescript-eslint/rule-tester": "8.18.1",
5252
"@vitest/eslint-plugin": "^1.1.20",
53-
"bumpp": "^9.9.1",
53+
"bumpp": "^9.9.2",
5454
"concurrently": "^8.2.2",
5555
"eslint": "^9.17.0",
5656
"eslint-doc-generator": "^2.0.2",

‎pnpm-lock.yaml

Lines changed: 2 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/index.ts

Lines changed: 55 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Linter } from 'eslint'
1+
import type { Linter, RuleModule } from '@typescript-eslint/utils/ts-eslint'
22
import { version } from '../package.json'
33
import lowerCaseTitle, { RULE_NAME as lowerCaseTitleName } from './rules/prefer-lowercase-title'
44
import maxNestedDescribe, { RULE_NAME as maxNestedDescribeName } from './rules/max-nested-describe'
@@ -70,8 +70,8 @@ const createConfig = <R extends Linter.RulesRecord>(rules: R) => (
7070
[`vitest/${ruleName}`]: rules[ruleName]
7171
}
7272
}, {})) as {
73-
[K in keyof R as `vitest/${Extract<K, string>}`]: R[K]
74-
}
73+
[K in keyof R as `vitest/${Extract<K, string>}`]: R[K]
74+
}
7575

7676
const createConfigLegacy = (rules: Record<string, string>) => ({
7777
plugins: ['@vitest'],
@@ -159,7 +159,18 @@ const recommended = {
159159
[noImportNodeTestName]: 'error'
160160
} as const
161161

162-
const plugin = {
162+
interface VitestPLugin extends Linter.Plugin {
163+
meta: {
164+
name: string
165+
version: string
166+
}
167+
rules: Record<string, RuleModule<any, any>>
168+
//TODO: use classic type for config
169+
configs?: Record<string, any>
170+
environments?: Record<string, any>
171+
}
172+
173+
const plugin: VitestPLugin = {
163174
meta: {
164175
name: 'vitest',
165176
version
@@ -228,48 +239,6 @@ const plugin = {
228239
[paddingAroundTestBlocksName]: paddingAroundTestBlocks,
229240
[validExpectInPromiseName]: validExpectInPromise
230241
},
231-
configs: {
232-
'legacy-recommended': createConfigLegacy(recommended),
233-
'legacy-all': createConfigLegacy(allRules),
234-
'recommended': {
235-
plugins: {
236-
get vitest() {
237-
return plugin
238-
}
239-
},
240-
rules: createConfig(recommended)
241-
},
242-
'all': {
243-
plugins: {
244-
get vitest() {
245-
return plugin
246-
}
247-
},
248-
rules: createConfig(allRules)
249-
},
250-
'env': {
251-
languageOptions: {
252-
globals: {
253-
suite: 'writable',
254-
test: 'writable',
255-
describe: 'writable',
256-
it: 'writable',
257-
expectTypeOf: 'writable',
258-
assertType: 'writable',
259-
expect: 'writable',
260-
assert: 'writable',
261-
vitest: 'writable',
262-
vi: 'writable',
263-
beforeAll: 'writable',
264-
afterAll: 'writable',
265-
beforeEach: 'writable',
266-
afterEach: 'writable',
267-
onTestFailed: 'writable',
268-
onTestFinished: 'writable'
269-
}
270-
}
271-
}
272-
},
273242
environments: {
274243
env: {
275244
globals: {
@@ -294,4 +263,44 @@ const plugin = {
294263
}
295264
}
296265

266+
plugin.configs = {
267+
'legacy-recommended': createConfigLegacy(recommended),
268+
'legacy-all': createConfigLegacy(allRules),
269+
'recommended': {
270+
plugins: {
271+
["vitest"]: plugin
272+
},
273+
rules: createConfig(recommended)
274+
},
275+
'all': {
276+
plugins: {
277+
["vitest"]: plugin
278+
},
279+
rules: createConfig(allRules)
280+
},
281+
'env': {
282+
languageOptions: {
283+
globals: {
284+
suite: 'writable',
285+
test: 'writable',
286+
describe: 'writable',
287+
it: 'writable',
288+
expectTypeOf: 'writable',
289+
assertType: 'writable',
290+
expect: 'writable',
291+
assert: 'writable',
292+
vitest: 'writable',
293+
vi: 'writable',
294+
beforeAll: 'writable',
295+
afterAll: 'writable',
296+
beforeEach: 'writable',
297+
afterEach: 'writable',
298+
onTestFailed: 'writable',
299+
onTestFinished: 'writable'
300+
}
301+
}
302+
}
303+
}
304+
305+
297306
export default plugin

‎src/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,4 @@ export const isParsedInstanceOfMatcherCall = (
211211
&& expectFnCall.args.length === 1
212212
&& isSupportedAccessor(expectFnCall.args[0], classArg)
213213
)
214-
}
214+
}

0 commit comments

Comments
 (0)
Please sign in to comment.