Skip to content

Commit 99f0b68

Browse files
committed
docs(linter): Improve docs for vitest/require-mock-type-parameters rule. (#21754)
The code examples were marked as `js` but contained TypeScript syntax, so oxfmt was messing them up. Also added some missing backticks around method names.
1 parent 9e2796b commit 99f0b68

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

crates/oxc_linter/src/rules/vitest/require_mock_type_parameters.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,22 @@ impl std::ops::Deref for RequireMockTypeParameters {
4848
declare_oxc_lint!(
4949
/// ### What it does
5050
///
51-
/// Enforces the use of type parameters on vi.fn(), and optionally on vi.importActual() and vi.importMock().
51+
/// Enforces the use of type parameters on `vi.fn()`, and optionally on `vi.importActual()` and `vi.importMock()`.
5252
///
53-
/// By default, only vi.fn() is checked. Set checkImportFunctions to true to also check vi.importActual() and vi.importMock().
53+
/// By default, only `vi.fn()` is checked. Set `checkImportFunctions` to `true` to also check `vi.importActual()` and `vi.importMock()`.
5454
///
5555
/// ### Why is this bad?
5656
///
57-
/// Without explicit type parameters, vi.fn() creates a mock typed as (...args: any[]) => any.
57+
/// Without explicit type parameters, `vi.fn()` creates a mock typed as `(...args: any[]) => any`.
5858
/// This disables type checking between the mock and the real implementation, which can lead to two problems:
5959
///
60-
/// - tests that fail due to incorrect mock usage when they should pass, or worse, tests that pass while the mock silently diverges from the actual runtime behavior.
60+
/// - tests that fail due to incorrect mock usage when they should pass
61+
/// - or worse, tests that pass while the mock silently diverges from the actual runtime behavior.
6162
///
6263
/// ### Examples
6364
///
6465
/// Examples of **incorrect** code for this rule configured as `{ "checkImportFunctions": false }`:
65-
/// ```js
66+
/// ```ts
6667
/// import { vi } from 'vitest'
6768
///
6869
/// test('foo', () => {
@@ -71,7 +72,7 @@ declare_oxc_lint!(
7172
/// ```
7273
///
7374
/// Examples of **incorrect** code for this rule configured as `{ "checkImportFunctions": true }`:
74-
/// ```js
75+
/// ```ts
7576
/// import { vi } from 'vitest'
7677
///
7778
/// vi.mock('./example.js', async () => {
@@ -83,18 +84,18 @@ declare_oxc_lint!(
8384
/// ```
8485
///
8586
/// Examples of **correct** code for this rule configured as `{ "checkImportFunctions": false }`:
86-
/// ```js
87+
/// ```ts
8788
/// import { vi } from 'vitest'
8889
///
89-
/// test('foo', () => {
90-
/// const myMockedFnOne = vi.fn<(arg1: string, arg2: boolean) => number>()
91-
/// const myMockedFnTwo = vi.fn<() => void>()
92-
/// const myMockedFnThree = vi.fn<any>()
93-
/// })
90+
/// test('foo', () => {
91+
/// const myMockedFnOne = vi.fn<(arg1: string, arg2: boolean) => number>()
92+
/// const myMockedFnTwo = vi.fn<() => void>()
93+
/// const myMockedFnThree = vi.fn<any>()
94+
/// })
9495
/// ```
9596
///
9697
/// Examples of **correct** code for this rule configured as `{ "checkImportFunctions": true }`:
97-
/// ```js
98+
/// ```ts
9899
/// import { vi } from 'vitest'
99100
///
100101
/// vi.mock('./example.js', async () => {

0 commit comments

Comments
 (0)