Skip to content

format-if-else ​

Check that conditional statements are properly formated

INFO

☑️ The predefined configuration "mslint:recommended" enables this rule.

Rule details ​

This rule checks that the consequents that are not enclosed in braces are placed on the same line as their condition.

Example of incorrect code for this rule:

maniascript
main() {
  if (A)
    A();
  else if (B)
    B();
  else
    C();
}

Example of correct code for this rule:

maniascript
main() {
  if (A) A();
  else if (B) B();
  else if (
    C
  ) C();
  else if (D) {
    D();
  }
  else E();
}

Resources ​