sonarjs/for-in
eslint-plugin-sonarjs
No autofix
eslint.config.js
export default [
{
rules: {
"sonarjs/for-in": "error",
},
},
];for (name in object) {
doSomething(name); // Noncompliant
}for (name in object) {
if (object.hasOwnProperty(name)) {
doSomething(name);
}
}Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
sonarjs/for-in
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/for-in": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Default export names and file names should match
Function and method names should comply with a naming convention
"if ... else if" constructs should end with "else" clauses