Add pre-commit hook to enable LuaFormatter for pre-commit. #236
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello! I've been working with the maintainer of pre-commit to add official Lua support for the pre-commit tool. With pre-commit, a developer or team can choose to run hooks that will execute before a change is committed to git.
Support for Lua in pre-commit was literally added an hour ago as of this PR submission in pre-commit/pre-commit#2158, so this change is hot off the presses.
I believe that LuaFormatter would be a fantastic tool to work with pre-commit since running a code formatter is a very common thing to do before committing.
This PR adds a hooks definition file that will allow any project to use lua-format with pre-commit. I ran a local test on one of my projects to confirm the behavior. I've included the output with no changes (i.e. already formatted code) and a test where the formatter updates the output.
Thanks for the consideration.
No formatting changes:
Auto-formatted:
The auto-formatted change acts as a failure so that a dev can review the diff of what the lua-format command did before they commit the changes.
The output during the first run is much noisier than subsequent runs. Typically, after the environment is configured by the first run, users will only see a line like: