Below is a summary of the discussion from this week’s JavaScript JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser. https://www.javascript.com/. chat (agenda, Slack transcript).
Have a topic for discussion for the next meeting? Leave a suggested edit on next week’s agenda.
Agenda Item: Coding standards
Slack Conversation
We recapitulated the modifications to the JavaScript coding standards we agreed on during the previous meeting:
- Remove: Whitespace exceptions for object and array literal member access.
- Remove: Enforcement of Yoda conditional.
- Remove: Strict equality exception for “== null”.
- Change: New standard for multi-line conditions
- 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.
- New: ES2015: Prefer “const” variable assignment, then “let”, never “var”.
- New: Adopt Gutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ camel-case clarifications.
- New: Adopt dangling comma enforcement.
- No change: Multi-line comments.
- Provide presets for ES5-only and ESnext code.
While we agreed last week on multiline/single line comments separation, it was argued that:
- Converting comment styles is not easy (moving from single to multiline as we type).
//
comments are easier to deal with when debugging.- All IDEs don’t allow configuring this rule (multi/single line comment difference).
We agreed on the following rules for comments:
/**
is to be used for JSDoc./*
is to be used for intra-line comments.//
is to be used in all other instances.
Actionable items
- Compile a formal proposal for all the JavaScript Coding Standard changes into a Make/Core Core is the set of software required to run WordPress. The Core Development Team builds WordPress. post. @aduth
- Update the ESlint Preset package Pull Request in Gutenberg: https://github.com/WordPress/gutenberg/pull/7965 @aduth @gziolo
Agenda Item: Source Maps
Slack Conversation
While we splitted Gutenberg Code Base into reusable packages, we updated our build scripts to rely on “transpired” code in our application code which means it’s harder to debug because browsers don’t have the source maps correctly mapped to the original source files.
Potential solutions discussed
- Use untranspiled code when building Gutenberg itself (cons: we should be the first consumers of our packages).
- Source maps per package used by webpack to generate other source maps.
Actionable items
The best solution is not clear yet, we’re going to do some exploration to see what’s the best path forward. @youknowriad @gziolo
Open floor
Packages
Some new packages are ready to be released and should be published to npm
soon. We still need to figure out the best option to support 2FA when publishing a big number of packages at the same time.
Questions
How to lazy-load WP scripts/styles given their handle names? /wp-admin/load-scripts.php
and /wp-admin/load-styles.php
only work for WordPress default scripts/styles and don’t support dependencies discovery? There’s no alternative at the moment, work must be done to add these features or propose an alternative endpoint for that.