Skip to content

feat(formatter/yaml): setup stub implementation#8000

Merged
siketyan merged 5 commits intobiomejs:nextfrom
siketyan:feat/yaml-formatter
Nov 6, 2025
Merged

feat(formatter/yaml): setup stub implementation#8000
siketyan merged 5 commits intobiomejs:nextfrom
siketyan:feat/yaml-formatter

Conversation

@siketyan
Copy link
Copy Markdown
Member

@siketyan siketyan commented Nov 5, 2025

Summary

Setup the formatter crate for the YAML language. It doesn't do anything, just printing the code as-is.

Test Plan

Added a smoke test.

Docs

N/A

@siketyan siketyan self-assigned this Nov 5, 2025
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 5, 2025

⚠️ No Changeset found

Latest commit: 7dd508b

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 github-actions Bot added A-Parser Area: parser A-Formatter Area: formatter A-Tooling Area: internal tools labels Nov 5, 2025
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Nov 5, 2025

CodSpeed Performance Report

Merging #8000 will not alter performance

Comparing siketyan:feat/yaml-formatter (7dd508b) with next (0b28f5f)

Summary

✅ 53 untouched
⏩ 85 skipped1

Footnotes

  1. 85 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@siketyan siketyan changed the base branch from main to next November 5, 2025 13:08
@siketyan siketyan marked this pull request as ready for review November 5, 2025 13:09
@siketyan siketyan requested review from a team November 5, 2025 13:09
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 5, 2025

Walkthrough

Adds a new YAML formatter crate (crates/biome_yaml_formatter) and wires YAML into the formatting pipeline. Introduces YamlFormatContext and YamlFormatOptions, YAML comment handling/suppression, verbatim formatting paths, many generated FormatRule/AsFormat/IntoFormat implementations for YAML AST nodes, crate-local auxiliary/list/bogus modules, and token formatting glue in the crate root. Also updated codegen (xtask) to support a YAML dialect and re-exported YamlFileSource from biome_yaml_syntax. A small unrelated tweak removed an #[expect(dead_code)] annotation.

Possibly related PRs

Suggested reviewers

  • dyc3
  • ematipico

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: setting up a stub YAML formatter implementation that prints code as-is.
Description check ✅ Passed The description is relevant and explains the purpose (stub formatter for YAML), test coverage (smoke test added), and acknowledges no docs changes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3cadfb and 7dd508b.

📒 Files selected for processing (1)
  • crates/biome_yaml_formatter/src/comments.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_yaml_formatter/src/comments.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_css_formatter)

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (12)
crates/biome_yaml_formatter/src/yaml/auxiliary/document.rs (1)

7-9: Stub implementation – replace with real formatting later.

This verbatim pass-through is fine for initial scaffolding, but you'll want to implement proper YAML document formatting with biome_formatter utilities in a follow-up.

Based on learnings.

crates/biome_yaml_formatter/src/yaml/auxiliary/block_sequence_entry.rs (1)

7-9: Stub implementation – replace with real formatting later.

The verbatim approach is acceptable for scaffolding, but implement proper block sequence entry formatting in a subsequent change.

Based on learnings.

crates/biome_yaml_formatter/src/yaml/auxiliary/flow_json_node.rs (1)

7-9: Stub implementation – replace with real formatting later.

Verbatim formatting serves as a placeholder. Implement proper flow JSON node formatting using biome_formatter utilities in follow-up work.

Based on learnings.

crates/biome_yaml_formatter/src/yaml/auxiliary/double_quoted_scalar.rs (1)

7-9: Stub implementation – replace with real formatting later.

Currently passes through as-is. Future work should handle double-quoted scalar formatting properly (escape sequences, line breaking, etc.) using biome_formatter utilities.

Based on learnings.

crates/biome_yaml_formatter/src/yaml/auxiliary/block_strip_indicator.rs (1)

7-13: Stub implementation – replace with real formatting later.

Verbatim pass-through is fine for now. Eventually implement proper block strip indicator formatting with biome_formatter utilities.

Based on learnings.

crates/biome_yaml_formatter/src/yaml/auxiliary/properties_tag_first.rs (1)

7-9: Stub implementation acknowledged.

This uses verbatim formatting as expected for the initial setup. Replace with proper formatting logic using biome_formatter utilities when implementing real YAML formatting behaviour.

Based on learnings.

crates/biome_yaml_formatter/src/yaml/auxiliary/indentation_indicator.rs (1)

7-13: Stub implementation acknowledged.

