-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
From @chrismccord at whatyouhide/code_formatter#14:
I believe the current plan is to allow user's choice to be respected on a macro-by-macro basis, so for example, Phoenix could generate a .formatter.exs
with a list of the router macros to not wrap in parens. While this can be made to work for Phoenix, since it generates projects, I still feel it will be too restrictive for many DSLs. I see two main issues:
1. Project Introducing new macros
Consider if phoenix introduces a new router macro. This is not unheard of as forward
was a later introduced feature. Existing applications will begin wrapping the new macro(s) in parens, but leave the others in the DSLs unwrapped, which will be inconsistent and require manual intervention from the end-user.
2. DSLs containing many dozens of macros
Consider an HTML DSL, which contains many dozens of macros. With the planned configuration, the end-user will need to copy-paste the entirety of an external projects macros, which themselves may be auto-generated from some flat file DB. Even if the giant copy-paste can be seen as an okay tradeoff, we then have the problem of # 1 above.
Possible solutions
Ideally, we would be able to get around this by specifying a module in config and the formatter would respective input for all the macros it provides. I've been told by José this can't really work however.
Another option would be to allow the formatter config to load_config
similar to mix to a direct dep path, such as:
.... # formatter config
load_config "deps/phoenix/.formatter.exs"
I'm still naive to the workings of the formatter, so forgive me if I trivialize supporting such a feature, but I feel strongly that we need a better story here than "list all the macros in config". Thoughts?