fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
758 stars 189 forks source link

Move editor config to library rather than tool #3031

Open Smaug123 opened 6 months ago

Smaug123 commented 6 months ago

In consumers such as Myriad, it would be nice if we could automatically read the editorconfig appropriate to the files we want to write out, and use that directly, rather than writing out with no config and then forcing the user to reformat with a manual invocation of fantomas.

This would be pretty easy to do, I'd say: we just need to move the EditorConfig files to Fantomas.Core, so that consumers can use them.

Definition of done: a user can call EditorConfig.readConfiguration, after having automatically located the correct .editorconfig file using the same mechanism that Fantomas uses.

I'd be happy to implement this if we think it's desirable.

Pros and Cons

The advantages of making this adjustment to Fantomas are:

The disadvantages of making this adjustment to Fantomas are:

Extra information

Estimated cost (XS, S, M, L, XL, XXL): XS

Affidavit (please submit!)

Please tick this by placing a cross in the box:

Please tick all that apply:

nojaf commented 6 months ago

Hi there,

First reaction: I'm against this. I don't think it is worth it. Why would you want to format the generated code? I would just ignore it via .fantomasignore file.

Or course, since Fantomas.Client, having the extra dependency might not be the end of the world.

I'm gonna let @dawedawe and @josh-degraw decide on this one! No pressure lads.

Smaug123 commented 6 months ago

Fair enough - it's just an aesthetic preference, nothing more! Happy to close if you like.

josh-degraw commented 6 months ago

Yeah I'm inclined to agree with Florian at least about the case where generated files should be ignored. But I can totally see value in having the editorconfig parser available outside the tool fwiw. But right now I'd say without a stronger use case I'd prefer to leave things as they are.

dawedawe commented 6 months ago

Hey, sorry for the late reply, I took a few days off from GitHub. The cons are stronger for me, too.

nojaf commented 6 months ago

Alright, let's leave this one open for a while. Maybe some other real-world use-cases show up.

Smaug123 commented 6 months ago

Happy to close it as won't-fix!