This uses verbatim formatting as expected for the initial setup. Replace with proper formatting logic using biome_formatter utilities when implementing real YAML formatting behaviour.

Based on learnings.

crates/biome_yaml_formatter/src/yaml/auxiliary/block_map_explicit_entry.rs (1)

7-13: Stub implementation acknowledged.

This uses verbatim formatting as expected for the initial setup. Replace with proper formatting logic using biome_formatter utilities when implementing real YAML formatting behaviour.

Based on learnings.

crates/biome_yaml_formatter/src/yaml/auxiliary/tag_property.rs (1)

7-9: Stub implementation acknowledged.

This uses verbatim formatting as expected for the initial setup. Replace with proper formatting logic using biome_formatter utilities when implementing real YAML formatting behaviour.

Based on learnings.

crates/biome_yaml_formatter/src/yaml/lists/flow_sequence_entry_list.rs (1)

7-9: Inconsistent list formatting pattern.

Unlike directive_list.rs (Line 8) which implements proper list formatting via f.join().entries(node.iter().formatted()).finish(), this list formatter uses verbatim. For consistency, consider using the join/entries pattern here as well.

crates/biome_yaml_formatter/src/yaml/auxiliary/block_content.rs (1)

7-9: Stub implementation acknowledged.

This uses verbatim formatting as expected for the initial setup. Replace with proper formatting logic using biome_formatter utilities when implementing real YAML formatting behaviour.

Based on learnings.

crates/biome_yaml_formatter/src/yaml/auxiliary/block_sequence.rs (1)

7-9: Stub implementation acknowledged.

This uses verbatim formatting as expected for the initial setup. Replace with proper formatting logic using biome_formatter utilities when implementing real YAML formatting behaviour.

Based on learnings.

Comment thread crates/biome_yaml_formatter/src/comments.rs Outdated
Comment on lines +45 to +47
fn source_map(&self) -> Option<&TransformSourceMap> {
None
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Return the stored source map.

You stash the TransformSourceMap in Line 33, but Line 46 always returns None, so downstream consumers never see it. Please surface the stored map.

     fn source_map(&self) -> Option<&TransformSourceMap> {
-        None
+        self.source_map.as_ref()
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fn source_map(&self) -> Option<&TransformSourceMap> {
None
}
fn source_map(&self) -> Option<&TransformSourceMap> {
self.source_map.as_ref()
}
🤖 Prompt for AI Agents
In crates/biome_yaml_formatter/src/context.rs around lines 45 to 47, the
source_map() method currently always returns None even though a
TransformSourceMap was stored earlier (around line 33); change the method to
return a reference to the stored map (e.g., return self.source_map.as_ref()) so
downstream consumers receive the actual Option<&TransformSourceMap> instead of
None, keeping the signature the same.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread crates/biome_yaml_formatter/src/yaml/auxiliary/flow_mapping.rs
Comment thread crates/biome_yaml_formatter/src/yaml/lists/flow_map_entry_list.rs
@dyc3
Copy link
Copy Markdown
Contributor

dyc3 commented Nov 5, 2025

FWIW, having the formatter crate present can make working on the parser a bit more tedious. If you add new nodes or add/remove fields, and only run just gen-grammar yaml, the compiler will yell at you until you run just gen-formatter.

@l0ngvh
Copy link
Copy Markdown
Contributor

l0ngvh commented Nov 6, 2025

Personally I'm fine with that. I think a large portion of users only use YAML as config or translation files, which only concern simple lists/map. With this in place we can deliver YAML tooling to these users much sooner

Copy link
Copy Markdown
Contributor

@l0ngvh l0ngvh left a comment

Choose a reason for hiding this comment

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

Should we have a few snapshot tests to show that the formatter is running?

Comment thread crates/biome_yaml_formatter/src/comments.rs Outdated
@siketyan
Copy link
Copy Markdown
Member Author

siketyan commented Nov 6, 2025

@l0ngvh The current implementation only prints all tokens as-is, so we don't have anything to test yet. I'll definitely add some tests on adding format rules for simple elements!

@siketyan siketyan force-pushed the feat/yaml-formatter branch from d3cadfb to 7dd508b Compare November 6, 2025 02:18
@siketyan siketyan merged commit 96e2888 into biomejs:next Nov 6, 2025
26 checks passed
dyc3 pushed a commit that referenced this pull request Nov 8, 2025
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
@siketyan siketyan deleted the feat/yaml-formatter branch November 17, 2025 10:30
@coderabbitai coderabbitai Bot mentioned this pull request Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter A-Parser Area: parser A-Tooling Area: internal tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants