Why this matters
Adding non-numeric properties to arrays is error-prone and goes against the intended use of arrays. Use Map or Object instead to ensure predictable behavior.
Ensure that arrays do not contain non-numeric properties. This practice can lead to unexpected behavior. Use Maps or Objects instead.
Adding non-numeric properties to arrays is error-prone and goes against the intended use of arrays. Use Map or Object instead to ensure predictable behavior.
Side-by-side examples engineers can pattern-match during review.
const arr = [];
arr['key'] = 'value'; // Bad practiceconst map = new Map<string, string>();
map.set('key', 'value');const arr = [];
arr['key'] = 'value'; // Bad practiceconst map = new Map<string, string>();
map.set('key', 'value');From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.