-
Notifications
You must be signed in to change notification settings - Fork 460
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
Feature: -PspotlessIdeHook with multiple files #791
Comments
The IDE hook can also read/write from stdin and/or stdout, which is useful for IDE integration. It is difficult to reconcile those features with multiple files, so I will not merge any PR which complicates the I am open to a new broader thoughts on the usecaseWhen you stage a file, the content on disk can be different than the content in staging. Spotless only runs against the content on disk. Which of the following is lint-staged doing?
In #623, we have a feature request which runs Spotless directly on staging, without touching disk. That has the benefit that when disk and staging are different, we never clobber that difference. Advanced git users understand that there are at three complete copies (head, WC, staging/index), but most think of staging as just a boolean checkbox. This confusion makes it hard to build tools that do "the right thing" - either you clobber data for advanced users, or confuse everybody else by having the WC magically different than staging. |
Concerning lint-staged, there is a blog which explains how lint-staged supports partially staged files. So (I have not tested it thourougly, yet), lint-staged seems to work this way:
Anyhow, if spotless wants to eventually include the functionality that lint-staged currently covers, it would probably be wise to use/adapt that algorithm. |
I followed this blogpost about using spotless for pre-commit hooks. It works but it uses |
This feature would actually really help with the format on save feature we're trying to add (ragurney/spotless-intellij-gradle#33) to the spotless-intellij-gradle plugin. |
following, because I too was thinking about whether I could use lintstaged (but with yaml, not js) with this. I can do it with a precommit hook before lintstaged, but then I can't only run it when certain files change. However right now that seems like the best option |
@nedtwigg just curious what the priority of this feature request is? It would be really great to have a separate |
My priority list right now is
It is very useful to know that you want |
Thanks so much @nedtwigg! |
Hey @nedtwigg, just following up here. Thanks! |
Sorry, going to be a couple weeks longer before I get to this, thanks for following up! |
@nedtwigg bump >~< |
@nedtwigg 🙏🏼 |
I wanted to set up spotless on a pre-commit hook with husky and lint-staged. It works, but it's really slow when committing multiple files. Would be great to a have an option to pass multiple files to spotless. (Alternatively, if spotless could do what lint-staged does, #623 that would be nice too). |
|
I am using -PspotlessIdeHook to have spotless format all files that lint-staged detects. So, before a commit succeeds, lint-staged triggers spotless individually for each file since the -PspotlessIdeHook parameter accepts single files only. For interested parties - this is my lint-staged configuration:
Although this approach works, the duration of which is quite underwhelming as gradle needs to start all-over for each file. It would be nice to be able to pass entire batches of file names to spotless (alternatively make lint-staged obsolete).
The text was updated successfully, but these errors were encountered: