Skip to content

Commit

Permalink
Scripts: Add .prettierignore, use in format script (#30844)
Browse files Browse the repository at this point in the history
* Scripts: Include YAML files in prettification

* Move create-block's Changelog entry to Enhancement

* Scripts: Add prettierignore, use in format script

* Run format script

* Revert "Run format script"

This reverts commit d4afc4d.

* Add root-level .prettierignore

* Remove unnecessary line from .prettierignore

* Add README note about .prettierignore

* Add Changelog entry
  • Loading branch information
ockham authored Apr 23, 2021
1 parent f4b3c72 commit 7e20698
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.cache
build
build-module
build-types
packages/block-serialization-spec-parser/parser.js
packages/e2e-tests/plugins
packages/react-native-editor/bundle
vendor
1 change: 1 addition & 0 deletions packages/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### New Features

- Include a Jest Reporter that formats test results for GitHub Actions annotations ([#31041](https://github.com/WordPress/gutenberg/pull/31041)).
- Have the `format` command ignore files listed in a `.prettierignore` file, add a fallback `.prettierignore` to the package ([30844](https://github.com/WordPress/gutenberg/pull/30844)).

### Breaking Changes

Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ This is how you execute the script with presented setup:

When you run commands similar to the `npm run format:src` example above, you can provide a file, a directory, or `glob` syntax or any combination of them.

By default, files located in `build`, `node_modules`, and `vendor` folders are ignored.
By default, files located in `build`, `node_modules`, and `vendor` folders are ignored. You can customize the list of ignored files and directories by adding them to a `.prettierignore` file in your project.

### `lint-js`

Expand Down
2 changes: 2 additions & 0 deletions packages/scripts/config/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
vendor
8 changes: 4 additions & 4 deletions packages/scripts/scripts/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ if ( ! hasPrettierConfig() ) {
];
}

// If `--ignore-path` is not explicitly specified, use the project's or global .eslintignore
// If `--ignore-path` is not explicitly specified, use the project's or global .prettierignore.
let ignorePath = getArgFromCLI( '--ignore-path' );
if ( ! ignorePath ) {
if ( hasProjectFile( '.eslintignore' ) ) {
ignorePath = fromProjectRoot( '.eslintignore' );
if ( hasProjectFile( '.prettierignore' ) ) {
ignorePath = fromProjectRoot( '.prettierignore' );
} else {
ignorePath = fromConfigRoot( '.eslintignore' );
ignorePath = fromConfigRoot( '.prettierignore' );
}
}
const ignoreArgs = [ '--ignore-path', ignorePath ];
Expand Down

0 comments on commit 7e20698

Please sign in to comment.