Repository navigation
fix(parser/yaml): lex directives - #10484
Conversation
|
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
ac477d0 to
0b03f06
Compare
ematipico
left a comment
There was a problem hiding this comment.
Can you please add new cases in the parser too? We shouldn't rely on the prettier tests; we need to build our own infra too.
e18fdee to
c722e01
Compare
WalkthroughThis pull request adds YAML directive lexing support to Biome's YAML parser. The lexer now recognises directives starting with 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/biome_yaml_parser/src/lexer/mod.rs`:
- Around line 552-583: Add rustdoc comments to the three new directive helper
methods to explain their purpose and behavior: document is_at_directive to state
it detects a '%' directive at column zero by checking current_coordinate and
current_byte, document consume_directive to describe it asserts the '%' start,
consumes until a break or trailing trivia and returns a LexToken with
DIRECTIVE_LITERAL, and document is_at_directive_trailing_trivia to explain the
trailing-trivia detection logic (handling '#' comment start, leading blanks, and
spaces followed by '#' or break). Use the function names is_at_directive,
consume_directive, and is_at_directive_trailing_trivia in the comments so
readers can find the implementations easily.
In `@crates/biome_yaml_parser/tests/yaml_test_suite/ok/document/directives.yaml`:
- Line 5: The test fixture containing the literal "%YAML1.2" is currently in the
ok/ suite but the lexer tokenises it as DIRECTIVE_LITERAL (no diagnostics);
either move this fixture into the err/ suite if you want to enforce the YAML 1.2
space form ("%YAML 1.2"), or keep it in ok/ and update directives.yaml to add a
brief comment explaining that the lexer permissively accepts "%YAML1.2" (and
leave directives.yaml.snap unchanged since it contains only AST/CST). Ensure you
update the test location or add the inline comment in the same fixture so
expectations match the lexer behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: df72e963-546e-4aeb-8d0c-b2422a9ca85f
⛔ Files ignored due to path filters (6)
crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-2-24-global-tags.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-5-9-directive-indicator.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-6-13-reserved-directives.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-6-14-yaml-directive.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-9-5-directives-documents.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_parser/tests/yaml_test_suite/ok/document/directives.yaml.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (2)
crates/biome_yaml_parser/src/lexer/mod.rscrates/biome_yaml_parser/tests/yaml_test_suite/ok/document/directives.yaml
Summary
Implemented the lexer to support YAML directives before the DIRECTIVE_END marker (
---).For example:
Test Plan
Added lexer unit tests.
Docs
N/A