sonarjs/no-unenclosed-multiline-block
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-unenclosed-multiline-block": "error",
},
},
];Multiline blocks should be enclosed in curly braces
if (condition)
firstActionInBlock();
secondAction(); // Noncompliant; executed unconditionally
thirdAction();
if (condition) firstActionInBlock(); secondAction(); // Noncompliant; secondAction executed unconditionally
if (condition) firstActionInBlock(); // Noncompliant
secondAction(); // Executed unconditionally
if (condition); secondAction(); // Noncompliant; secondAction executed unconditionally
let str = undefined;
for (let i = 0; i < array.length; i++)
str = array[i];
doTheThing(str); // Noncompliant; executed only on last array elementif (condition) {
firstActionInBlock();
secondAction();
}
thirdAction();
let str = undefined;
for (let i = 0; i < array.length; i++) {
str = array[i];
doTheThing(str);
}Examples from the ESLint documentation.
sonarjs/no-unenclosed-multiline-block
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-unenclosed-multiline-block": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
"undefined" should not be passed as the value of optional parameters
JSX list components keys should match up between renders
Promise rejections should not be caught by "try" blocks
Errors should not be created without being thrown