macisamuele / language-formatters-pre-commit-hooks

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

format arrays in .toml using pretty-format-toml #109

Closed im-renpei closed 1 year ago

im-renpei commented 2 years ago

Hi @macisamuele

Appreciate your great work! I wonder if there is a way to format arrays in .toml using pretty-format-toml.

[array]
array1 = [1, 2, 3, 4,

5, 6, 7, 8, 9, 10]
array2 = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]
macisamuele commented 1 year ago

I'm about to release v2.6.0 of the library that would address the concern. The fix has been introduced by updating the underlying formatting library in #134 / #137

Tested it locally and comments are preserved.

@@ -1,9 +1,18 @@
 [array]
-array1 = [1, 2, 3, 4,
-
-5, 6, 7, 8, 9, 10]
-array2 = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
-
-[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
-
-[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]
+array1 = [
+  1,
+  2,
+  3,
+  4,
+  5,
+  6,
+  7,
+  8,
+  9,
+  10
+]
+array2 = [
+  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
+  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
+  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+]