Skip to content

arrayUnnecessaryLengthChecks

Reports unnecessary array length checks before .some() or .every() calls.

✅ This rule is included in the ts logical presets.

Array#some() returns false for an empty array, so checking array.length !== 0 or array.length > 0 before calling .some() is redundant.

Array#every() returns true for an empty array, so checking array.length === 0 before calling .every() is redundant.

This rule reports these unnecessary length checks.

AEdeclare consB0arr7<2:sp ansty="le--0:#C792EA;--1:#8844">AB0boole53[<];d ivclassNa="meec-li">53arrA72leng5<3 sp ansty="le--0:#C792EA;--1:#8844">AE!<==sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#F78C6C;--1:#AA09">8<20sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C792EA;--1:#8844">AE<&&sp ansty="le--0:#D6DEEB;--1:#403F">53 arrAB0so53(Boolean<);d ivclassNa="meco"><);d>AEdeclare consB0arr7<2:sp ansty="le--0:#C792EA;--1:#8844">AB0boole53[<];d ivclassNa="meec-li">53arrA72leng5<3 sp ansty="le--0:#C792EA;--1:#8844">Asp ansty="le--0:#D6DEEB;--1:#403F">5sp><3 sp ansty="le--0:#F78C6C;--1:#AA09">8<20sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C792EA;--1:#8844">AE<&&sp ansty="le--0:#D6DEEB;--1:#403F">53 arrAB0so53(Boolean<);d ivclassNa="meco"><);d>AEdeclare consB0arr7<2:sp ansty="le--0:#C792EA;--1:#8844">AB0boole53[<];d ivclassNa="meec-li">53arrA72leng5<3 sp ansty="le--0:#C792EA;--1:#8844">AE=<==sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#F78C6C;--1:#AA09">8<20sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C792EA;--1:#8844">AE<||sp ansty="le--0:#D6DEEB;--1:#403F">53 arrAB0eve53(Boolean<);d ivclassNa="meco"><);d>
44AEdeclare co61B0a64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0boo3F5<3[] ;divclass="Nameec-">3F53a4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B03F53(Boole<;di vdivclass="Nameexpressive-">44AEdeclare co61B0a64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0boo3F5<3[] ;divclass="Nameec-">3F53a4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0e3F53(Boole<;di vdivclass="Nameexpressive-">44AEdeclare co61B0a64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0boo3F5<3[] ;divclass="Nameec-">3F53a4<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72le344A30<9820 spans="tyle--0:#D6DEEB;--1:#40">3443F53 a4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0e3F53(Boole<;di vdivclass="Nameexpressive-">44AEdeclare co61B0a64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0boo3F5<3[] ;divclass="Nameec-">3F53a4<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72le344A30<9820 spans="tyle--0:#D6DEEB;--1:#40">3443F53 a4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B03F53(Boole

This rule is not configurable.

If you prefer explicit length checks for documentation purposes, or if your team’s coding standards require them, you may disable this rule.