refactor: replace stoplight/yaml with yaml (eemeli)#206
Merged
thim81 merged 4 commits intothim81:mainfrom Apr 12, 2026
Merged
Conversation
Problem: stoplight/yaml has unfixed bugs in block scalar chomping (|+ loses trailing blank lines, explicit indent indicators like |2 produce a spurious leading newline). Furthermore the library is effectivelly unmaintained. Solution: Replace stoplight/yaml with the actively maintained yaml (eemeli) package. Comment preservation is re-implemented using a path-based extract/inject strategy.
- yaml-default-newline: block scalar chomping (|+ keep, |- strip, | clip) now behaves correctly. |+ doesn't lose trailing blank lines, and spurious leading newlines are not created. - yaml-no-sort-keep-comments: a valueCommentBefore (key: # comment above a block node) is re-emitted on its own line below the key rather than inline. This is a known rendering difference of the new path-based inject approach; the YAML is semantically equivalent.
Owner
|
hi @guilhas07 A long time ago, I did looked into using https://github.com/eemeli/yaml library but for some reason I was not able to fully migrate to it. Looking at the implementation (which opens up for AST usage if we would need it), the updated tests PLUS the required support for preserving comments; your PR looks in a very good shape. |
Owner
|
hi @guilhas07 I just released version 1.31.0, which includes your excellent PR of the switch to Thanks again for another contribution 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Splitted into commits for easier review — happy to squash before merge, or keep it as is.
Fixes #149, #202
I'd like to propose replacing stoplight/yaml with https://github.com/eemeli/yaml. Open to feedback on the approach before this goes further.
Problem
stoplight/yaml has multiple unfixed bugs and limitations:
Solution
Replace stoplight/yaml with the actively maintained https://github.com/eemeli/yaml package. Comment preservation is re-implemented using a path-based extract/inject strategy. This also unlocks greater flexibility going forward, due to the yaml package exposing a AST which give us fine-grained control. Also it provides multiple configuration options.