sonarjs/updated-loop-counter
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/updated-loop-counter": "error",
},
},
];Loop counters should not be assigned within the loop body
var names = [ "Jack", "Jim", "", "John" ];
for (var i = 0; i < names.length; i++) {
if (!names[i]) {
i = names.length; // Non-Compliant
} else {
console.log(names[i]);
}
}var names = [ "Jack", "Jim", "", "John" ];
for (var name of names) {
if (!name) {
break; // Compliant
} else {
console.log(name);
}
}Examples from the ESLint documentation.
sonarjs/updated-loop-counter
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/updated-loop-counter": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Server hostnames should be verified during SSL/TLS connections
Vi.mock should be declared at module scope
Server certificates should be verified during SSL/TLS connections