Skip to content

Commit

Permalink
chore(deps): update dependency @antfu/eslint-config to v2 (#5153)
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] authored Feb 8, 2024
1 parent a931646 commit 7a31a1a
Show file tree
Hide file tree
Showing 56 changed files with 609 additions and 478 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Next generation testing framework powered by Vite.
<a href="https://cn.vitest.dev">中文文档</a>
</p>


<h4 align="center">

</h4>
Expand All @@ -49,7 +48,6 @@ Next generation testing framework powered by Vite.

> Vitest 1.0 requires Vite >=v5.0.0 and Node >=v18.0.0

```ts
import { assert, describe, expect, it } from 'vitest'

Expand Down
32 changes: 16 additions & 16 deletions docs/advanced/runner.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,69 +11,69 @@ export interface VitestRunner {
/**
* First thing that's getting called before actually collecting and running tests.
*/
onBeforeCollect?(paths: string[]): unknown
onBeforeCollect?: (paths: string[]) => unknown
/**
* Called after collecting tests and before "onBeforeRun".
*/
onCollected?(files: File[]): unknown
onCollected?: (files: File[]) => unknown

/**
* Called when test runner should cancel next test runs.
* Runner should listen for this method and mark tests and suites as skipped in
* "onBeforeRunSuite" and "onBeforeRunTask" when called.
*/
onCancel?(reason: CancelReason): unknown
onCancel?: (reason: CancelReason) => unknown

/**
* Called before running a single test. Doesn't have "result" yet.
*/
onBeforeRunTask?(test: TaskPopulated): unknown
onBeforeRunTask?: (test: TaskPopulated) => unknown
/**
* Called before actually running the test function. Already has "result" with "state" and "startTime".
*/
onBeforeTryTask?(test: TaskPopulated, options: { retry: number; repeats: number }): unknown
onBeforeTryTask?: (test: TaskPopulated, options: { retry: number; repeats: number }) => unknown
/**
* Called after result and state are set.
*/
onAfterRunTask?(test: TaskPopulated): unknown
onAfterRunTask?: (test: TaskPopulated) => unknown
/**
* Called right after running the test function. Doesn't have new state yet. Will not be called, if the test function throws.
*/
onAfterTryTask?(test: TaskPopulated, options: { retry: number; repeats: number }): unknown
onAfterTryTask?: (test: TaskPopulated, options: { retry: number; repeats: number }) => unknown

/**
* Called before running a single suite. Doesn't have "result" yet.
*/
onBeforeRunSuite?(suite: Suite): unknown
onBeforeRunSuite?: (suite: Suite) => unknown
/**
* Called after running a single suite. Has state and result.
*/
onAfterRunSuite?(suite: Suite): unknown
onAfterRunSuite?: (suite: Suite) => unknown

/**
* If defined, will be called instead of usual Vitest suite partition and handling.
* "before" and "after" hooks will not be ignored.
*/
runSuite?(suite: Suite): Promise<void>
runSuite?: (suite: Suite) => Promise<void>
/**
* If defined, will be called instead of usual Vitest handling. Useful, if you have your custom test function.
* "before" and "after" hooks will not be ignored.
*/
runTask?(test: TaskPopulated): Promise<void>
runTask?: (test: TaskPopulated) => Promise<void>

/**
* Called, when a task is updated. The same as "onTaskUpdate" in a reporter, but this is running in the same thread as tests.
*/
onTaskUpdate?(task: [string, TaskResult | undefined][]): Promise<void>
onTaskUpdate?: (task: [string, TaskResult | undefined][]) => Promise<void>

/**
* Called before running all tests in collected paths.
*/
onBeforeRunFiles?(files: File[]): unknown
onBeforeRunFiles?: (files: File[]) => unknown
/**
* Called right after running all tests in collected paths.
*/
onAfterRunFiles?(files: File[]): unknown
onAfterRunFiles?: (files: File[]) => unknown
/**
* Called when new context for a test is defined. Useful, if you want to add custom properties to the context.
* If you only want to define custom context with a runner, consider using "beforeAll" in "setupFiles" instead.
Expand All @@ -82,11 +82,11 @@ export interface VitestRunner {
*
* @see https://vitest.dev/advanced/runner.html#your-task-function
*/
extendTaskContext?<T extends Test | Custom>(context: TaskContext<T>): TaskContext<T>
extendTaskContext?: <T extends Test | Custom>(context: TaskContext<T>) => TaskContext<T>
/**
* Called, when certain files are imported. Can be called in two situations: when collecting tests and when importing setup files.
*/
importFile(filepath: string, source: VitestRunnerImportSource): unknown
importFile: (filepath: string, source: VitestRunnerImportSource) => unknown
/**
* Publicly available configuration.
*/
Expand Down
4 changes: 2 additions & 2 deletions docs/api/expect.md
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ If you are using TypeScript, since Vitest 0.31.0 you can extend default `Asserti

