google / yamlfmt

An extensible command line tool or library to format yaml files.
Apache License 2.0
1.2k stars 48 forks source link

%YAML:1.0 give error #215

Closed niroosh1997 closed 1 month ago

niroosh1997 commented 1 month ago

when in the start of the file there is %YAML:1.0 then tells that yaml including non alphabetical character and not linting file.

braydonk commented 1 month ago

Hi @niroosh1997 thanks for opening an issue.

It looks like the underlying yaml library does not support directives. I could potentially add a hotfix where yamlfmt purposely strips directives and puts them back in after the document similar to other features I've added. Worth noting though, the YAML 1.0 spec is similarly not supported by the YAML parser (see that library's README).

niroosh1997 commented 1 month ago

Seems like great hotfix for my purposes!

I did it manually and it works great so would love this hotix

Thanks Nir

On Wed, 30 Oct 2024, 20:48 Braydon Kains, @.***> wrote:

Hi @niroosh1997 https://github.com/niroosh1997 thanks for opening an issue.

It looks like the underlying yaml library does not support directives. I could potentially add a hotfix where yamlfmt purposely strips directives and puts them back in after the document similar to other features I've added. Worth noting though, the YAML 1.0 spec is similarly not supported by the YAML parser (see that library's README https://github.com/go-yaml/yaml?tab=readme-ov-file#compatibility).

— Reply to this email directly, view it on GitHub https://github.com/google/yamlfmt/issues/215#issuecomment-2448078675, or unsubscribe https://github.com/notifications/unsubscribe-auth/AME6ZHCCVWPP4Y2EBFXGTTLZ6ESX3AVCNFSM6AAAAABQ4KBOKWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBYGA3TQNRXGU . You are receiving this because you were mentioned.Message ID: @.***>

braydonk commented 1 month ago

I will try and get something added in soon, along with documentation stating that directives are ignored and will have no affect on parsing.