mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(linter): error diagnostic message based on parameter length of valid-expect (#6455)
This commit is contained in:
parent
073b02af14
commit
e81181261d
2 changed files with 68 additions and 68 deletions
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 2 arguments
|
||||
╭─[valid_expect.tsx:1:1]
|
||||
1 │ expect('something', 'else', 'entirely').toEqual('something');
|
||||
· ───────────────────────────────────────
|
||||
╰────
|
||||
help: Add the missing arguments.
|
||||
|
||||
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 2 arguments
|
||||
╭─[valid_expect.tsx:1:1]
|
||||
1 │ expect('something', 'else', 'entirely').toEqual('something');
|
||||
· ───────────────────────────────────────
|
||||
╰────
|
||||
help: Add the missing arguments.
|
||||
|
||||
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 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
|
||||
╭─[valid_expect.tsx:1:1]
|
||||
1 │ expect('something', 'else', 'entirely').toEqual('something');
|
||||
· ───────────────────────────────────────
|
||||
╰────
|
||||
help: Remove the extra 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: Remove the extra 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: Remove the extra 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');
|
||||
· ───────────────────────────
|
||||
|
|
@ -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.
|
||||
|
||||
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 2 arguments
|
||||
╭─[valid_expect.tsx:1:1]
|
||||
1 │ expect("something", "else", "entirely").toEqual("something");
|
||||
· ───────────────────────────────────────
|
||||
╰────
|
||||
help: Add the missing arguments.
|
||||
|
||||
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 2 arguments
|
||||
╭─[valid_expect.tsx:1:1]
|
||||
1 │ expect("something", "else", "entirely").toEqual("something");
|
||||
· ───────────────────────────────────────
|
||||
╰────
|
||||
help: Add the missing arguments.
|
||||
|
||||
⚠ eslint-plugin-vitest(valid-expect): Expect requires at least 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
|
||||
╭─[valid_expect.tsx:1:1]
|
||||
1 │ expect("something", "else", "entirely").toEqual("something");
|
||||
· ───────────────────────────────────────
|
||||
╰────
|
||||
help: Remove the extra 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: Remove the extra 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: Remove the extra 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");
|
||||
· ───────────────────────────
|
||||
|
|
|
|||
Loading…
Reference in a new issue