no-incorrect-deep-equal

July 2, 2026 ยท View on GitHub

๐Ÿ“ Disallow deepEqual/deepStrictEqual (and their notDeep* variants) when comparing with primitives.

๐Ÿ’ผ This rule is enabled in the following configs: โœ… recommended, โ˜‘๏ธ unopinionated.

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

deepEqual and deepStrictEqual (and their notDeep* variants) perform deep structural comparison, which is unnecessary and misleading when one of the arguments is a primitive value. A primitive has no structure to recurse into, so strict equality is the correct and simpler assertion.

This rule reports deepEqual, deepStrictEqual, notDeepEqual, and notDeepStrictEqual calls where either argument is a primitive literal. It autofixes by replacing the method name with the strict equality equivalent.

Deep methodReplacement
deepEqualequal
deepStrictEqualstrictEqual
notDeepEqualnotEqual
notDeepStrictEqualnotStrictEqual

Examples

import assert from 'node:assert';

// โŒ
assert.deepEqual(actual, 'expected string');
assert.deepStrictEqual(42, actual);
assert.notDeepEqual(actual, null);

// โœ…
assert.equal(actual, 'expected string');
assert.strictEqual(42, actual);
assert.notEqual(actual, null);

// โœ… (non-primitives โ€” deep comparison is appropriate)
assert.deepEqual(actual, {key: 'value'});
assert.deepStrictEqual(actual, [1, 2, 3]);