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.
nursery/noMixedReturns
nursery · since 2.6.10
{
"linter": {
"rules": {
"nursery": {
"noMixedReturns": "error"
}
}
}
}Require return statements to either always or never specify values
Disallow dangling underscores in identifiers
Enforce getter and setter pairs in objects and classes
Disallow unmodified loop conditions