no-empty
eslint
SuggestionRecommended
eslint.config.js
export default [
{
rules: {
"no-empty": "error",
},
},
];if (foo) {
}
while (foo) {
}
switch(foo) {
}
try {
doSomething();
} catch(ex) {
} finally {
}if (foo) {
// empty
}
while (foo) {
/* empty */
}
switch(foo) {
/* empty */
}
try {
doSomething();
} catch (ex) {
// continue regardless of error
}
try {
doSomething();
} finally {
/* continue regardless of error */
}Examples from the ESLint documentation.
no-empty
eslint
export default [
{
rules: {
"no-empty": "error",
},
},
];no-empty
eslint plugin · restriction
{
"rules": {
"no-empty": "error"
}
}suspicious/noEmptyBlockStatements
suspicious · since 1.3.0
{
"linter": {
"rules": {
"suspicious": {
"noEmptyBlockStatements": "error"
}
}
}
}Disallow confusing multiline expressions
Disallow the use of undeclared variables unless mentioned in /*global */ comments
Require spread operators instead of .apply()
Disallow variable assignments when the value is not used
Disallow losing originally caught error when re-throwing custom errors