100phlecs / tailwind_formatter

Sorts tailwind classes within elixir projects
https://hexdocs.pm/tailwind_formatter
MIT License
111 stars 11 forks source link

Remove surrounding spaces #46

Open zimt28 opened 11 months ago

zimt28 commented 11 months ago

The formatter currently seems to reduce multiple spaces to single spaces but keeps the first and last space, these should be removed.

"   grid hidden     h-96 grid-cols-4  "  currently becomes
" grid hidden h-96 grid-cols-4 "         instead of
"grid hidden h-96 grid-cols-4"
100phlecs commented 11 months ago

The current context behind this decision is that it seemed complicated to determine whether a string needs padding or not, i.e. {"h-6 " <> if true, do: "bg-white"} – a trailing space here is needed in order to keep the classes separate

Currently the user can delete/add trailing/leading spaces, instead of causing issues such as the above, where we remove the trailing space and have it ultimately render as h-6bg-white

If we could map out all of the cases of when we need to add/remove whitespace, it would be cool I agree. Just easier to keep the current default so the formatter doesn't step on anyone's toes 🙂