vitest/prefer-to-have-length

January 2, 2026 ยท View on GitHub

๐Ÿ“ Enforce using toHaveLength().

โš ๏ธ This rule warns in the ๐ŸŒ all config.

๐Ÿ”ง This rule is automatically fixable by the --fix CLI option.

// bad
expect(files.length).toStrictEqual(1)

// good
expect(files).toHaveLength(1)