Create block: Add support for format:js
to ESNext template
#20335
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for
format:js
script to the block scaffolded when using the default ESNext template.It also runs this command during the scaffolding process. The reason for that is that we can't predict the length of inputs provided by users so we can't really format JavaScript file correctly for all cases. That's why the idea to format those files popped up. It ensures that users won't see any errors when running
npm run lint:js
in the scaffolded project. At the moment, when I runnpm ini @wordpress/block
, use default values and runnpm run lint:js
in the scaffolded folder, I see:How has this been tested?
$ npx wp-create-block $ cd esnext-example $ npm run lint:js $ npm run format:js
Types of changes
Enhancement
Checklist: