# for-direction

Disallow for loops whose counter moves away from its bound

A counter that moves away from its relational bound cannot make a true loop condition false.
Instead, you MUST reverse the counter update or comparison direction.

An unconditional loop expresses intentional nontermination directly.

- Category: correctness
- Level: error
- Fix: suggestion
- Scope: module

## Reported

```ds title="main.ds"
for (let index: int32 = 0; index < 10; index--) {}
```

## Accepted

```ds title="main.ds"
for (let index: int32 = 0; index < 10; index++) {}
```

## Prior art

- [ESLint · for-direction](https://eslint.org/docs/latest/rules/for-direction)

[language/linter/src/rules/correctness/for_direction.rs:10](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/correctness/for_direction.rs#L10)
