Skip to content

feat(format/yaml): normalize scalar quotes - #11054

Merged
dyc3 merged 3 commits into
dyc3/yaml-fmt-explicit-entriesfrom
dyc3/yaml-fmt-quote-style
Jul 28, 2026
Merged

feat(format/yaml): normalize scalar quotes#11054
dyc3 merged 3 commits into
dyc3/yaml-fmt-explicit-entriesfrom
dyc3/yaml-fmt-quote-style

Conversation

@dyc3

@dyc3 dyc3 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the quote style formatter option

implemented by fable 5

Test Plan

updated snapshots

Docs

@changeset-bot

changeset-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a5b9cdb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

✅ Organic activity

No automation signals detected in the analyzed events.

View full analysis →

This is an automated analysis by AgentScan

@github-actions github-actions Bot added A-Formatter Area: formatter L-Yaml Language: Yaml labels Jul 23, 2026
@dyc3 dyc3 changed the title dyc3/yaml fmt quote style feat(format/yaml): normalize scalar quotes Jul 23, 2026
@dyc3
dyc3 force-pushed the dyc3/yaml-fmt-quote-style branch from 0d9449f to fb09118 Compare July 25, 2026 18:53
@dyc3
dyc3 marked this pull request as ready for review July 25, 2026 18:56
/// equivalent, so text with any other escape keeps its double quotes; a
/// backslash in a single quoted scalar is content that double quotes would
/// misread as an escape, so such text keeps its single quotes
fn normalize_quotes(value: &str, quote_style: QuoteStyle) -> Cow<'_, str> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be great to have unit tests. Also, JS does this already, and its logic is battle-tested; we shouldn't re-invent the wheel, so maybe we should look at unifying the logic. Maybe with a new trait, like Denis created for CSS name casing.

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.

I'll add tests, but I think the trait would be good follow up work, after this PR. Seems like a larger refactor to me.

@dyc3
dyc3 force-pushed the dyc3/yaml-fmt-quote-style branch from fb09118 to e425f8c Compare July 26, 2026 19:33
@dyc3
dyc3 force-pushed the dyc3/yaml-fmt-quote-style branch from e425f8c to a5b9cdb Compare July 26, 2026 21:00
@dyc3
dyc3 requested a review from ematipico July 27, 2026 18:35
@dyc3
dyc3 merged commit 65d9024 into main Jul 28, 2026
27 checks passed
@dyc3
dyc3 deleted the dyc3/yaml-fmt-quote-style branch July 28, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter L-Yaml Language: Yaml

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants