Skip to content

Respect prettier-ignore comments before formatting ranges - #20194

Open
davidscottpope-gif wants to merge 1 commit into
prettier:mainfrom
davidscottpope-gif:fix-range-prettier-ignore
Open

davidscottpope-gif wants to merge 1 commit into
prettier:mainfrom
davidscottpope-gif:fix-range-prettier-ignore

Conversation

@davidscottpope-gif

Copy link
Copy Markdown

Description

Fixes #20164.

Range formatting reparses only the selected source text. When a prettier-ignore comment is immediately before the selected statement, it was left out of that text and the statement was formatted anyway.

Attach comments before selecting the range, keep ignored source elements intact when the selection falls inside them, and include their leading comments in the text being reparsed. Ordinary comments still allow formatting, and nonignored statements within the selected range are still formatted.

Adds snapshots covering line/block ignore comments, nested ignored statements, selections inside ignored functions, surrounding statements, and a range containing both ignored and nonignored statements. Adds cursor-offset and CRLF tests.

Testing on Linux with Node 22.23.3:

  • New fixture: 91 tests and 7 snapshots passed.
  • Unit and range-related suite: 1,476 tests and 353 snapshots passed.
  • JavaScript/TypeScript/Flow format suites: 29,104 tests and 8,341 snapshots passed.
  • Targeted cursor/debug API integration tests: 8 passed.
  • Typecheck, modified-code ESLint, fixture lint, and formatting checks passed.

The full integration suite, macOS, and production standalone/browser tests were not run to completion.

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.
  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

AI assistance was used to investigate the bug, write the patch and tests, and prepare this description. There are no API or CLI changes. The changelog filename and PR-number placeholder will be updated after this PR is opened.

@agentscanapp

agentscanapp Bot commented Sep 30, 2026

Copy link
Copy Markdown

Automation signals

Activity patterns show signs of automation.

View full analysis →

Report this account →

Evidence
  • Severe fork surge: 27 repositories forked in rapid succession (within 24 hours)
  • Rapid PRs to repository: 4 PRs opened to jaywcjlove/awesome-mac within 10s intervals

Last 4 PRs:

This is an automated analysis by AgentScan

@netlify

netlify Bot commented Sep 30, 2026

Copy link
Copy Markdown

✅ Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit bd7754c
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/6abd842c74c33400076f6e99
😎 Deploy Preview https://deploy-preview-20194--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Range formatting ignores a // prettier-ignore comment just before the range

1 participant