Rule Change: max-statements should count statements in switch cases and braceless bodies
Author: xbinaryxCreated Sep 17, 2026Updated Sep 17, 2026
Labelsenhancementruleaccepted
What rule do you want to change?
max-statements
What change do you want to make?
Generate more warnings
How do you think the change should be implemented?
A new default behavior
Example code
/* eslint max-statements: ["error", 1] */
function withBraces() {
if (a) { b(); }
}
function withoutBraces() {
if (a) b();
}
function withSwitch(x) {
switch (x) {
case 1:
a();
b();
c();
break;
}
}What does the rule currently do for this code?
Only withBraces is reported. The same two statements without braces, and the statements in withSwitch, are not counted at all.
What will the rule do after it's changed?
Statements are counted whether or not they are wrapped in a block, so all three functions are reported.
Participation
- I am willing to submit a pull request to implement this change.
AI acknowledgment
- I did not use AI to generate this issue report.
- (If the above is not checked) I have reviewed the AI-generated content before submitting.
Additional comments
No response
Source: eslint/eslint