for-direction
NOTE: this rule is part of the
recommended
rule set.Enable full set in
deno.json
:{ "lint": { "rules": { "tags": ["recommended"] } } }
Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include
or exclude
array in deno.json
:{ "lint": { "rules": { "include": ["for-direction"], "exclude": ["for-direction"] } } }
Requires for
loop control variables to increment in the correct direction.
Incrementing for
loop control variables in the wrong direction leads to
infinite loops. This can occur through incorrect initialization, bad
continuation step logic or wrong direction incrementing of the loop control
variable.
Invalid:
// Infinite loop
for (let i = 0; i < 2; i--) {}
Valid:
for (let i = 0; i < 2; i++) {}