Problem/Motivation

Since Drupal core adopted Prettier formatting for JavaScript - see Use Prettier for formatting core JavaScript all the way back in Drupal 8.7 - the Stroustrup style brace rule have been replaced 1TBS (One True Brace Style) one.

Stroustrup style brace

if (condition1 || condition2) {
  action1();
}
else if (condition3 && condition4) {
  action2();
}
else {
  defaultAction();
}

1TBS

if (condition1 || condition2) {
  action1();
} else if (condition3 && condition4) {
  action2();
} else {
  defaultAction();
}

The JavaScript coding standard documentation page still shows the Stroustrup style braces.

Benefits

Drupal core has already adopted this change, as seen in the issue - Use Prettier for formatting core JavaScript.

Three supporters required

  1. https://www.drupal.org/u/grandmaglassesropeman (2018-06-12)
  2. https://www.drupal.org/u/tedbow (2018-08-08)
  3. https://www.drupal.org/u/lauriii (2018-08-08)

Proposed changes

Make the default brace-style rule examples on the documentation site to align with core's 1TBS.

Particularly on the JavaScript coding standards page examples related to if/else and try/catch blocks.

Comments

tsega created an issue.