Javascript Chat Summary – July 24th

Below is a summary of the discussion from this week’s JavaScript chat (agenda, Slack transcript).

Have a topic for discussion for the next meeting? Leave a suggested edit on next week’s agenda.

Agenda Item: Administrative

Slack Conversation

It was raised that listing the attendees of a chat in the summary takes unnecessary time from the volunteers who take notes. We decided to no longer do it.

Agenda Item: JS coding standards

Slack Conversation

This agenda item focused around normalizing JS coding standards between WordPress core and Gutenberg. The overall consensus was that coding standards we decide on should be enforceable through ESlint. We agreed on the following decisions:

  • For multiline comments, we will stick to the current core standards. Aside from some personal preferences, no one raised a strong need to change them.
  • We’ll remove all spacing exceptions from the JS standards on spacing.
  • Yoda conditions will no longer be enforced for JS.
  • We won’t allow any exceptions for strict equality. The current exceptions in the core JS standards will be removed.
  • For multiline conditions we’ll enforce three rules (proposed by @youknowriad):
    • If the condition is short enough to fit in a line, just use a single line
    • If not, one condition per line separated from the opening/closing parenthesis
    • the operator position at the end
  • For multiline conditions we’ll remove the indentation clause from the standards.
  • The Gutenberg naming conventions will be added to the standards. See:
  • CSS naming conventions also need to be normalized with core. This should be addressed separately.
  • We’ll start enforcing trailing comma’s.
  • With regard to variable declarations at the top of each function: `var` declarations should always be at the top, `let` and `const` shouldn’t. This is because `var` is hoisted, the others aren’t.
  • ES5 (non-transpiled) code should still be able to meet standards. We decided to have two rulesets, one baseset and one set specifically for ESnext (transpiled) code. It should be possible to disable the ESnext ruleset for legacy code. This will also be very useful for plugin and theme authors.
  • The ESnext specific standards still need some more exploration. These will be explored in a trac ticket or Github issue / PR. There is already a related PR here: https://github.com/WordPress/gutenberg/pull/7965
  • We agreed the current JS in core should be updated to adhere as much as possible to the WordPress JS coding standards. This is also in line with the most recent practices regarding coding standards. We decided to at least fix what can be autofixed.

Agenda Item: deprecations

Slack Conversation

@jorbin created a PR on the deprecated package. The idea is that whenever a deprecated feature is encountered, an action is fired. This is necessary to log deprecation notices and to be able to easily log these deprecations or for plugins to handle and do something when something deprecated is encountered.

The approach was received positively. @jorbin will process the code review so we can merge.