Skip to content

Commit 7e20698

Browse files
authored
Scripts: Add .prettierignore, use in format script (#30844)
* 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
1 parent f4b3c72 commit 7e20698

5 files changed

Lines changed: 16 additions & 5 deletions

File tree

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.cache
2+
build
3+
build-module
4+
build-types
5+
packages/block-serialization-spec-parser/parser.js
6+
packages/e2e-tests/plugins
7+
packages/react-native-editor/bundle
8+
vendor

packages/scripts/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### New Features
66

77
- Include a Jest Reporter that formats test results for GitHub Actions annotations ([#31041](https://github.com/WordPress/gutenberg/pull/31041)).
8+
- 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)).
89

910
### Breaking Changes
1011

packages/scripts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ This is how you execute the script with presented setup:
150150

151151
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.
152152

153-
By default, files located in `build`, `node_modules`, and `vendor` folders are ignored.
153+
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.
154154

155155
### `lint-js`
156156

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
vendor

packages/scripts/scripts/format.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ if ( ! hasPrettierConfig() ) {
7979
];
8080
}
8181

82-
// If `--ignore-path` is not explicitly specified, use the project's or global .eslintignore
82+
// If `--ignore-path` is not explicitly specified, use the project's or global .prettierignore.
8383
let ignorePath = getArgFromCLI( '--ignore-path' );
8484
if ( ! ignorePath ) {
85-
if ( hasProjectFile( '.eslintignore' ) ) {
86-
ignorePath = fromProjectRoot( '.eslintignore' );
85+
if ( hasProjectFile( '.prettierignore' ) ) {
86+
ignorePath = fromProjectRoot( '.prettierignore' );
8787
} else {
88-
ignorePath = fromConfigRoot( '.eslintignore' );
88+
ignorePath = fromConfigRoot( '.prettierignore' );
8989
}
9090
}
9191
const ignoreArgs = [ '--ignore-path', ignorePath ];

0 commit comments

Comments
 (0)