sonarjs/function-return-type
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/function-return-type": "error",
},
},
];Functions should always return the same type
function foo(a) { // Noncompliant
if (a === 1) {
return true;
}
return 3;
}function foo(a) {
if (a === 1) {
return true;
}
return false;
}Examples from the ESLint documentation.
sonarjs/function-return-type
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/function-return-type": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Functions should not be defined inside loops
Future reserved words should not be used as identifiers
A "for" loop update clause should move the counter in the right direction
Generators should explicitly "yield" a value