Skip to content

Respect .prettierignore when formatting local files - #1056

Merged
dejmedus merged 2 commits into
mainfrom
jb-prettier-ignore
Jan 16, 2026
Merged

dejmedus merged 2 commits into
mainfrom
jb-prettier-ignore

Conversation

@dejmedus

@dejmedus dejmedus commented Sep 16, 2025 •

Copy link
Copy Markdown
Contributor

What are you adding in this PR?

Previously, the extension used liquid prettier plugin to format all files regardless of whether it was ignored by a .prettierignore file in the workspace. Although we aren't able to respect.prettierignore in all environments (for instance in browser or remote filesystems) we can in nodePrettierFormat

This PR checks for a .prettierignore at the workspace root and does not format files that .getFileInfo determines should be ignored

demo
prettier-demo.mov

What did you learn?

  • Unlike other prettier config:
    • there is only one possible ignore file name
    • prettier looks for .prettierignore files at workspace root (though its being discussed)

Before you deploy

  • I included a minor bump changeset
  • My feature is backward compatible

@dejmedus dejmedus changed the title Respect .prettierignore file when possible Respect .prettierignore when formatting local files Sep 19, 2025
Previously, the extension used liquid prettier plugin
to format all files regardless of whether there was a
`.prettierignore` file in the workspace. Although
we are unable to respect `.prettierignore` in browsers
https://prettier.io/docs/en/browser or remote filesystems,
we can when we have access to both full prettier and
the vscode workspace

This commit checks for a `.prettierignore` at the
workspace root and does not format files that
`.getFileInfo` determines should be ignored
@@ -0,0 +1,74 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seemed okay to add a test here as src/*.spec.ts are excluded, but i'm happy to move or remove if preferred!

@dejmedus
dejmedus marked this pull request as ready for review December 20, 2025 01:45
@dejmedus
dejmedus requested a review from a team as a code owner December 20, 2025 01:45
@dejmedus
dejmedus merged commit 99755b7 into main Jan 16, 2026
12 checks passed
@dejmedus
dejmedus deleted the jb-prettier-ignore branch January 16, 2026 17:36
@tonystar

Copy link
Copy Markdown

Looking forward for this!

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.

.prettierignore file is ignored by the plugin

4 participants