sonarjs/no-undefined-assignment
eslint-plugin-sonarjs
No autofix
eslint.config.js
export default [
{
rules: {
"sonarjs/no-undefined-assignment": "error",
},
},
];var myObject = {};
// ...
myObject.fname = undefined; // Noncompliant
// ...
if (myObject.lname == undefined) {
// property not yet created
}
if (myObject.fname == undefined) {
// no real way of knowing the true state of myObject.fname
}var myObject = {};
// ...
myObject.fname = null;
// ...
if (myObject.lname == undefined) {
// property not yet created
}
if (myObject.fname == undefined) {
// no real way of knowing the true state of myObject.fname
}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/no-undefined-assignment
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-undefined-assignment": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Unused function parameters should be removed
Variables declared with "var" should be declared before they are used