consistent-return
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"consistent-return": "error",
},
},
];Require return statements to either always or never specify values
function doSomething(condition) {
if (condition) {
return true;
} else {
return;
}
}
function doSomethingElse(condition) {
if (condition) {
return true;
}
}function doSomething(condition) {
if (condition) {
return true;
} else {
return false;
}
}
function Foo() {
if (!(this instanceof Foo)) {
return new Foo();
}
this.a = 0;
}Examples from the ESLint documentation.
consistent-return
eslint
export default [
{
rules: {
"consistent-return": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Require return statements to either always or never specify values
Disallow dangling underscores in identifiers
Disallow variable declarations from shadowing variables declared in the outer scope