-
Notifications
You must be signed in to change notification settings - Fork 38
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
docs: add formatter spec #32
Conversation
Describe how formatters should ideally work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 👍
Maybe it's a separate concern, but I do wonder: if we ever want prjfmt
to have the option to check the format instead of applying the format, maybe this should make it into the specification.
If a formatter doesn't implement check
functionality itself, that can be implemented in a wrapper script using diff
(but then the formatter should probably not do in place formatting).
It might also make sense to not use the same options
when in check
mode. Some options might not make sense (for example ormolu's mode which can only be one of inplace
, check
or stdout
). So maybe prjfmt
could have a field check-args
as well as args
which would follow a similar specification but would only check if the files are formatted.
|
||
Where | ||
* `<command>` is the name of the formatter. | ||
* `[options]` is any number of flags and options that the formatter wants to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prjfmt.toml
calls these args
, it might be better to keep these two names synchronized. How about we rename this to args
or alternatively rename the field in prjfmt.toml
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I'm thinking we should do this the other way around and rename args
to options
. args
is more generic and also includes the list of files that would be passed.
I am still not sure whether we have to make a formatter spec or not. If the user still uses |
Co-authored-by: Andika Demas Riyandi <[email protected]>
Regarding the |
Alright, so this relies on:
Is that a common feature of formatters? I don't think |
We'll see. Thanks to the spec it should be possible to petition upstream formatters to implement the right thing. In the worse-case scenario, it's possible to fallback on the source control to query if any files are dirty after the formatting occurs. And then ship with some common implementations in the documentation. For example for git, it just adds a single line of code to the CI. |
Another missing aspect of the spec is the XDG config part that formatters can ship. Let's ship this and gather more experience by trying out a ton of formatters. We can always come back and update the spec. |
…configure-treefmt-pipeline into main Reviewed-on: https://git.numtide.com/numtide/treefmt/pulls/32
Describe how formatters should ideally work.
Fixes #31