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

Scripts: Add .prettierignore, use in format script #30844

Merged
merged 9 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why this was necessary? There's JavaScript there that seems like it should be formatted. I'll create a PR to remove this and see what happens.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some test plugins with JS code that not necessarily are compatible with the linting rules established for Gutenberg plugin. Feel free to fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying in #62572.

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