macisamuele / language-formatters-pre-commit-hooks

Collection of custom pre-commit hooks.
Apache License 2.0
119 stars 58 forks source link

Spaces before and after curly brackets in TOML #245

Closed my1e5 closed 4 weeks ago

my1e5 commented 1 month ago

From the TOML specification on arrays - https://toml.io/en/v1.0.0#array

contributors = [
  "Foo Bar <foo@example.com>",
  { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" }
]

Note how there are spaces before and after the curly brackets.

But pretty-format-toml is removing these spaces.


contributors = [
  "Foo Bar <foo@example.com>",
-  { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" }
+  {name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux"},
]
macisamuele commented 4 weeks ago

@my1e5 thanks for the report.

The TOML specifications provide an example on how the content might look like and it is explicit about the fact that whitespaces are ignored.

This library aims to provide a "single" way to render the output file, while not altering the semantic of it. Removing the spaces is a direction that the underlying toml_sort library is using.

Given that the generated output is conform to the standard, I don't think that this is an issue.