What version of Oxlint are you using?
1.70.0
What command did you run?
oxlint -c oxlint.config.jsonc
What does your .oxlintrc.json (or oxlint.config.ts) config file look like?
What happened?
vitest/expect-expect reports a false positive when a test uses expectTypeOf as a global without an explicit import ... from "vitest".
Reproduction (repro.spec.ts):
it("should work", () => {
expectTypeOf({ a: 1 }).toEqualTypeOf<{ a: number }>();
});
Actual output:
x vitest(expect-expect): Test has no assertions
Expected: No diagnostic — expectTypeOf should be recognized as an assertion. The rule's documentation explicitly lists ["expect", "expectTypeOf", "assert", "assertType"] as the Vitest default.
Root cause: The shared implementation at crates/oxc_linter/src/rules/shared/jest_vitest/expect_expect.rs selects defaults based on ctx.frameworks().is_vitest():
let assert_function_names = if ctx.frameworks().is_vitest() {
&rule.assert_function_names_vitest // ["expect", "expectTypeOf", "assert", "assertType"]
} else {
&rule.assert_function_names_jest // ["expect"] only
};
Framework detection (has_vitest_imports in crates/oxc_linter/src/frameworks.rs) only checks for value imports from "vitest". When using Vitest with globals: true, there is no import, so is_vitest() returns false, and the rule falls back to the Jest defaults which only include ["expect"].
The vitest/expect-expect rule should unconditionally use the Vitest assertion function defaults regardless of import-based framework detection — the rule is already namespaced under vitest/.
What version of Oxlint are you using?
1.70.0
What command did you run?
oxlint -c oxlint.config.jsonc
What does your
.oxlintrc.json(oroxlint.config.ts) config file look like?{ "plugins": ["vitest"], "globals": { "expect": "readonly", "expectTypeOf": "readonly" }, "overrides": [ { "files": ["**/*.spec.ts"], "plugins": ["vitest"], "rules": { "vitest/expect-expect": "error" } } ] }What happened?
vitest/expect-expectreports a false positive when a test usesexpectTypeOfas a global without an explicitimport ... from "vitest".Reproduction (
repro.spec.ts):Actual output:
Expected: No diagnostic —
expectTypeOfshould be recognized as an assertion. The rule's documentation explicitly lists["expect", "expectTypeOf", "assert", "assertType"]as the Vitest default.Root cause: The shared implementation at
crates/oxc_linter/src/rules/shared/jest_vitest/expect_expect.rsselects defaults based onctx.frameworks().is_vitest():Framework detection (
has_vitest_importsincrates/oxc_linter/src/frameworks.rs) only checks for value imports from"vitest". When using Vitest withglobals: true, there is no import, sois_vitest()returnsfalse, and the rule falls back to the Jest defaults which only include["expect"].The
vitest/expect-expectrule should unconditionally use the Vitest assertion function defaults regardless of import-based framework detection — the rule is already namespaced undervitest/.