vitest/prefer-equality-matcher
@vitest/eslint-plugin
Suggestion
eslint.config.js
import vitest from "@vitest/eslint-plugin";
export default [
{
plugins: { vitest },
rules: {
"vitest/prefer-equality-matcher": "error",
},
},
];// bad
expect(1 == 1).toBe(1)
// bad
expect(1).toEqual(1)The documentation shows no correct example for this rule.
Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
vitest/prefer-equality-matcher
@vitest/eslint-plugin
import vitest from "@vitest/eslint-plugin";
export default [
{
plugins: { vitest },
rules: {
"vitest/prefer-equality-matcher": "error",
},
},
];vitest/prefer-equality-matcher
vitest plugin · style
{
"plugins": [
"vitest"
],
"rules": {
"vitest/prefer-equality-matcher": "error"
}
}nursery/useExpectEqualityMatcher
nursery · since 2.6.9
{
"linter": {
"rules": {
"nursery": {
"useExpectEqualityMatcher": "error"
}
}
}
}Suggest using the built-in equality matchers
Enforce using a function as a describe title over an equivalent string
Enforce having hooks before any test cases
Enforce using toBeCalledWith() or toHaveBeenCalledWith()
Enforce importing Vitest globals
Enforce using toBeCalledTimes(1) or toHaveBeenCalledTimes(1)