Standardize npm script naming in the Gutenberg project

This is an announcement to all contributors to the GutenbergGutenberg 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. project.

The Gutenberg project has a number of npm scripts defined in the main package.json used for development purposes or with Continues Integration. The naming was standardized to make understanding each script’s role easier and avoid confusion over conventions used when new scripts need to be added.

To standardize script naming, scriptlint tool was used to drive the process.

New start script

There were test and dev scripts originally defined. To complement that start script got added that acts as an alias for dev script.

Use namespace

Using namespaced script names improves readability and makes the intent more obvious. Namespaces are used to group related scripts, and a colon is used to separate namespaces.

Based on this rule, most of the scripts were renamed to use namespaces. Here are some examples:

  • lint-css to lint:css
  • test-e2e to test:e2e
  • changelog to other:changelog

Alphabetic order

Sorting script names alphabetically makes it easier to find a particular script. The pre* / post* hooksHooks In WordPress theme and development, hooks are functions that can be applied to an action or a Filter in WordPress. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same. are exceptionally grouped by caller script:

  "lint:md:docs": "wp-scripts lint-md-docs",
  "prelint:php": "wp-env run composer \"install --no-interaction\"",
  "lint:php": "wp-env run composer run-script lint"

Unify parallel commands

The way of parallelizing commands was a mixture of connecting them with & and npm-run-all package, but scripts were unified to use npm-run-all as possible.

A list of new scripts can be found at this link.

For more info, see #19949 and #42368.

Props to @mkaz for the initial suggestion, to @gziolo, @zieladam, and @mamaduka for reviewing.