diff --git a/crates/oxc_linter/src/rules/jest/no_conditional_in_test.rs b/crates/oxc_linter/src/rules/jest/no_conditional_in_test.rs index d81d4e88a14f5..f7e0267a1ab96 100644 --- a/crates/oxc_linter/src/rules/jest/no_conditional_in_test.rs +++ b/crates/oxc_linter/src/rules/jest/no_conditional_in_test.rs @@ -10,7 +10,9 @@ use crate::{ }; fn no_conditional_in_test(span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("Avoid having conditionals in tests.").with_label(span) + OxcDiagnostic::warn("Avoid having conditionals in tests.") + .with_help("Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand.") + .with_label(span) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/jest/no_hooks.rs b/crates/oxc_linter/src/rules/jest/no_hooks.rs index 3599a66773934..99232d4f48429 100644 --- a/crates/oxc_linter/src/rules/jest/no_hooks.rs +++ b/crates/oxc_linter/src/rules/jest/no_hooks.rs @@ -13,7 +13,9 @@ use crate::{ }; fn unexpected_hook_diagnostic(span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("Do not use setup or teardown hooks.").with_label(span) + OxcDiagnostic::warn("Do not use setup or teardown hooks.") + .with_help("Inline the setup or teardown logic directly in each test for better readability and isolation.") + .with_label(span) } #[derive(Debug, Default, Clone, Deserialize)] diff --git a/crates/oxc_linter/src/rules/jest/no_test_return_statement.rs b/crates/oxc_linter/src/rules/jest/no_test_return_statement.rs index 3126e3a72ea39..cb9185bf54ec2 100644 --- a/crates/oxc_linter/src/rules/jest/no_test_return_statement.rs +++ b/crates/oxc_linter/src/rules/jest/no_test_return_statement.rs @@ -15,7 +15,10 @@ use crate::{ }; fn no_test_return_statement_diagnostic(span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("Jest tests should not return a value").with_label(span) + OxcDiagnostic::warn("Jest tests should not return a value") + .with_help("Use `await` for async assertions or remove the return statement.") + .with_note("Jest ignores returned values from tests.") + .with_label(span) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/promise/avoid_new.rs b/crates/oxc_linter/src/rules/promise/avoid_new.rs index 24781519818bf..617dea1fd48d1 100644 --- a/crates/oxc_linter/src/rules/promise/avoid_new.rs +++ b/crates/oxc_linter/src/rules/promise/avoid_new.rs @@ -6,7 +6,11 @@ use oxc_span::Span; use crate::{AstNode, context::LintContext, rule::Rule}; fn avoid_new_promise_diagnostic(span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("Avoid creating new promises").with_label(span) + OxcDiagnostic::warn("Avoid creating new promises") + .with_help( + "Use `async`/`await` instead, or return an existing promise from a library function.", + ) + .with_label(span) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/promise/prefer_await_to_callbacks.rs b/crates/oxc_linter/src/rules/promise/prefer_await_to_callbacks.rs index 6604b04a13566..911f784bfc5e6 100644 --- a/crates/oxc_linter/src/rules/promise/prefer_await_to_callbacks.rs +++ b/crates/oxc_linter/src/rules/promise/prefer_await_to_callbacks.rs @@ -10,7 +10,9 @@ use oxc_span::{GetSpan, Span}; use crate::{AstNode, context::LintContext, rule::Rule}; fn prefer_await_to_callbacks(span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("Prefer `async`/`await` to the callback pattern").with_label(span) + OxcDiagnostic::warn("Prefer `async`/`await` to the callback pattern") + .with_help("Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow.") + .with_label(span) } #[derive(Debug, Default, Clone)] diff --git a/crates/oxc_linter/src/rules/promise/prefer_await_to_then.rs b/crates/oxc_linter/src/rules/promise/prefer_await_to_then.rs index 0c540ba3f2fe1..a3769c45f1ec9 100644 --- a/crates/oxc_linter/src/rules/promise/prefer_await_to_then.rs +++ b/crates/oxc_linter/src/rules/promise/prefer_await_to_then.rs @@ -6,7 +6,9 @@ use schemars::JsonSchema; use serde::Deserialize; fn prefer_wait_to_then_diagnostic(span: Span) -> OxcDiagnostic { - OxcDiagnostic::warn("Prefer await to then()/catch()/finally()").with_label(span) + OxcDiagnostic::warn("Prefer await to then()/catch()/finally()") + .with_help("Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code.") + .with_label(span) } use crate::{ diff --git a/crates/oxc_linter/src/snapshots/jest_no_conditional_in_test.snap b/crates/oxc_linter/src/snapshots/jest_no_conditional_in_test.snap index dda72cf877874..6615604a50e67 100644 --- a/crates/oxc_linter/src/snapshots/jest_no_conditional_in_test.snap +++ b/crates/oxc_linter/src/snapshots/jest_no_conditional_in_test.snap @@ -9,6 +9,7 @@ source: crates/oxc_linter/src/tester.rs · ─────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:32] @@ -17,6 +18,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 5 │ }; ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:35] @@ -25,6 +27,7 @@ source: crates/oxc_linter/src/tester.rs · ─────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:35] @@ -33,6 +36,7 @@ source: crates/oxc_linter/src/tester.rs · ─────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:35] @@ -41,6 +45,7 @@ source: crates/oxc_linter/src/tester.rs · ─────────────── 4 │ const anotherFoo = anotherBar ? anotherFoo : anotherBaz; ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:42] @@ -49,6 +54,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────────────────────────── 5 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:25] @@ -61,6 +67,7 @@ source: crates/oxc_linter/src/tester.rs 9 │ ╰─▶ } 10 │ }); ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -70,6 +77,7 @@ source: crates/oxc_linter/src/tester.rs 5 │ ╰─▶ } 6 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -78,6 +86,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -86,6 +95,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -94,6 +104,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -102,6 +113,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -110,6 +122,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -118,6 +131,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -126,6 +140,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -134,6 +149,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -142,6 +158,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -150,6 +167,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:5:25] @@ -158,6 +176,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 6 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:25] @@ -166,6 +185,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 5 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:7:25] @@ -174,6 +194,7 @@ source: crates/oxc_linter/src/tester.rs · ──────────────── 8 │ switch('quux') {} ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:8:25] @@ -182,6 +203,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────────── 9 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:23] @@ -190,6 +212,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────────── 5 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:6:29] @@ -202,6 +225,7 @@ source: crates/oxc_linter/src/tester.rs 11 │ ╰─▶ } 12 │ }); ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:14:27] @@ -212,6 +236,7 @@ source: crates/oxc_linter/src/tester.rs 17 │ ╰─▶ } 18 │ }); ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:25] @@ -223,6 +248,7 @@ source: crates/oxc_linter/src/tester.rs 8 │ ╰─▶ } 9 │ }; ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:25] @@ -234,6 +260,7 @@ source: crates/oxc_linter/src/tester.rs 8 │ ╰─▶ } 9 │ }; ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -242,6 +269,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -250,6 +278,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -258,6 +287,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -266,6 +296,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -274,6 +305,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -282,6 +314,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -290,6 +323,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -298,6 +332,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -306,6 +341,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -314,6 +350,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 4 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:25] @@ -322,6 +359,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 5 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:25] @@ -330,6 +368,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 5 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:7:25] @@ -338,6 +377,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 8 │ if ('quux') {} ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:8:25] @@ -346,6 +386,7 @@ source: crates/oxc_linter/src/tester.rs · ────────────── 9 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:23] @@ -354,6 +395,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 5 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:23] @@ -362,6 +404,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 5 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:23] @@ -370,6 +413,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 5 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:23] @@ -378,6 +422,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 5 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:4:23] @@ -386,6 +431,7 @@ source: crates/oxc_linter/src/tester.rs · ───────────── 5 │ }) ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:6:29] @@ -397,6 +443,7 @@ source: crates/oxc_linter/src/tester.rs 10 │ ╰─▶ } 11 │ }); ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:13:27] @@ -406,6 +453,7 @@ source: crates/oxc_linter/src/tester.rs 15 │ ╰─▶ } 16 │ }); ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:3:23] @@ -415,6 +463,7 @@ source: crates/oxc_linter/src/tester.rs 5 │ ╰─▶ } 6 │ }); ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. ⚠ eslint-plugin-jest(no-conditional-in-test): Avoid having conditionals in tests. ╭─[no_conditional_in_test.tsx:10:23] @@ -424,3 +473,4 @@ source: crates/oxc_linter/src/tester.rs 12 │ ╰─▶ } 13 │ }); ╰──── + help: Replace conditionals with separate test cases for each branch to keep tests deterministic and easy to understand. diff --git a/crates/oxc_linter/src/snapshots/jest_no_hooks.snap b/crates/oxc_linter/src/snapshots/jest_no_hooks.snap index a8273967f6a0d..3ed148ce53a39 100644 --- a/crates/oxc_linter/src/snapshots/jest_no_hooks.snap +++ b/crates/oxc_linter/src/snapshots/jest_no_hooks.snap @@ -7,30 +7,35 @@ source: crates/oxc_linter/src/tester.rs 1 │ beforeAll(() => {}) · ───────── ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:1:1] 1 │ beforeEach(() => {}) · ────────── ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:1:1] 1 │ afterAll(() => {}) · ──────── ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:1:1] 1 │ afterEach(() => {}) · ───────── ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:1:1] 1 │ beforeEach(() => {}); afterEach(() => { jest.resetModules() }); · ────────── ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:5:17] @@ -39,48 +44,56 @@ source: crates/oxc_linter/src/tester.rs · ────────── 6 │ ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:1:1] 1 │ beforeAll(() => {}) · ───────── ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:1:1] 1 │ beforeEach(() => {}) · ────────── ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:1:1] 1 │ afterAll(() => {}) · ──────── ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:1:1] 1 │ afterEach(() => {}) · ───────── ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:1:1] 1 │ afterEach(() => {}) · ───────── ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:1:1] 1 │ afterEach(() => {}) · ───────── ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:1:1] 1 │ beforeEach(() => {}); afterEach(() => { vi.resetModules() }); · ────────── ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. ⚠ eslint-plugin-jest(no-hooks): Do not use setup or teardown hooks. ╭─[no_hooks.tsx:4:8] @@ -89,3 +102,4 @@ source: crates/oxc_linter/src/tester.rs · ────────── 5 │ ╰──── + help: Inline the setup or teardown logic directly in each test for better readability and isolation. diff --git a/crates/oxc_linter/src/snapshots/jest_no_test_return_statement.snap b/crates/oxc_linter/src/snapshots/jest_no_test_return_statement.snap index 7a86ebe710613..6f1b9e9f5e693 100644 --- a/crates/oxc_linter/src/snapshots/jest_no_test_return_statement.snap +++ b/crates/oxc_linter/src/snapshots/jest_no_test_return_statement.snap @@ -9,6 +9,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:3:21] @@ -17,6 +19,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:3:21] @@ -25,6 +29,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:3:21] @@ -33,6 +39,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:3:21] @@ -41,6 +49,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:3:21] @@ -49,6 +59,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:3:21] @@ -57,6 +69,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:3:21] @@ -65,6 +79,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:3:21] @@ -73,6 +89,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:3:21] @@ -81,6 +99,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:3:21] @@ -89,6 +109,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:3:21] @@ -97,6 +119,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:3:21] @@ -105,6 +129,8 @@ source: crates/oxc_linter/src/tester.rs · ────── 4 │ }); ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. ⚠ eslint-plugin-jest(no-test-return-statement): Jest tests should not return a value ╭─[no_test_return_statement.tsx:4:21] @@ -113,3 +139,5 @@ source: crates/oxc_linter/src/tester.rs · ────── 5 │ } ╰──── + help: Use `await` for async assertions or remove the return statement. + note: Jest ignores returned values from tests. diff --git a/crates/oxc_linter/src/snapshots/promise_avoid_new.snap b/crates/oxc_linter/src/snapshots/promise_avoid_new.snap index 3c3e2ae191579..342b8493f4873 100644 --- a/crates/oxc_linter/src/snapshots/promise_avoid_new.snap +++ b/crates/oxc_linter/src/snapshots/promise_avoid_new.snap @@ -7,15 +7,18 @@ source: crates/oxc_linter/src/tester.rs 1 │ var x = new Promise(function (x, y) {}) · ─────────────────────────────── ╰──── + help: Use `async`/`await` instead, or return an existing promise from a library function. ⚠ eslint-plugin-promise(avoid-new): Avoid creating new promises ╭─[avoid_new.tsx:1:1] 1 │ new Promise() · ───────────── ╰──── + help: Use `async`/`await` instead, or return an existing promise from a library function. ⚠ eslint-plugin-promise(avoid-new): Avoid creating new promises ╭─[avoid_new.tsx:1:7] 1 │ Thing(new Promise(() => {})) · ───────────────────── ╰──── + help: Use `async`/`await` instead, or return an existing promise from a library function. diff --git a/crates/oxc_linter/src/snapshots/promise_prefer_await_to_callbacks.snap b/crates/oxc_linter/src/snapshots/promise_prefer_await_to_callbacks.snap index 197122192b49c..dc7815ca709ef 100644 --- a/crates/oxc_linter/src/snapshots/promise_prefer_await_to_callbacks.snap +++ b/crates/oxc_linter/src/snapshots/promise_prefer_await_to_callbacks.snap @@ -7,81 +7,95 @@ source: crates/oxc_linter/src/tester.rs 1 │ heart(function(err) {}) · ──────────────── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:7] 1 │ heart(err => {}) · ───────── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:15] 1 │ heart("ball", function(err) {}) · ──────────────── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:22] 1 │ function getData(id, callback) {} · ──────── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:18] 1 │ const getData = (cb) => {} · ── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:22] 1 │ var x = function (x, cb) {} · ── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:1] 1 │ cb() · ──── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:1] 1 │ callback() · ────────── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:7] 1 │ heart(error => {}) · ─────────── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:27] 1 │ async.map(files, fs.stat, function(err, results) { if (err) throw err; }); · ────────────────────────────────────────────── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:23] 1 │ _.map(files, fs.stat, function(err, results) { if (err) throw err; }); · ────────────────────────────────────────────── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:21] 1 │ map(files, fs.stat, function(err, results) { if (err) throw err; }); · ────────────────────────────────────────────── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:5] 1 │ map(function(err, results) { if (err) throw err; }); · ────────────────────────────────────────────── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. ⚠ eslint-plugin-promise(prefer-await-to-callbacks): Prefer `async`/`await` to the callback pattern ╭─[prefer_await_to_callbacks.tsx:1:19] 1 │ customMap(errors, (err) => err.message) · ──────────────────── ╰──── + help: Refactor to use an `async` function with `await` instead of passing callbacks for cleaner error handling and control flow. diff --git a/crates/oxc_linter/src/snapshots/promise_prefer_await_to_then.snap b/crates/oxc_linter/src/snapshots/promise_prefer_await_to_then.snap index 479e2a1fcf98a..b6684e70ca8a4 100644 --- a/crates/oxc_linter/src/snapshots/promise_prefer_await_to_then.snap +++ b/crates/oxc_linter/src/snapshots/promise_prefer_await_to_then.snap @@ -7,81 +7,95 @@ source: crates/oxc_linter/src/tester.rs 1 │ function foo() { hey.then(x => {}) } · ──── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:43] 1 │ function foo() { hey.then(function() { }).then() } · ──── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:22] 1 │ function foo() { hey.then(function() { }).then() } · ──── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:51] 1 │ function foo() { hey.then(function() { }).then(x).catch() } · ───── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:43] 1 │ function foo() { hey.then(function() { }).then(x).catch() } · ──── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:22] 1 │ function foo() { hey.then(function() { }).then(x).catch() } · ──── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:47] 1 │ async function a() { hey.then(function() { }).then(function() { }) } · ──── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:26] 1 │ async function a() { hey.then(function() { }).then(function() { }) } · ──── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:22] 1 │ function foo() { hey.catch(x => {}) } · ───── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:22] 1 │ function foo() { hey.finally(x => {}) } · ─────── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:13] 1 │ something().then(async () => await somethingElse()) · ──── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:38] 1 │ async function foo() { await thing().then() } · ──── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:32] 1 │ async function foo() { thing().then() } · ──── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code. ⚠ eslint-plugin-promise(prefer-await-to-then): Prefer await to then()/catch()/finally() ╭─[prefer_await_to_then.tsx:1:37] 1 │ async function hi() { await thing().then(x => {}) } · ──── ╰──── + help: Use `await` with `try`/`catch` instead of promise chaining for more readable and maintainable async code.