-
-
Notifications
You must be signed in to change notification settings - Fork 899
Labels
A-linterArea - LinterArea - Linter
Description
What version of Oxlint are you using?
latest
What command did you run?
oxlint
What does your .oxlintrc.json config file look like?
What happened?
A nested if/else if with:
- if multiline
- else if single line
will never pass curly rule.
while (state.pos < max) {
if (dividerPosition) {
if (
state.src.charCodeAt(state.pos) === 125 /* } */ &&
state.src.charCodeAt(state.pos - 1) !== 92 /* \ */
) {
closePos = state.pos;
break;
}
} else if (
state.src.charCodeAt(state.pos) === 58 /* : */ &&
state.src.charCodeAt(state.pos - 1) !== 92 /* \ */
) {
dividerPosition = state.pos;
}
state.pos++;
}
multi-or-nest will suggest the else if removing the braces.
while (state.pos < max) {
if (dividerPosition) {
if (
state.src.charCodeAt(state.pos) === 125 /* } */ &&
state.src.charCodeAt(state.pos - 1) !== 92 /* \ */
) {
closePos = state.pos;
break;
}
} else if (
state.src.charCodeAt(state.pos) === 58 /* : */ &&
state.src.charCodeAt(state.pos - 1) !== 92 /* \ */
)
dividerPosition = state.pos;
state.pos++;
}The consistent will suggest adding the braces.
In short, case 1 is a false positive which curly rule should recognize the brance is necessary and not try to auto fix by removing braces.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-linterArea - LinterArea - Linter
{ // ... "rules": { "curly": ["warn", "multi-or-nest", "consistent"], } }