-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: YAML.stringify spacing for multiline values #23510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Updated 5:41 PM PT - Oct 11th, 2025
❌ Your commit
🧪 To try this PR locally: bunx bun-pr 23510 That installs a local version of the PR into your bun-23510 --bun |
WalkthroughRefines YAML serialization formatting: unwraps property values once to determine whether a newline is needed, prints a colon followed by newline for complex/non-empty collections and a colon+space for inline primitives/empty collections, and updates tests/snapshots to reflect the new no-space-before-newline style. Changes
Possibly related PRs
Suggested reviewers
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (3)
🧰 Additional context used📓 Path-based instructions (13)test/**📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
Files:
test/**/*.{js,ts}📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
Files:
test/**/*.test.ts📄 CodeRabbit inference engine (test/CLAUDE.md)
Files:
test/regression/issue/**📄 CodeRabbit inference engine (test/CLAUDE.md)
Files:
test/**/*.test.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
test/js/**/*.{js,ts}📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
Files:
test/js/bun/**/*.{js,ts}📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)
Files:
test/js/**📄 CodeRabbit inference engine (test/CLAUDE.md)
Files:
test/js/bun/**📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.zig📄 CodeRabbit inference engine (.cursor/rules/javascriptcore-class.mdc)
Files:
src/{**/js_*.zig,bun.js/api/**/*.zig}📄 CodeRabbit inference engine (.cursor/rules/registering-bun-modules.mdc)
Files:
src/bun.js/**/*.zig📄 CodeRabbit inference engine (.cursor/rules/zig-javascriptcore-classes.mdc)
Files:
src/**/*.zig📄 CodeRabbit inference engine (CLAUDE.md)
Files:
⏰ 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). (1)
🔇 Additional comments (2)
Comment |
Fixed two issues with YAML.stringify output formatting: 1. Removed extra space after colon when value is on next line - Before: `key: \n value` - After: `key:\n value` 2. Keep empty arrays/objects inline instead of newline - Before: `arr: \n []` - After: `arr: []` The fix checks if a value is an empty array or object before deciding whether to put it on a newline. Empty collections stay inline with proper spacing, while non-empty collections go on the next line without a space after the colon. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
2c11778
to
8692c36
Compare
What does this PR do?
Fixes two formatting issues in
Bun.YAML.stringify()
to match standard YAML format (as used by js-yaml):Removed extra space after colon for multiline values
key: \n value
key:\n value
Keep empty arrays/objects inline
arr: \n []
arr: []
The fix modifies
YAMLObject.zig
to::
) for primitives and empty collections:\n
) for non-empty arrays and objectsHow did you verify your code works?
Created comprehensive regression test (
test/regression/issue/23501-yaml-spacing.test.ts
) covering:Updated existing YAML tests (
test/js/bun/yaml/yaml.test.ts
) to match the correct standard YAML formatVerified output matches js-yaml behavior by comparing side-by-side with the
js-yaml
packageAll tests pass ✅ (152 pass, 2 pre-existing timeout failures unrelated to this change)
Fixes #23501
🤖 Generated with Claude Code