Skip to content

Conversation

@fyc09
Copy link
Contributor

@fyc09 fyc09 commented Oct 14, 2024

Description

Fix bug in #13008. Added a check to determine whether the YAML ignore comment is at the beginning of the file.

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.

Try the playground for this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 17, 2024

Open in StackBlitz

yarn add https://pkg.pr.new/prettier/prettier/@prettier/[email protected]
yarn add https://pkg.pr.new/prettier/prettier/@prettier/[email protected]
yarn add https://pkg.pr.new/prettier/[email protected]

commit: 76e893d

@fyc09
Copy link
Contributor Author

fyc09 commented Dec 17, 2024

Can anyone review it?

@fyc09
Copy link
Contributor Author

fyc09 commented Dec 25, 2024

Can anyone review it?

@netlify
Copy link

netlify bot commented Feb 25, 2025

Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 76e893d
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/68af1c8ec181f40008b5ee5d
😎 Deploy Preview https://deploy-preview-16756--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.

(parent) =>
hasLeadingComments(parent.node) &&
isPrettierIgnore(parent.node.leadingComments.at(-1)),
))
Copy link
Member

Choose a reason for hiding this comment

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

We are ignoring mappingItem separately, so the parent is not correctly ignored.

For example, spacing is not preserved.

Prettier pr-16756
Playground link

--parser yaml

Input:

# prettier-ignore
abc:     123




def:     456

Output:

# prettier-ignore
abc:     123

def: 456

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But in this way, I can't ignore the first item in an object separately.

Copy link
Member

Choose a reason for hiding this comment

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

I'll try to understand the original issue better.

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.

2 participants