Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/oxc_linter/src/rules/jest/valid_expect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,21 @@ impl ValidExpect {
return;
};

if call_expr.arguments.len() < self.min_args {
if call_expr.arguments.len() > self.max_args {
let error = format!(
"Expect takes at most {} argument{} ",
self.min_args,
if self.min_args > 1 { "s" } else { "" }
self.max_args,
if self.max_args > 1 { "s" } else { "" }
);
let help = "Remove the extra arguments.";
ctx.diagnostic(valid_expect_diagnostic(error, help, call_expr.span));
return;
}
if call_expr.arguments.len() > self.max_args {
if call_expr.arguments.len() < self.min_args {
let error = format!(
"Expect requires at least {} argument{} ",
self.max_args,
if self.max_args > 1 { "s" } else { "" }
self.min_args,
if self.min_args > 1 { "s" } else { "" }
);
let help = "Add the missing arguments.";
ctx.diagnostic(valid_expect_diagnostic(error, help, call_expr.span));
Expand Down
68 changes: 34 additions & 34 deletions crates/oxc_linter/src/snapshots/valid_expect.snap
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
---
source: crates/oxc_linter/src/tester.rs
---
⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 1 argument
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 1 argument
╭─[valid_expect.tsx:1:1]
1 │ expect().toBe(2);
· ────────
╰────
help: Remove the extra arguments.
help: Add the missing arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 1 argument
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 1 argument
╭─[valid_expect.tsx:1:1]
1 │ expect().toBe(true);
· ────────
╰────
help: Remove the extra arguments.
help: Add the missing arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 1 argument
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 1 argument
╭─[valid_expect.tsx:1:1]
1 │ expect().toEqual('something');
· ────────
╰────
help: Remove the extra arguments.
help: Add the missing arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 1 argument
⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 1 argument
╭─[valid_expect.tsx:1:1]
1 │ expect('something', 'else').toEqual('something');
· ───────────────────────────
╰────
help: Add the missing arguments.
help: Remove the extra arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 2 arguments
⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 2 arguments
╭─[valid_expect.tsx:1:1]
1 │ expect('something', 'else', 'entirely').toEqual('something');
· ───────────────────────────────────────
╰────
help: Add the missing arguments.
help: Remove the extra arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 2 arguments
⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 2 arguments
╭─[valid_expect.tsx:1:1]
1 │ expect('something', 'else', 'entirely').toEqual('something');
· ───────────────────────────────────────
╰────
help: Add the missing arguments.
help: Remove the extra arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 2 arguments
⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 2 arguments
╭─[valid_expect.tsx:1:1]
1 │ expect('something', 'else', 'entirely').toEqual('something');
· ───────────────────────────────────────
╰────
help: Add the missing arguments.
help: Remove the extra arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 2 arguments
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 2 arguments
╭─[valid_expect.tsx:1:1]
1 │ expect('something').toEqual('something');
· ───────────────────
╰────
help: Remove the extra arguments.
help: Add the missing arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 3 arguments
⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 1 argument
╭─[valid_expect.tsx:1:1]
1 │ expect('something', 'else').toEqual('something');
· ───────────────────────────
Expand Down Expand Up @@ -498,63 +498,63 @@ source: crates/oxc_linter/src/tester.rs
╰────
help: Did you forget add a matcher(e.g. `toBe`, `toBeDefined`)

⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 1 argument
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 1 argument
╭─[valid_expect.tsx:1:1]
1 │ expect().toBe(2);
· ────────
╰────
help: Remove the extra arguments.
help: Add the missing arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 1 argument
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 1 argument
╭─[valid_expect.tsx:1:1]
1 │ expect().toBe(true);
· ────────
╰────
help: Remove the extra arguments.
help: Add the missing arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 1 argument
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 1 argument
╭─[valid_expect.tsx:1:1]
1 │ expect().toEqual("something");
· ────────
╰────
help: Remove the extra arguments.
help: Add the missing arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 1 argument
⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 1 argument
╭─[valid_expect.tsx:1:1]
1 │ expect("something", "else").toEqual("something");
· ───────────────────────────
╰────
help: Add the missing arguments.
help: Remove the extra arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 2 arguments
⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 2 arguments
╭─[valid_expect.tsx:1:1]
1 │ expect("something", "else", "entirely").toEqual("something");
· ───────────────────────────────────────
╰────
help: Add the missing arguments.
help: Remove the extra arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 2 arguments
⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 2 arguments
╭─[valid_expect.tsx:1:1]
1 │ expect("something", "else", "entirely").toEqual("something");
· ───────────────────────────────────────
╰────
help: Add the missing arguments.
help: Remove the extra arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 2 arguments
⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 2 arguments
╭─[valid_expect.tsx:1:1]
1 │ expect("something", "else", "entirely").toEqual("something");
· ───────────────────────────────────────
╰────
help: Add the missing arguments.
help: Remove the extra arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 2 arguments
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 2 arguments
╭─[valid_expect.tsx:1:1]
1 │ expect("something").toEqual("something");
· ───────────────────
╰────
help: Remove the extra arguments.
help: Add the missing arguments.

⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 3 arguments
⚠ eslint-plugin-vitest(valid-expect): Expect takes at most 1 argument
╭─[valid_expect.tsx:1:1]
1 │ expect("something", "else").toEqual("something");
· ───────────────────────────
Expand Down