I try to find eslint rule to prevent writing if-else in one line style. What should I expect:
// Wrong
if() /* some code */
else /* some code */
// Correct
if() {
/* some code */
} else {
/* some code */
}
// But for if statement (without else) should be correct both
if() /* some code */
if() {
/* some code */
}
With the no-restricted-syntax rule you can disallow specific syntax.
Following rule should normally disallow the shorthand if statement.
no-restricted-syntax: ["error", "IfStatement > ExpressionStatement > AssignmentExpression"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With