Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add format-js to scripts README for Prettier support #19766

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ _Example:_
"build": "wp-scripts build",
"check-engines": "wp-scripts check-engines",
"check-licenses": "wp-scripts check-licenses",
"format:js": "wp-scripts format-js",
"lint:css": "wp-scripts lint-style",
"lint:js": "wp-scripts lint-js",
"lint:md": "wp-scripts lint-md",
Expand Down Expand Up @@ -168,6 +169,31 @@ In the `wp-env` config block, each entry can be configured like so:
- `test-php`: Runs your plugin's PHPUnit tests. You will need to have an appropriately configured `phpunit.xml.dist` file.
- `docker-run`: For more advanced debugging, contributors may sometimes need to run commands in the Docker containers. This is the equivalent of running `docker-compose run` within the WordPress directory.

### `format-js`
mkaz marked this conversation as resolved.
Show resolved Hide resolved

Formats JavaScript files to the expected coding guidelines.

_Example:_

```json
{
"scripts": {
"format:js": "wp-scripts format-js"
ntwb marked this conversation as resolved.
Show resolved Hide resolved
}
}
```

This is how you execute the script with presented setup:

* `npm run format:js src/` - formats JavaScript files in src/ directory.

When you run commands similar to example above, you can provide a file, a directory, or `glob` syntax or any combination of them. See [more examples](https://eslint.org/docs/user-guide/command-line-interface).

By default, files specified in `.eslintignore` are ignored.

#### Advanced information

It uses [wp-prettier](https://github.com/automattic/wp-prettier) a [Prettier](https://prettier.io/) fork that follows the WordPress code conventions.

### `lint-js`

Expand Down