8000 Fix cache not invalidated when files are ignored or restored by kovsu · Pull Request #18029 · prettier/prettier · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@kovsu
Copy link
Contributor
@kovsu kovsu commented Oct 10, 2025

Description

fix: #18016

After:

CleanShot.2025-10-10.at.16.51.22.mp4

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

@pkg-pr-new
Copy link
pkg-pr-new bot commented Oct 10, 2025

Open in StackBlitz

yarn add https://pkg.pr.new/prettier/prettier/@prettier/plugin-hermes@18029.tgz
yarn add https://pkg.pr.new/prettier/prettier/@prettier/plugin-oxc@18029.tgz
yarn add https://pkg.pr.new/prettier/prettier@18029.tgz

commit: 386bfb6

@netlify
Copy link
netlify bot commented Oct 10, 2025

Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 386bfb6
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/691a89a1d2b1df00081f5fb4
😎 Deploy Preview https://deploy-preview-18029--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@fisker
Copy link
Member
fisker commented Oct 11, 2025

I think the bug can be fixed by removing the initial value of shouldSetCache

8000
- let shouldSetCache = !isDifferent;
+ let shouldSetCache = false;

Will it work?

Also, we need tests for this case.

@kovsu
Copy link
Contributor Author
kovsu commented Oct 12, 2025

Will it work?

It seems don't work. If the file is ignored, it gets an early return.

  const isFileIgnored = isIgnored(filename);
  if (
    isFileIgnored &&
    (context.argv.debugCheck ||
      context.argv.write ||
      context.argv.check ||
      context.argv.listDifferent)
  ) {
    continue;
 }

@fisker fisker added this to the 3.7 milestone Oct 16, 2025
@fisker fisker self-requested a review October 16, 2025 20:19
@fisker
Copy link
Member
fisker commented Nov 16, 2025

Hello @kovsu , sorry for the long delay.

Do you know why we need removeFormatResultsCache? Shouldn't the file hash mismatch on the second run?

For example:

If I run prettier foo.js bar.js --no-single-quote --write, we will cache result for both foo.js and bar.js. Then I run prettier foo.js --single-quote --write, will we remove the cache for bar.js?

This really doesn't make sense to me, since each command can even have a different cache location.

@fisker fisker modified the milestones: 3.7, 3.8 Nov 26, 2025
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.

[cache issue] Prettier does not recheck files which used to be in .prettierignore

2 participants

0