eslint/no-unmodified-loop-condition Suspicious
What it does
Disallow references in loop conditions that are never modified within the loop.
Why is this bad?
A loop condition that depends on values that never change within the loop body can cause infinite loops or logic bugs.
Examples
Examples of incorrect code for this rule:
js
let done = false;
while (!done) {
work();
}Examples of correct code for this rule:
js
let done = false;
while (!done) {
done = checkDone();
}Configuration
This rule accepts a configuration object with the following properties:
checkConditionalExpressions
type: boolean
default: false
Whether references in each branch of a conditional expression should be checked independently instead of checking the result of the entire expression.
How to use
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"no-unmodified-loop-condition": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"no-unmodified-loop-condition": "error",
},
});bash
oxlint --deny no-unmodified-loop-conditionVersion
This rule was added in v1.48.0.
