no-dupe-else-if
eslint
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"no-dupe-else-if": "error",
},
},
];if (isSomething(x)) {
foo();
} else if (isSomething(x)) {
bar();
}
if (a) {
foo();
} else if (b) {
bar();
} else if (c && d) {
baz();
} else if (c && d) {
quux();
} else {
quuux();
}
if (n === 1) {
foo();
} else if (n === 2) {
bar();
} else if (n === 3) {
baz();
} else if (n === 2) {
quux();
} else if (n === 5) {
quuux();
}if (isSomething(x)) {
foo();
} else if (isSomethingElse(x)) {
bar();
}
if (a) {
foo();
} else if (b) {
bar();
} else if (c && d) {
baz();
} else if (c && e) {
quux();
} else {
quuux();
}
if (n === 1) {
foo();
} else if (n === 2) {
bar();
} else if (n === 3) {
baz();
} else if (n === 4) {
quux();
} else if (n === 5) {
quuux();
}if (a) {
if (a) {
foo();
}
}
if (a) {
foo();
} else {
if (a) {
bar();
}
}Examples from the ESLint documentation.
no-dupe-else-if
eslint
export default [
{
rules: {
"no-dupe-else-if": "error",
},
},
];no-dupe-else-if
eslint plugin · correctness
{
"rules": {
"no-dupe-else-if": "error"
}
}suspicious/noDuplicateElseIf
suspicious · since 1.6.2
{
"linter": {
"rules": {
"suspicious": {
"noDuplicateElseIf": "error"
}
}
}
}Enforce for loop update clause moving the counter in the right direction
Disallow \8 and \9 escape sequences in string literals
Disallow assigning to imported bindings
Disallow use of optional chaining in contexts where the undefined value is not allowed
Disallow returning values from setters