You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: crates/oxc_linter/src/rules/vitest/require_mock_type_parameters.rs
+14-13Lines changed: 14 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -48,21 +48,22 @@ impl std::ops::Deref for RequireMockTypeParameters {
48
48
declare_oxc_lint!(
49
49
/// ### What it does
50
50
///
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()`.
52
52
///
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()`.
54
54
///
55
55
/// ### Why is this bad?
56
56
///
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`.
58
58
/// This disables type checking between the mock and the real implementation, which can lead to two problems:
59
59
///
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.
61
62
///
62
63
/// ### Examples
63
64
///
64
65
/// Examples of **incorrect** code for this rule configured as `{ "checkImportFunctions": false }`:
65
-
/// ```js
66
+
/// ```ts
66
67
/// import { vi } from 'vitest'
67
68
///
68
69
/// test('foo', () => {
@@ -71,7 +72,7 @@ declare_oxc_lint!(
71
72
/// ```
72
73
///
73
74
/// Examples of **incorrect** code for this rule configured as `{ "checkImportFunctions": true }`:
74
-
/// ```js
75
+
/// ```ts
75
76
/// import { vi } from 'vitest'
76
77
///
77
78
/// vi.mock('./example.js', async () => {
@@ -83,18 +84,18 @@ declare_oxc_lint!(
83
84
/// ```
84
85
///
85
86
/// Examples of **correct** code for this rule configured as `{ "checkImportFunctions": false }`:
0 commit comments