# no-equals-in-for-termination

Rule `sonarjs/no-equals-in-for-termination`. Equality operators should not be used in "for" loop termination conditions

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1266 by reach, #567 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/no-equals-in-for-termination` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-888/) |

## Code examples

### Incorrect: the rule reports this

```js
for (var i = 1; i != 10; i += 2)  // Noncompliant. Infinite; i goes from 9 straight to 11.
{
  //...
}
```

### Correct: the rule accepts this

```js
for (var i = 1; i <= 10; i += 2)  // Compliant
{
  //...
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/no-equals-in-for-termination": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/no-empty-test-title](https://lintradar.dev/rules/sonarjs/no-empty-test-title.md): Test and suite titles should not be empty or whitespace-only
- [sonarjs/no-exclusive-tests](https://lintradar.dev/rules/sonarjs/no-exclusive-tests.md): Exclusive tests should not be committed to version control
- [sonarjs/no-empty-parameterized-test-dataset](https://lintradar.dev/rules/sonarjs/no-empty-parameterized-test-dataset.md): Parameterized tests should not have empty datasets
- [sonarjs/no-extra-arguments](https://lintradar.dev/rules/sonarjs/no-extra-arguments.md): Function calls should not pass extra arguments
- [sonarjs/no-empty-group](https://lintradar.dev/rules/sonarjs/no-empty-group.md): Regular expressions should not contain empty groups
- [sonarjs/no-fallthrough](https://lintradar.dev/rules/sonarjs/no-fallthrough.md): Switch cases should end with an unconditional "break" statement

---

Web page: https://lintradar.dev/rules/sonarjs/no-equals-in-for-termination. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
