Skip to content

[CONFIG] Add PostCSS support to prettier css overrides#349

Open
spadilha wants to merge 2 commits intomainfrom
config/add-pcss-prettier-support
Open

[CONFIG] Add PostCSS support to prettier css overrides#349
spadilha wants to merge 2 commits intomainfrom
config/add-pcss-prettier-support

Conversation

@spadilha
Copy link
Copy Markdown
Contributor

@spadilha spadilha commented Apr 9, 2026

What does this do/fix?

This pull request updates the project’s Prettier configuration to properly support PostCSS files. It extends the WordPress Prettier config and adds .pcss to the files that should use CSS formatting rules, ensuring consistent styling across all CSS-related files.

This builds on the Prettier setup introduced in #276. The default @wordpress/prettier-config does not include .pcss in its CSS overrides, so PostCSS files were being formatted with JavaScript rules. This change addresses that gap at the project level.

Prettier configuration improvements:

  • .prettierrc.js: Now extends the WordPress Prettier config and adds .pcss to the list of files receiving CSS formatting rules, so PostCSS files are formatted consistently with other CSS files.

QA

Pull request checklist

  • I've added a changelog entry for these changes.

@spadilha spadilha marked this pull request as ready for review April 9, 2026 18:54
@spadilha spadilha requested review from GeoffDusome, Copilot and dpellenwood and removed request for Copilot April 9, 2026 18:54
@spadilha spadilha changed the title Add pcss support to prettier css overrides [CONFIG] Add PostCSS support to prettier css overrides Apr 9, 2026
@spadilha spadilha self-assigned this Apr 9, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the project’s Prettier configuration so PostCSS (.pcss) files receive the same CSS-specific formatting overrides as other stylesheet files, and documents the change in the changelog.

Changes:

  • Updated .prettierrc.js to extend @wordpress/prettier-config and include .pcss in the CSS override file matching.
  • Added a 2026.04 changelog entry noting the Prettier .pcss support update.
  • Normalized indentation/trailing whitespace for a few existing changelog bullets.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.prettierrc.js Extends the WordPress Prettier config and modifies the CSS override to include .pcss.
CHANGELOG.md Adds a release note for the Prettier config update and cleans up a few formatting inconsistencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .prettierrc.js
Comment thread .prettierrc.js
@GeoffDusome
Copy link
Copy Markdown
Contributor

I'm going to let @dpellenwood have the final say here. Personally, I haven't had this issue, but it's possible I've configured my iDE to do this and haven't needed specific project configuration to do so. If this is indeed happening, I agree with what Copilot is saying here in terms of just making sure we're overriding the correct thing by checking against stuff. Entirely possible @wordpress/prettier-config changes and this whole thing breaks (in it's current state).

@dpellenwood
Copy link
Copy Markdown
Collaborator

@spadilha , I've not experienced this issue.

By default prettier (via npm run format in ModernPress) uses WP's config, which only applies prettier to JS & Config based files. It doesn't run at all for css/pcss/sass files.

If you run npm run format locally on a ModernPress site, you'll see the output lists which files are processed and pcss files are not included.

What scenarios are you seeing where the WP Scripts format command is processing style files?

@spadilha
Copy link
Copy Markdown
Contributor Author

@dpellenwood my local setup uses Prettier as the default formatter for style files. I like it because it removes parenSpacing, switches single quotes to double quotes, cleans up spacing, and most importantly fixes indentation. Stylelint does not handle those things. How are you usually formatting CSS files?

I did not run into this in the GUQ or Mediavine projects because they do not have a .prettierrc.js, so I assume they were not using @wordpress/prettier-config.

In ModernPress, when I format a .pcss file locally with Prettier, it gets JS style formatting, which is the opposite of what I need. .scss and .css format correctly, so it looks like the WordPress config applies CSS rules to css, sass, and scss, but not pcss.

@GeoffDusome I changed the approach and now I am just adding a dedicated override for .pcss.

This got me thinking, has no one else run into this with the WordPress Prettier config and .pcss files? Are people generally not using Prettier for CSS formatting? If not, what are they using instead to handle indentation and other formatting that Stylelint does not cover?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants