for-direction
NOTE: this rule is part of the
推荐
rule set.Enable full set in
deno.json
:{ "lint": { "rules": { "tags": ["推荐"] } } }
Enable full set using the Deno CLI:
deno lint --rules-tags=推荐
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"] } } }
需要 for
循环控制变量以正确的方向递增。
以错误的方向递增 for
循环控制变量会导致无限循环。这可以通过不正确的初始化、错误的继续步骤逻辑或错误方向的循环控制变量递增造成。
无效:
// 无限循环
for (let i = 0; i < 2; i--) {}
有效:
for (let i = 0; i < 2; i++) {}