```ts
interface CustomMatchers<R = unknown> {
toBeFoo(): R
toBeFoo: () => R
}

declare module 'vitest' {
Expand Down Expand Up @@ -1456,4 +1456,4 @@ expect.addEqualityTesters([areAnagramsEqual])
test('custom equality tester', () => {
expect(new AnagramComparator('listen')).toEqual(new AnagramComparator('silent'))
})
```
```
1 change: 0 additions & 1 deletion docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ test.todo.concurrent(/* ... */) // or test.concurrent.todo(/* ... */)

When running concurrent tests, Snapshots and Assertions must use `expect` from the local [Test Context](/guide/test-context.md) to ensure the right test is detected.


```ts
test.concurrent('test 1', async ({ expect }) => {
expect(foo).toMatchSnapshot()
Expand Down
12 changes: 4 additions & 8 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,6 @@ Minimum number of threads. You can also use `VITEST_MIN_THREADS` environment var

Run all tests with the same environment inside a single worker thread. This will disable built-in module isolation (your source code or [inlined](#deps-inline) code will still be reevaluated for each test), but can improve test performance.


:::warning
Even though this option will force tests to run one after another, this option is different from Jest's `--runInBand`. Vitest uses workers not only for running tests in parallel, but also to provide isolation. By disabling this option, your tests will run sequentially, but in the same global context, so you must provide isolation yourself.

Expand Down Expand Up @@ -782,7 +781,6 @@ Isolate environment for each test file.

Run all tests with the same environment inside a single child process. This will disable built-in module isolation (your source code or [inlined](#deps-inline) code will still be reevaluated for each test), but can improve test performance.


:::warning
Even though this option will force tests to run one after another, this option is different from Jest's `--runInBand`. Vitest uses child processes not only for running tests in parallel, but also to provide isolation. By disabling this option, your tests will run sequentially, but in the same global context, so you must provide isolation yourself.

Expand Down Expand Up @@ -881,7 +879,6 @@ Pass additional arguments to `node` process in the VM context. See [Command-line
Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103.
:::


#### poolOptions.vmForks<NonProjectOption />

Options for `vmForks` pool.
Expand Down Expand Up @@ -1063,7 +1060,6 @@ declare module 'vitest' {
```
:::


### watchExclude<NonProjectOption />

- **Type:** `string[]`
Expand Down Expand Up @@ -1557,10 +1553,10 @@ Path to a provider that will be used when running browser tests. Vitest provides
```ts
export interface BrowserProvider {
name: string
getSupportedBrowsers(): readonly string[]
initialize(ctx: Vitest, options: { browser: string; options?: BrowserProviderOptions }): Awaitable<void>
openPage(url: string): Awaitable<void>
close(): Awaitable<void>
getSupportedBrowsers: () => readonly string[]
initialize: (ctx: Vitest, options: { browser: string; options?: BrowserProviderOptions }) => Awaitable<void>
openPage: (url: string) => Awaitable<void>
close: () => Awaitable<void>
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/extending-matchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ If you are using TypeScript, since Vitest 0.31.0 you can extend default `Asserti
import type { Assertion, AsymmetricMatchersContaining } from 'vitest'

interface CustomMatchers<R = unknown> {
toBeFoo(): R
toBeFoo: () => R
}

declare module 'vitest' {
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ basic-foo.test.ts
basic/foo.test.ts
```

You can also use the `-t, --testNamePattern <pattern> ` option to filter tests by full name. This can be helpful when you want to filter by the name defined within a file rather than the filename itself.
You can also use the `-t, --testNamePattern <pattern>` option to filter tests by full name. This can be helpful when you want to filter by the name defined within a file rather than the filename itself.

## Specifying a Timeout

Expand Down
3 changes: 0 additions & 3 deletions docs/guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ All `@vitest/*` sub packages require Vitest version 1.0.

Quotes in snapshots are no longer escaped, and all snapshots use backtick quotes (`) even if the string is just a single line.


1. Quotes are no longer escaped:

```diff
Expand All @@ -44,7 +43,6 @@ There were also [changes](https://github.com/vitest-dev/vitest/pull/4076) to `@v
- `client.setTest` was renamed to `client.startCurrentRun`
- `client.resetCurrent` was renamed to `client.finishCurrentRun`


### Pools are Standardized [#4172](https://github.com/vitest-dev/vitest/pull/4172)

We removed a lot of configuration options to make it easier to configure the runner to your needs. Please, have a look at migration examples if you rely on `--threads` or other related flags.
Expand Down Expand Up @@ -145,7 +143,6 @@ A few types were removed in favor of Jest-style "Mock" naming.
`SpyInstance` is deprecated in favor of `MockInstance` and will be removed in the next major release.
:::


### Timer mocks [#3925](https://github.com/vitest-dev/vitest/pull/3925)

`vi.useFakeTimers()` no longer automatically mocks [`process.nextTick`](https://nodejs.org/api/process.html#processnexttickcallback-args).
Expand Down
1 change: 0 additions & 1 deletion docs/guide/mocking.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ Because Vitest runs in Node, mocking network requests is tricky; web APIs are no

Mock Service Worker (MSW) works by intercepting the requests your tests make, allowing you to use it without changing any of your application code. In-browser, this uses the [Service Worker API](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API). In Node.js, and for Vitest, it uses the [`@mswjs/interceptors`](https://github.com/mswjs/interceptors) library. To learn more about MSW, read their [introduction](https://mswjs.io/docs/)


### Configuration

You can use it like below in your [setup file](/config/#setupfiles)
Expand Down
3 changes: 0 additions & 3 deletions docs/guide/reporters.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ not ok 1 - __tests__/test-file-1.test.ts > first test file > 2 + 2 should equal
ok 2 - __tests__/test-file-1.test.ts > first test file > 4 - 2 should equal 2 # time=0.00ms
```


### Hanging Process Reporter

Displays a list of hanging processes, if any are preventing Vitest from exiting safely. The `hanging-process` reporter does not itself display test results, but can be used in conjunction with another reporter to monitor processes while tests run. Using this reporter can be resource-intensive, so should generally be reserved for debugging purposes in situations where Vitest consistently cannot exit the process.
Expand All @@ -453,8 +452,6 @@ to provide annotations for test failures. This reporter is automatically enabled
<img alt="Github Actions" img-dark src="https://github.com/vitest-dev/vitest/assets/4232207/336cddc2-df6b-4b8a-8e72-4d00010e37f5">
<img alt="Github Actions" img-light src="https://github.com/vitest-dev/vitest/assets/4232207/ce8447c1-0eab-4fe1-abef-d0d322290dca">



## Custom Reporters

You can use third-party custom reporters installed from NPM by specifying their package name in the reporters' option:
Expand Down
1 change: 0 additions & 1 deletion docs/guide/snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ export default {
} satisfies SnapshotSerializer
```


```ts
import { defineConfig } from 'vite'

Expand Down
1 change: 0 additions & 1 deletion docs/guide/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ vitest --ui

Then you can visit the Vitest UI at <a href="http://localhost:51204/__vitest__/">`http://localhost:51204/__vitest__/`</a>


<img alt="Vitest UI" img-light src="https://user-images.githubusercontent.com/11247099/171992267-5cae2fa0-b927-400a-8eb1-da776974cb61.png">
<img alt="Vitest UI" img-dark src="https://user-images.githubusercontent.com/11247099/171992272-7c6057e2-80c3-4b17-a7b6-0ac28e5a5e0b.png">

Expand Down
14 changes: 13 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ export default antfu(
'node/prefer-global/process': 'off',
'no-empty-pattern': 'off',
'antfu/indent-binary-ops': 'off',
'style/member-delimiter-style': ['error', { multiline: { delimiter: 'none' }, singleline: { delimiter: 'semi' } }],
'unused-imports/no-unused-imports': 'error',
'style/member-delimiter-style': [
'error',
{
multiline: { delimiter: 'none' },
singleline: { delimiter: 'semi' },
},
],

'ts/no-invalid-this': 'off',

Expand All @@ -42,6 +48,12 @@ export default antfu(
'import/no-named-as-default': 'off',
},
},
{
files: [`packages/*/*.{js,mjs,d.ts}`],
rules: {
'antfu/no-import-dist': 'off',
},
},
{
files: [`packages/${GLOB_SRC}`],
rules: {
Expand Down
2 changes: 1 addition & 1 deletion examples/image-snapshot/test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { toMatchImageSnapshot } from 'jest-image-snapshot'

declare module 'vitest' {
interface Assertion<T> {
toMatchImageSnapshot(): T
toMatchImageSnapshot: () => T
}
}

Expand Down
29 changes: 15 additions & 14 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
[build.environment]
NODE_VERSION = "20"
# don't need playwright for docs build
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1"

[build]
publish = "docs/.vitepress/dist"
command = "pnpm docs:build"
ignore = "git diff --quiet $COMMIT_REF $CACHED_COMMIT_REF -- docs/ package.json pnpm-lock.yaml"
publish = "docs/.vitepress/dist"
command = "pnpm docs:build"
ignore = "git diff --quiet $COMMIT_REF $CACHED_COMMIT_REF -- docs/ package.json pnpm-lock.yaml"

[build.environment]
NODE_VERSION = "20"
# don't need playwright for docs build
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1"

[[redirects]]
from = "/new"
to = "https://stackblitz.com/fork/github/vitest-dev/vitest/tree/main/examples/basic?initialPath=__vitest__/"
status = 302
from = "/new"
to = "https://stackblitz.com/fork/github/vitest-dev/vitest/tree/main/examples/basic?initialPath=__vitest__/"
status = 302

[[headers]]
for = "/manifest.webmanifest"
[headers.values]
Content-Type = "application/manifest+json"
for = "/manifest.webmanifest"

[headers.values]
Content-Type = "application/manifest+json"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"test:browser:playwright": "pnpm -C test/browser run test:playwright"
},
"devDependencies": {
"@antfu/eslint-config": "^1.2.1",
"@antfu/eslint-config": "^2.6.4",
"@antfu/ni": "^0.21.12",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
"webdriverio": "*"
},
"peerDependenciesMeta": {
"webdriverio": {
"playwright": {
"optional": true
},
"safaridriver": {
"optional": true
},
"playwright": {
"webdriverio": {
"optional": true
}
},
Expand Down
Loading

0 comments on commit 7a31a1a

Please sign in to comment.