Skip to content

Commit 4b0451d

Browse files
chore(deps): update dependency @antfu/eslint-config to v4 (#7407)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Vladimir Sheremet <[email protected]>
1 parent 2d4537f commit 4b0451d

File tree

42 files changed

+513
-472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+513
-472
lines changed

docs/guide/migration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ JSON reporter now prints `task.meta` for every assertion result.
265265
Previously `vi.fn<TArgs, TReturn>` accepted two generic types separately for arguments and return value. This is changed to directly accept a function type `vi.fn<T>` to simplify the usage.
266266

267267
```ts
268-
import { type Mock, vi } from 'vitest'
268+
import { vi } from 'vitest'
269+
import type { Mock } from 'vitest'
269270

270271
const add = (x: number, y: number): number => x + y
271272

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"test:browser:playwright": "pnpm -C test/browser run test:playwright"
3737
},
3838
"devDependencies": {
39-
"@antfu/eslint-config": "^3.16.0",
39+
"@antfu/eslint-config": "^4.8.1",
4040
"@antfu/ni": "^23.3.1",
4141
"@playwright/test": "^1.50.1",
4242
"@rollup/plugin-commonjs": "^28.0.2",

packages/browser/src/client/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { CancelReason } from '@vitest/runner'
2+
import type { BirpcReturn } from 'birpc'
23
import type { WebSocketBrowserEvents, WebSocketBrowserHandlers } from '../node/types'
3-
import { type BirpcReturn, createBirpc } from 'birpc'
4+
import { createBirpc } from 'birpc'
45
import { parse, stringify } from 'flatted'
56
import { getBrowserState } from './utils'
67

packages/browser/src/client/orchestrator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { GlobalChannelIncomingEvent, IframeChannelEvent, IframeChannelIncomingEvent } from '@vitest/browser/client'
12
import type { SerializedConfig } from 'vitest'
2-
import { channel, client } from '@vitest/browser/client'
3-
import { globalChannel, type GlobalChannelIncomingEvent, type IframeChannelEvent, type IframeChannelIncomingEvent } from '@vitest/browser/client'
3+
import { channel, client, globalChannel } from '@vitest/browser/client'
44
import { generateHash } from '@vitest/runner/utils'
55
import { relative } from 'pathe'
66
import { getUiAPI } from './ui'

packages/browser/src/client/tester/locators/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type {
1010
UserEventSelectOptions,
1111
UserEventUploadOptions,
1212
} from '@vitest/browser/context'
13+
import type { ParsedSelector } from 'ivya'
1314
import { page, server } from '@vitest/browser/context'
1415
import {
1516
getByAltTextSelector,
@@ -20,7 +21,7 @@ import {
2021
getByTextSelector,
2122
getByTitleSelector,
2223
Ivya,
23-
type ParsedSelector,
24+
2425
} from 'ivya'
2526
import { ensureAwaited, getBrowserState } from '../../utils'
2627
import { getElementError } from '../public-utils'

packages/browser/src/client/tester/public-utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { type Locator, type LocatorSelectors, page } from '@vitest/browser/context'
1+
import type { Locator, LocatorSelectors } from '@vitest/browser/context'
2+
import type { StringifyOptions } from 'vitest/utils'
3+
import { page } from '@vitest/browser/context'
24
import { asLocator } from 'ivya'
3-
import { stringify, type StringifyOptions } from 'vitest/utils'
5+
import { stringify } from 'vitest/utils'
46

57
export function getElementLocatorSelectors(element: Element): LocatorSelectors {
68
const locator = page.elementLocator(element)

packages/browser/src/client/tester/snapshot.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { VitestBrowserClient } from '@vitest/browser/client'
22
import type { SnapshotEnvironment } from 'vitest/snapshot'
3-
import { originalPositionFor, type ParsedStack, TraceMap } from 'vitest/utils'
3+
import type { ParsedStack } from 'vitest/utils'
4+
import { originalPositionFor, TraceMap } from 'vitest/utils'
45

56
export class VitestBrowserSnapshotEnvironment implements SnapshotEnvironment {
67
private sourceMaps = new Map<string, any>()

packages/browser/src/node/plugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Stats } from 'node:fs'
22
import type { HtmlTagDescriptor } from 'vite'
3+
import type { Plugin } from 'vitest/config'
34
import type { Vitest } from 'vitest/node'
45
import type { ParentBrowserProject } from './projectParent'
56
import { lstatSync, readFileSync } from 'node:fs'
@@ -9,7 +10,7 @@ import { toArray } from '@vitest/utils'
910
import MagicString from 'magic-string'
1011
import { basename, dirname, extname, resolve } from 'pathe'
1112
import sirv from 'sirv'
12-
import { coverageConfigDefaults, type Plugin } from 'vitest/config'
13+
import { coverageConfigDefaults } from 'vitest/config'
1314
import { getFilePoolName, resolveApiServerConfig, resolveFsAllow, distDir as vitestDist } from 'vitest/node'
1415
import { distRoot } from './constants'
1516
import { createOrchestratorMiddleware } from './middlewares/orchestratorMiddleware'

packages/browser/src/node/projectParent.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { StackTraceParserOptions } from '@vitest/utils/source-map'
12
import type { HtmlTagDescriptor } from 'vite'
23
import type { ErrorWithDiff, ParsedStack } from 'vitest'
34
import type {
@@ -12,7 +13,7 @@ import type {
1213
import type { BrowserServerState } from './state'
1314
import { readFileSync } from 'node:fs'
1415
import { readFile } from 'node:fs/promises'
15-
import { parseErrorStacktrace, parseStacktrace, type StackTraceParserOptions } from '@vitest/utils/source-map'
16+
import { parseErrorStacktrace, parseStacktrace } from '@vitest/utils/source-map'
1617
import { dirname, join, resolve } from 'pathe'
1718
import { BrowserServerCDPHandler } from './cdp'
1819
import builtinCommands from './commands/index'

packages/coverage-istanbul/src/provider.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
import type { CoverageMap } from 'istanbul-lib-coverage'
2+
import type { Instrumenter } from 'istanbul-lib-instrument'
13
import type { ProxifiedModule } from 'magicast'
24
import type { CoverageProvider, ReportContext, ResolvedCoverageOptions, Vitest } from 'vitest/node'
35
import { promises as fs } from 'node:fs'
46
// @ts-expect-error missing types
57
import { defaults as istanbulDefaults } from '@istanbuljs/schema'
68
import createDebug from 'debug'
7-
import libCoverage, { type CoverageMap } from 'istanbul-lib-coverage'
8-
import { createInstrumenter, type Instrumenter } from 'istanbul-lib-instrument'
9+
import libCoverage from 'istanbul-lib-coverage'
10+
import { createInstrumenter } from 'istanbul-lib-instrument'
911
import libReport from 'istanbul-lib-report'
1012
import libSourceMaps from 'istanbul-lib-source-maps'
1113
import reports from 'istanbul-reports'

packages/coverage-v8/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import type { Profiler } from 'node:inspector'
12
import type { CoverageProviderModule } from 'vitest/node'
23
import type { ScriptCoverageWithOffset, V8CoverageProvider } from './provider'
3-
import inspector, { type Profiler } from 'node:inspector'
4+
import inspector from 'node:inspector'
45
import { fileURLToPath } from 'node:url'
56
import { provider } from 'std-env'
67
import { loadProvider } from './load-provider'

packages/expect/src/jest-asymmetric-matchers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable unicorn/no-instanceof-builtins -- we check both */
2+
13
import type { ChaiPlugin, MatcherState } from './types'
24
import { GLOBAL_EXPECT } from './constants'
35
import {
@@ -242,7 +244,7 @@ export class Any extends AsymmetricMatcher<any> {
242244
}
243245

244246
if (this.sample === Function) {
245-
return typeof other == 'function' || other instanceof Function
247+
return typeof other == 'function' || typeof other === 'function'
246248
}
247249

248250
if (this.sample === Boolean) {

packages/mocker/src/node/automockPlugin.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import type { Plugin } from 'vite'
2+
import type { Declaration, ExportDefaultDeclaration, ExportNamedDeclaration, Expression, Pattern, Positioned, Program } from './esmWalker'
23
import MagicString from 'magic-string'
34
import { cleanUrl } from '../utils'
45
import {
5-
type Declaration,
6-
type ExportDefaultDeclaration,
7-
type ExportNamedDeclaration,
8-
type Expression,
6+
97
getArbitraryModuleIdentifier,
10-
type Pattern,
11-
type Positioned,
12-
type Program,
8+
139
} from './esmWalker'
1410

1511
export interface AutomockPluginOptions {

packages/mocker/src/node/mockerPlugin.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import type { Plugin, ViteDevServer } from 'vite'
2+
import type { AutomockPluginOptions } from './automockPlugin'
3+
import type { HoistMocksPluginOptions } from './hoistMocksPlugin'
4+
25
import { readFile } from 'node:fs/promises'
36
import { fileURLToPath } from 'node:url'
4-
57
import { resolve } from 'pathe'
6-
import { automockPlugin, type AutomockPluginOptions } from './automockPlugin'
8+
import { automockPlugin } from './automockPlugin'
79
import { dynamicImportPlugin } from './dynamicImportPlugin'
8-
import { hoistMocksPlugin, type HoistMocksPluginOptions } from './hoistMocksPlugin'
10+
import { hoistMocksPlugin } from './hoistMocksPlugin'
911
import { interceptorPlugin } from './interceptorPlugin'
1012
import { ServerMockResolver } from './resolver'
1113

packages/runner/src/suite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ function createTest(
785785
function formatName(name: string | Function) {
786786
return typeof name === 'string'
787787
? name
788-
: name instanceof Function
788+
: typeof name === 'function'
789789
? name.name || '<anonymous>'
790790
: String(name)
791791
}

packages/runner/src/utils/tasks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import type { Arrayable } from '@vitest/utils'
12
import type { Suite, Task, Test } from '../types/tasks'
2-
import { type Arrayable, toArray } from '@vitest/utils'
3+
import { toArray } from '@vitest/utils'
34

45
/**
56
* @deprecated use `isTestCase` instead

packages/ui/client/composables/explorer/collapse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ function collapseAllNodes(nodes: UITaskTreeNode[]) {
6969
}
7070
}
7171

72-
function * collectChildNodes(node: UITaskTreeNode, itself: boolean): Generator<string> {
72+
function* collectChildNodes(node: UITaskTreeNode, itself: boolean): Generator<string> {
7373
if (itself) {
7474
yield node.id
7575
}
7676

7777
if (isParentNode(node)) {
7878
for (let i = 0; i < node.tasks.length; i++) {
79-
yield * collectChildNodes(node.tasks[i], true)
79+
yield* collectChildNodes(node.tasks[i], true)
8080
}
8181
}
8282
}

packages/ui/client/composables/explorer/collector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export function runCollect(
106106
}
107107

108108
function* collectRunningTodoTests() {
109-
yield * uiEntries.value.filter(isRunningTestNode)
109+
yield* uiEntries.value.filter(isRunningTestNode)
110110
}
111111

112112
function updateRunningTodoTests() {
@@ -473,7 +473,7 @@ function* testsCollector(suite: Arrayable<Task>): Generator<Test> {
473473
yield s
474474
}
475475
else {
476-
yield * testsCollector(s.tasks)
476+
yield* testsCollector(s.tasks)
477477
}
478478
}
479479
}

packages/ui/client/composables/explorer/expand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function* collectExpandedNode(
143143
if (!ids.has(child.id)) {
144144
yield node
145145
}
146-
yield * children
146+
yield* children
147147
}
148148
else if (!ids.has(child.id)) {
149149
yield child

packages/ui/client/composables/explorer/filter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function* filterAll(
3737
filter: Filter,
3838
) {
3939
for (const node of sortedRootTasks()) {
40-
yield * filterNode(node, search, filter)
40+
yield* filterNode(node, search, filter)
4141
}
4242
}
4343

@@ -113,7 +113,7 @@ export function* filterNode(
113113
)
114114

115115
// collect files, and suites and tests whose parent is expanded
116-
yield * entries.filter((node) => {
116+
yield* entries.filter((node) => {
117117
// all file nodes or children of expanded parents
118118
return isFileNode(node) || (parents.has(node.parentId) && map.get(node.parentId)?.expanded)
119119
})
@@ -277,7 +277,7 @@ function* visitNode(
277277
yield [match, node]
278278
if (isParentNode(node)) {
279279
for (let i = 0; i < node.tasks.length; i++) {
280-
yield * visitNode(node.tasks[i], treeNodes, matcher)
280+
yield* visitNode(node.tasks[i], treeNodes, matcher)
281281
}
282282
}
283283
}

packages/ui/client/test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import type { RenderOptions } from '@testing-library/vue'
12
import {
23
render as _render,
34
cleanup,
4-
type RenderOptions,
5+
56
} from '@testing-library/vue'
67
import { vTooltip } from 'floating-vue'
78
import { afterEach } from 'vitest'

packages/utils/src/diff/cleanupSemantic.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Diff {
6565
* @return {number} The number of characters common to the start of each
6666
* string.
6767
*/
68-
const diff_commonPrefix = function (text1: string, text2: string): number {
68+
function diff_commonPrefix(text1: string, text2: string): number {
6969
// Quick check for common null cases.
7070
if (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) {
7171
return 0
@@ -99,7 +99,7 @@ const diff_commonPrefix = function (text1: string, text2: string): number {
9999
* @param {string} text2 Second string.
100100
* @return {number} The number of characters common to the end of each string.
101101
*/
102-
const diff_commonSuffix = function (text1: string, text2: string): number {
102+
function diff_commonSuffix(text1: string, text2: string): number {
103103
// Quick check for common null cases.
104104
if (
105105
!text1
@@ -139,7 +139,7 @@ const diff_commonSuffix = function (text1: string, text2: string): number {
139139
* string and the start of the second string.
140140
* @private
141141
*/
142-
const diff_commonOverlap_ = function (text1: string, text2: string): number {
142+
function diff_commonOverlap_(text1: string, text2: string): number {
143143
// Cache the text lengths to prevent multiple calls.
144144
const text1_length = text1.length
145145
const text2_length = text2.length
@@ -189,7 +189,7 @@ const diff_commonOverlap_ = function (text1: string, text2: string): number {
189189
* Reduce the number of edits by eliminating semantically trivial equalities.
190190
* @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
191191
*/
192-
const diff_cleanupSemantic = function (diffs: Array<Diff>): void {
192+
function diff_cleanupSemantic(diffs: Array<Diff>): void {
193193
let changes = false
194194
const equalities = [] // Stack of indices where equalities are found.
195195
let equalitiesLength = 0 // Keeping our own length var is faster in JS.

packages/utils/src/error.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import type { DiffOptions } from './diff'
12
import type { TestError } from './types'
2-
import { type DiffOptions, printDiffOrStringify } from './diff'
3+
import { printDiffOrStringify } from './diff'
34
import { format, stringify } from './display'
45

56
// utils is bundled for any environment and might not support `Element`

packages/utils/src/highlight.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { highlight as baseHighlight, type TokenColors } from 'tinyhighlight'
2-
import c, { type Colors } from 'tinyrainbow'
1+
import type { TokenColors } from 'tinyhighlight'
2+
import type { Colors } from 'tinyrainbow'
3+
import { highlight as baseHighlight } from 'tinyhighlight'
4+
import c from 'tinyrainbow'
35

46
function getDefs(c: Colors): TokenColors {
57
const Invalid = (text: string) => c.white(c.bgRed(c.bold(text)))

packages/vite-node/src/source-map-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ interface Options {
467467
retrieveSourceMap?: RetrieveMapHandler
468468
}
469469

470-
export const install = function (options: Options): void {
470+
export function install(options: Options): void {
471471
options = options || {}
472472

473473
// Allow sources to be found by methods other than reading the files
@@ -498,7 +498,7 @@ export const install = function (options: Options): void {
498498
}
499499
}
500500

501-
export const resetRetrieveHandlers = function (): void {
501+
export function resetRetrieveHandlers(): void {
502502
retrieveFileHandlers.length = 0
503503
retrieveMapHandlers.length = 0
504504

packages/vitest/src/node/cli/cac.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import type { CAC, Command } from 'cac'
12
import type { VitestRunMode } from '../types/config'
23
import type { CliOptions } from './cli-api'
34
import type { CLIOption, CLIOptions as CLIOptionsConfig } from './cli-config'
45
import { toArray } from '@vitest/utils'
5-
import cac, { type CAC, type Command } from 'cac'
6+
import cac from 'cac'
67
import { normalize } from 'pathe'
78
import c from 'tinyrainbow'
89
import { version } from '../../../package.json' with { type: 'json' }

packages/vitest/src/node/project.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { GlobOptions } from 'tinyglobby'
12
import type {
23
ModuleNode,
34
TransformResult,
@@ -9,6 +10,7 @@ import type { ProvidedContext } from '../types/general'
910
import type { OnTestsRerunHandler, Vitest } from './core'
1011
import type { GlobalSetupFile } from './globalSetup'
1112
import type { Logger } from './logger'
13+
import type { WorkspaceSpec as DeprecatedWorkspaceSpec } from './pool'
1214
import type { Reporter } from './reporters'
1315
import type { ParentProjectBrowser, ProjectBrowser } from './types/browser'
1416
import type {
@@ -24,7 +26,7 @@ import path from 'node:path'
2426
import { deepMerge, nanoid, slash } from '@vitest/utils'
2527
import mm from 'micromatch'
2628
import { isAbsolute, join, relative } from 'pathe'
27-
import { glob, type GlobOptions } from 'tinyglobby'
29+
import { glob } from 'tinyglobby'
2830
import { ViteNodeRunner } from 'vite-node/client'
2931
import { ViteNodeServer } from 'vite-node/server'
3032
import { setup } from '../api/setup'
@@ -34,7 +36,7 @@ import { loadGlobalSetupFiles } from './globalSetup'
3436
import { CoverageTransform } from './plugins/coverageTransform'
3537
import { MocksPlugins } from './plugins/mocks'
3638
import { WorkspaceVitestPlugin } from './plugins/workspace'
37-
import { type WorkspaceSpec as DeprecatedWorkspaceSpec, getFilePoolName } from './pool'
39+
import { getFilePoolName } from './pool'
3840
import { TestSpecification } from './spec'
3941
import { createViteServer } from './vite'
4042

0 commit comments

Comments
 (0)