Repository navigation
fix(yaml): use a non-zero indent when stringifying flat documents - #103
Conversation
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review. ℹ️ Recent review info
Walkthrough
Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #103 +/- ##
=======================================
Coverage ? 98.75%
=======================================
Files ? 8
Lines ? 80
Branches ? 17
=======================================
Hits ? 79
Misses ? 1
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Problem
When
parseYAMLreads a document with no indented lines, such asa: 1, the detected indent is"".stringifyYAMLpasses its length,0, tojs-yaml'sdump. Any nested value added to that object is then written at column 0, which changes the data when read back:Change
stringifyYAMLfalls back to an indent of2when the detected indent is0. This is the same defaultgetFormatuses for values that were not parsed. Detected non-zero indents and an explicitindentoption behave as before.Tests
A new
yamltest parses a flat document, adds a nested object and array, and checks both the output and that it parses back to the same data.src/yaml.tschange: 1 failed, 28 passed, 1 skipped.pnpm test(oxlint, oxfmt, tsc, vitest) andpnpm buildpass.Fixes #102
Summary by CodeRabbit
Bug Fixes
Tests