-
Notifications
You must be signed in to change notification settings - Fork 401
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
adding new formatters can break older projects #3642
Comments
The set of enabled formatters is tied to the
Something like this seems good. To be more precise, when the user doesn't explicitly enables |
It might be nice to consider an |
IIUC, there are two ways of disabling ocamlformat:
Is that correct? |
That is my understanding, but @emillon will know for certain as an OCamlformat maintainer. (I believe he's on vacation this week.) |
It is also possible to specify files that should be ignored by ocamlformat using Also, note that ocamlformat will act even without an I appreciate that these things are all complications for interoperation with dune. I'm not sure what the best plan ought to be. |
In general we want to support one workflow and support it well rather than try to support every possible combination. I propose to simply update the Dune documentation here to clarify what is supported. |
Agreed. I think that When it comes to having a @gpetiot, what do you think? |
I like the idea of Dune passing That + skipping ocamlformat in sub-tree without a |
Bump @emillon any update on this? |
@tmcgilchrist You can enable formatting only for dune files: https://dune.readthedocs.io/en/stable/dune-files.html#formatting |
This ticket can have a pretty wide scope so allow me to explain how this works today and if we agree on the problem we're trying to solve (before discussing potential solutions). Let me describe the situation with formatting rules. There are 3 steps that happen when formatting a project:
What happen in step 1 depends on the version of In step 2, we consider all files to be formatted. These correspond to all files with the extension corresponding to enabled dialects (by default Step 3 happens when we call My understanding is that in the context of ocaml-ci you're trying to answer 2 questions:
Is this correct? |
In the ocaml-ci, we have a "lint fmt" step which probes the project metadata to determine the formatters to run over the project. This is primarily for
dune
files andml[i]
files via ocamlformat.The problem arises when we try a
dune build @fmt
with ocamlformat installed but without a .ocamlformat file, at which point dune tries to invoke ocamlformat even if there is no way it can work:I think there's an erroneous default in dune that makes this difficult to work around:
This default means that projects have to specifically add
(formatting disabled)
to turn it off for OCaml code, but to enable it for dune files.Wouldn't it be better to specifically version formatters used by a project, so that a future dune client understanding a new formatter wouldn't cause older format lint tests to fail? Specifically, this means flagging that ocamlformat is enabled specifically for a project. We could minimise breakage by taking the presence of an .ocamlformat file to mean
(formatting enabled)
, and the absence to be(formatting disabled)
.See ocurrent/ocaml-ci#224
The text was updated successfully, but these errors were encountered: