Skip to content

Commit 8705661

Browse files
AfsoonCopilot
authored andcommitted
docs(linter): Added in the missing jest rules that are compatible with vitest. (#16679)
After the review @connorshea did in #16540 (review), suggested to me add a missing part of documentation in the linter rule. I hadn't added it because the reference rule I used lack of it. So this PR aims to add it in all jest rules stated as compatible. ## Before this PR The following Jest linter only had this documentation part: - consistent-test-it - expect-expect - no-alias-methods - no-commented-out-tests - no-disabled-tests - no-focused-tests - no-identical-title - no-test-prefixes - prefer-hooks-in-order - valid-describe-callback - valid-expect ## Adding in this PR - max-expects - max-nested-describe - no-conditional-expect - no-conditional-in-test - no-duplicate-hooks - no-hooks - no-interpolation-in-snapshots - no-restricted-jest-methods: I have doubts here see my comment in the [vitest-eslint-plugin issue](#4656 (comment)) - no-restricted-matchers - no-standalone-expect - no-test-return-statement - prefer-comparison-matcher - prefer-each - prefer-equality-matcher - prefer-expect-resolves - prefer-hooks-on-top - prefer-lowercase-title - prefer-mock-promise-shorthand - prefer-strict-equal - prefer-to-be - prefer-to-have-length - prefer-todo - require-to-throw-message - require-top-level-describe
1 parent 21de86e commit 8705661

24 files changed

+264
-0
lines changed

crates/oxc_linter/src/rules/jest/max_expects.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ declare_oxc_lint!(
6666
/// expect(true).toBeDefined();
6767
/// });
6868
/// ```
69+
///
70+
/// This rule is compatible with [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-expects.md),
71+
/// to use it, add the following configuration to your `.oxlintrc.json`:
72+
///
73+
/// ```json
74+
/// {
75+
/// "rules": {
76+
/// "vitest/max-expects": "error"
77+
/// }
78+
/// }
79+
/// ```
6980
MaxExpects,
7081
jest,
7182
style,

crates/oxc_linter/src/rules/jest/max_nested_describe.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ declare_oxc_lint!(
120120
/// });
121121
/// });
122122
/// ```
123+
///
124+
/// This rule is compatible with [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/max-nested-describe.md),
125+
/// to use it, add the following configuration to your `.oxlintrc.json`:
126+
///
127+
/// ```json
128+
/// {
129+
/// "rules": {
130+
/// "vitest/max-nested-describe": "error"
131+
/// }
132+
/// }
133+
/// ```
123134
MaxNestedDescribe,
124135
jest,
125136
style,

crates/oxc_linter/src/rules/jest/no_conditional_expect.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ declare_oxc_lint!(
9393
/// await expect(foo).rejects.toThrow(Error);
9494
/// });
9595
/// ```
96+
///
97+
/// This rule is compatible with [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md),
98+
/// to use it, add the following configuration to your `.oxlintrc.json`:
99+
///
100+
/// ```json
101+
/// {
102+
/// "rules": {
103+
/// "vitest/no-conditional-expect": "error"
104+
/// }
105+
/// }
106+
/// ```
96107
NoConditionalExpect,
97108
jest,
98109
correctness

crates/oxc_linter/src/rules/jest/no_conditional_in_test.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ declare_oxc_lint!(
9292
/// await expect(promiseValue()).resolves.toBe(1);
9393
/// });
9494
/// ```
95+
///
96+
/// This rule is compatible with [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md),
97+
/// to use it, add the following configuration to your `.oxlintrc.json`:
98+
///
99+
/// ```json
100+
/// {
101+
/// "rules": {
102+
/// "vitest/no-conditional-in-test": "error"
103+
/// }
104+
/// }
105+
/// ```
95106
NoConditionalInTest,
96107
jest,
97108
pedantic,

crates/oxc_linter/src/rules/jest/no_duplicate_hooks.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ declare_oxc_lint!(
100100
/// });
101101
/// });
102102
/// ```
103+
///
104+
/// This rule is compatible with [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-duplicate-hooks.md),
105+
/// to use it, add the following configuration to your `.oxlintrc.json`:
106+
///
107+
/// ```json
108+
/// {
109+
/// "rules": {
110+
/// "vitest/no-duplicate-hooks": "error"
111+
/// }
112+
/// }
113+
/// ```
103114
NoDuplicateHooks,
104115
jest,
105116
style,

crates/oxc_linter/src/rules/jest/no_hooks.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ declare_oxc_lint!(
8383
/// });
8484
/// });
8585
/// ```
86+
///
87+
/// This rule is compatible with [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-hooks.md),
88+
/// to use it, add the following configuration to your `.oxlintrc.json`:
89+
///
90+
/// ```json
91+
/// {
92+
/// "rules": {
93+
/// "vitest/no-hooks": "error"
94+
/// }
95+
/// }
96+
/// ```
8697
NoHooks,
8798
jest,
8899
style,

crates/oxc_linter/src/rules/jest/no_interpolation_in_snapshots.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ declare_oxc_lint!(
5151
/// `${interpolated}`,
5252
/// );
5353
/// ```
54+
///
55+
/// This rule is compatible with [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-interpolation-in-snapshots.md),
56+
/// to use it, add the following configuration to your `.oxlintrc.json`:
57+
///
58+
/// ```json
59+
/// {
60+
/// "rules": {
61+
/// "vitest/no-interpolation-in-snapshots": "error"
62+
/// }
63+
/// }
64+
/// ```
5465
NoInterpolationInSnapshots,
5566
jest,
5667
style

crates/oxc_linter/src/rules/jest/no_restricted_jest_methods.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ declare_oxc_lint!(
6868
/// // ...
6969
/// });
7070
/// ```
71+
///
72+
/// This rule is compatible with [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-vi-methods.md),
73+
/// to use it, add the following configuration to your `.oxlintrc.json`:
74+
///
75+
/// ```json
76+
/// {
77+
/// "rules": {
78+
/// "vitest/no-restricted-vi-methods": "error"
79+
/// }
80+
/// }
81+
/// ```
7182
NoRestrictedJestMethods,
7283
jest,
7384
style,

crates/oxc_linter/src/rules/jest/no_restricted_matchers.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ declare_oxc_lint!(
105105
/// });
106106
/// });
107107
/// ```
108+
///
109+
/// This rule is compatible with [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-restricted-matchers.md),
110+
/// to use it, add the following configuration to your `.oxlintrc.json`:
111+
///
112+
/// ```json
113+
/// {
114+
/// "rules": {
115+
/// "vitest/no-restricted-matchers": "error"
116+
/// }
117+
/// }
118+
/// ```
108119
NoRestrictedMatchers,
109120
jest,
110121
style,

crates/oxc_linter/src/rules/jest/no_standalone_expect/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ declare_oxc_lint!(
7070
/// expect(1).toBe(1);
7171
/// });
7272
/// ```
73+
///
74+
/// This rule is compatible with [eslint-plugin-vitest](https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-standalone-expect.md),
75+
/// to use it, add the following configuration to your `.oxlintrc.json`:
76+
///
77+
/// ```json
78+
/// {
79+
/// "rules": {
80+
/// "vitest/no-standalone-expect": "error"
81+
/// }
82+
/// }
83+
/// ```
7384
NoStandaloneExpect,
7485
jest,
7586
correctness,

0 commit comments

Comments
 (0)