-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Requests: Heredocs/Locals without Parens/HEEx attrs? #88
Comments
Thank you for your suggestions. A PR is always welcome if you want to tackle one of your suggestions yourself. Some comments:
I am not sure if this can be handled in
Great Idea. That should be possible in
That should be easy and it is a good candidate for a first recode-task.
Recode should also handle |
Hey Marcus!
Ah that makes sense, thanks for explaining that! I have half-way done implementation of this (it just doesn't take arity into account) so happy to fix it up and make a PR. I can certainly also handle the comparison one. As for heredoc formatting, Elixir's formatter leave indentation alone so long as it's legal. I have a naive implementation that I could work on a bit if you're interested. To clarify I'm looking to turn this: @moduledoc """
I'm a doc
""" to this: @moduledoc """
I'm a doc
""" Not a big deal if you aren't interested, though. Thanks and I'll be in touch! |
Ah, now I understand the thing with the |
Ya, basically doc formatting, but I'm also thinking for LiveView as well:
becomes:
I agree it's harder to figure out here. As far as I can tell, the only good heuristic is to see if the first line is indented too far then just un-indent every line by that much unless it's illegal to do. For example: @doc """
Hello!
Oh hi
I'm back here for some reason
I'm a list:
- one
- two
- three
""" would become: @doc """
Hello!
Oh hi
I'm back here for some reason
I'm a list:
- one
- two
- three
""" But: @doc """
I'm a doc.
The rest of me is
written like this for
some reason...
""" ...would just be left alone. The point of this corrector is just to catch people doing the extra indent on every line which is very common. Anyone who does something like that last example are people who just like to watch the world burn AFAIC and there's not much you can do about them 😅 The indentation level could even be configurable! |
I think A checker for |
Hey hey, thanks for Recode! I started writing some of these rules myself before I remember it existed (d'oh).
These are merely suggestions based on my top annoyances that were not covered by Recode. I'm happy to take the implementation of any of them.
Indent heredocs at the same level as their sigil.
There are some considerations here as you can't blindly re-indent everything. I feel the safest is to assume that if the first line is indented to far then reduce everything below it by the same amount (unless it "reverse-overflows").
Remove parens from
:locals_without_parens
.I'm not entirely sure this is possible to reliably identify everything in their proper files. There is
Mix.Tasks.Format.formatter_for_file/2
though I haven't played around with it too much and seems to return the same results for every file.Correct
if foo == bar, do: true, else: false
tofoo == bar
Correct
boolean={true}
HEEx attribute to simplyboolean
Not sure if you would want to get HEEx involved but the above always annoys me when I see it.
The text was updated successfully, but these errors were encountered: