jest/prefer-equality-matcher
eslint-plugin-jest
Suggestion
eslint.config.js
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/prefer-equality-matcher": "error",
},
},
];expect(x === 5).toBe(true);
expect(name === 'Carl').not.toEqual(true);
expect(myObj !== thatObj).toStrictEqual(true);expect(x).toBe(5);
expect(name).not.toEqual('Carl');
expect(myObj).not.toStrictEqual(thatObj);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.
jest/prefer-equality-matcher
eslint-plugin-jest
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/prefer-equality-matcher": "error",
},
},
];jest/prefer-equality-matcher
jest plugin · style
{
"plugins": [
"jest"
],
"rules": {
"jest/prefer-equality-matcher": "error"
}
}nursery/useExpectEqualityMatcher
nursery · since 2.6.9
{
"linter": {
"rules": {
"nursery": {
"useExpectEqualityMatcher": "error"
}
}
}
}Enforce using the built-in equality matchers
Prefer having hooks in a consistent order
Suggest having hooks before any test cases
Enforces a maximum depth to nested describe calls