sonarjs/no-function-declaration-in-block
eslint-plugin-sonarjs
No autofix
eslint.config.js
export default [
{
rules: {
"sonarjs/no-function-declaration-in-block": "error",
},
},
];Function declarations should not be made within blocks
if (x) {
function foo() {} //foo is hoisted in Chrome, Firefox and Safari, but not in Edge.
}if (x) {
const foo = function() {}
}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-function-declaration-in-block
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-function-declaration-in-block": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.