v0.7.0
The Big Path Change Release
This is one of the biggest releases of yamlfmt since the initial! And it's completely my fault because my holidays were so busy that this project unfortunately was lower in my priorities. Lots of new functionality, including one major breaking change (sorry for pulling a v0.x lol).
Major Breaking Change
The yamlfmt
command now boasts a new simplified default path specification format. The default mode for path specification is simply directories (searched recursively for files with desired file extensions) or direct paths to files. This is the new default, however the old doublestar
glob behaviour can be restored with the -dstar
flag or the global doublestar
option. See the new configuration docs for more info.
To go with this, issue #71 brought up a good point that it is strange for yamlfmt
to automatically search the working directory recursively. Looking at similar formatting tools I am trying to emulate, none of them do this. So I've removed that behaviour; you now have to specify at least one path. I didn't add a switch to restore old behaviour for this, since it seems pretty unlikely to cause much friction. If you disagree, feel free to open an issue.
Features
Using new yaml fork
While this on its own doesn't adjust user-facing functionality, it mostly represents a new direction for the project. This now means I am no longer at the mercy of the underlying yaml library, which is understandably very challenging to get things merged into. Some major things have already been fixed and tech debt reduced with more to come as I get the hang of the codebase.
Emoji support is now default
You can remove emoji_support
from your .yamlfmt
file, as the functionality for emoji_support
is now baked into the yaml library!
You can define a system-wide .yamlfmt
config!
This improves the config file resolution to resolve things in priority order. It also includes support for config from a configuration home directory (i.e. $XDG_CONFIG_HOME, $HOME/.config, %LOCALAPPDATA%) so a user can override the default config system-wide. See the config section of the README for updated info.
Set line length
This one was requested for a long time, but couldn't be done until I had control of the yaml library. In the basic
formatter you can finally set a line_length
option. I don't think the feature is perfect yet, and if you find an edge case let me know and I will see if it's workable.
Preserve line breaks in folded block scalars
Folded block scalars (multiline strings starting with >
block specified) previously would have their newlines removed. This was an unfortunate side effect of expected yaml parsing behaviour, since these blocks are supposed to have their newlines squashed on processing. However, for yamlfmt in particular, this is undesirable as we want to retain that line break information on format. I can't decide if this is clever or stupid, but my solution is to add an override that will force folded block scalars to be scanned as if they are literal (|
) block scalars, while retaining the fact that they are folded. This seems to work in all cases I could think of, however I decided to lock this behind an option in the basic
formatter just in case. The option is scan_folded_as_literal
.
Bug Fixes
Exclude paths didn't work with ./
The filepath wasn't cleaned before used as a doublestar
pattern, which meant exclude paths with a ./
in front would fail.
Contributors
- Thanks @fsrv-xyz for the Exclude Paths fix!
Thank you all for your patience while I got this release out. Since this is only a side project for me I can't dedicate as much time to it as I would like, and end-of-year priorities got in the way. I will try my best not to do a release this big again. If you have any problems or requests, don't hesitate to open an issue!