jest/prefer-to-have-length
eslint-plugin-jest
Safe autofix
eslint.config.js
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/prefer-to-have-length": "error",
},
},
];expect(files.length).toBe(1);expect(files.length).toEqual(1);expect(files.length).not.toStrictEqual(1);expect(files).toHaveLength(1);
expect(files).not.toHaveLength(1);
expect(files.name).toBe("report.txt");Examples from the Biome documentation.
jest/prefer-to-have-length
eslint-plugin-jest
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/prefer-to-have-length": "error",
},
},
];jest/prefer-to-have-length
jest plugin · style
{
"plugins": [
"jest"
],
"rules": {
"jest/prefer-to-have-length": "error"
}
}nursery/useExpectToHaveLength
nursery · since 2.6.9
{
"linter": {
"rules": {
"nursery": {
"useExpectToHaveLength": "error"
}
}
}
}Enforces a maximum depth to nested describe calls