hapi style guide ESLint rule dealing with for loops.
This rule enforces the following:
- Restrict iterator variable names.
forloop iterator variables should be named
i. Nested loops should use the variables
k, and so on.
- Restrict loop nesting. You can restrict the maximum nesting of
forloops. By default, this limit is three.
- Prevent postfix increment and decrement operators. The hapi style guide does not allow postfix increment and decrement operators in
forloop updates. The prefix version of these operators should be used instead.
- Single variable declaration in initialization section. A single
var i = 0;is allowed in the initialization section. This only applies to variable declarations, not assignments to existing variables. This means that
for (i = 0, j = 0)is allowed if
jare existing variables. Variable declarations involving destructuring are not allowed.
This rule can be configured by providing a single options object. The object supports the following keys.
A number representing the maximum allowed nesting of
for loops. Defaults to three.
The first variable iterator name to use. This defaults to