The formatter handles most reflow programs I've tested, except:
Some expression comments are removed, I think due to behavior of the parser. This is documented in the Cmd's help. I haven't looked into whether this is easy to fix or would cause other problems.
Line breaks in long type alias definitions aren't preserved, because I don't think the parser preserves this information. This is pretty inconvenient in some programs.
The formatter places newlines judiciously, including allowing up to one blank line between lines. It uses identifier punning when possible, elides function argument types when possible, writes declaration comments, etc. It always chooses := for assignment unless the left side is destructuring or a type is ascribed. This was necessary to handle declaration lists in make, requires, etc. without parser changes, for now, but I actually think this is nice because I dislike having multiple ways of writing anything.
Introduces a
reflow fmt
command.The formatter handles most reflow programs I've tested, except:
Cmd
's help. I haven't looked into whether this is easy to fix or would cause other problems.The formatter places newlines judiciously, including allowing up to one blank line between lines. It uses identifier punning when possible, elides function argument types when possible, writes declaration comments, etc. It always chooses := for assignment unless the left side is destructuring or a type is ascribed. This was necessary to handle declaration lists in make, requires, etc. without parser changes, for now, but I actually think this is nice because I dislike having multiple ways of writing anything.
It makes no effort to format invalid syntax.