fantomas icon indicating copy to clipboard operation
fantomas copied to clipboard

Move editor config to library rather than tool

Open Smaug123 opened this issue 1 year ago • 6 comments

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 user doesn't have to manually run fantomas after a Myriad invocation.

The disadvantages of making this adjustment to Fantomas are:

  • more chance for the embedded Fantomas in the downstream tool (like Myriad) to be backward-incompatible with the Fantomas expected in the workspace;
  • bloat of the Fantomas library, including a reference to the editorconfig NuGet package.

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:

  • [x] This is not a breaking change to Fantomas
  • [x] I or my company would be willing to help implement and/or test this

Smaug123 avatar Dec 29 '23 14:12 Smaug123

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.

nojaf avatar Dec 29 '23 15:12 nojaf

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

Smaug123 avatar Dec 29 '23 16:12 Smaug123

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.

josh-degraw avatar Dec 29 '23 16:12 josh-degraw

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

dawedawe avatar Jan 01 '24 20:01 dawedawe

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

nojaf avatar Jan 02 '24 07:01 nojaf

Happy to close it as won't-fix!

Smaug123 avatar Jan 02 '24 09:01 Smaug123