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 method | Replacement |
|---|---|
deepEqual | equal |
deepStrictEqual | strictEqual |
notDeepEqual | notEqual |
notDeepStrictEqual | notStrictEqual |
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]);