Skip to content

linter: rules table does not properly mark no-restricted-vi-methods as implemented #16732

@connorshea

Description

@connorshea

Working in #16540 I have notice that vitest/no-restricted-vi-methods is implemented but the table show as not. As you can see

"no-restricted-jest-methods",

Probably is due a name mistmatch. For Vitest the linter is named no-restricted-vi-methods but in jest is no-restricted-jest-methods. Following you can see how the jest rule have test case for the vitest context:

let pass_vitest = vec![
("vi", None),
("vi()", None),
("vi.mock()", None),
("expect(a).rejects;", None),
("expect(a);", None),
(
"
import { vi } from 'vitest';
vi;
",
None,
), // { "parserOptions": { "sourceType": "module" } }
];
let fail_vitest = vec![
("vi.fn()", Some(serde_json::json!([{ "fn": null }]))),
("vi.mock()", Some(serde_json::json!([{ "mock": "Do not use mocks" }]))),
(
"
import { vi } from 'vitest';
vi.advanceTimersByTime();
",
Some(serde_json::json!([{ "advanceTimersByTime": null }])),
), // { "parserOptions": { "sourceType": "module" } },
(r#"vi["fn"]()"#, Some(serde_json::json!([{ "fn": null }]))),
];
pass.extend(pass_vitest);
fail.extend(fail_vitest);
Tester::new(NoRestrictedJestMethods::NAME, NoRestrictedJestMethods::PLUGIN, pass, fail)
.with_jest_plugin(true)
.with_vitest_plugin(true)

Originally posted by @Afsoon in #4656

We should fix this by adding a one-off logic change to the rule list generation logic when mapping jest<->vitest rules, probably?

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions