Scony / godot-gdscript-toolkit

Independent set of GDScript tools - parser, linter, formatter, and more
MIT License
944 stars 65 forks source link

Add gdformat config file for excluding folders. #286

Closed chrisl8 closed 6 months ago

chrisl8 commented 6 months ago

This is an initial stab at fixing Issue #250

Some decisions I made that could go differently:

This is sort of an "easiest possible path" solution. Feel free to suggest better alternatives, but this appears to work for me.

Scony commented 6 months ago

Looks promising.

I've been thinking about the config file for a while and IMO using gdlintrc is not a proper way to go - it will be misleading and a change to use smth like gdformatrc would break compatibility in the future. Moreover, I'be been thinking about gdformatrc and I think we don't need it. IMO the best way to proceed would be by adding a new argument like --excluded-directories. It should be fairly straightforward to change the current PR to achieve that.

What do you think?

chrisl8 commented 6 months ago

The benefits of a config file that come to mind are

Basically a formatting tool operates similarly to a linting tool, in that I hope that other developers and myself can easily use it frequently without much fuss.

Also Godot has the added situation of expecting us to commit "addons" into the repo in the addons folder which we generally don't want to lint or format.

Finally, if all we intend to do is add a command line argument, at last in Linux, this is pretty easily done already:
find . -name '*.gd' -not -path "./addons/*" -print0 | xargs -0 gdformat --check

But it is nice that running gdlint is so much simpler:
gdlint .

and with a config file gdformat can also be just:
gdformat -c .

Prettier has a config file to ignore files: https://prettier.io/docs/en/ignore.html Black also seems able to be configured via a file as well: https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file

Those are my thoughts anyway and why I was wanting a config file for gdformat, a tool that I really love and hope to see become a standard for GDScript.

Scony commented 6 months ago

Ok, that makes sense. Let's just rename to gdformatrc then

chrisl8 commented 6 months ago

Updated code is ready.