Skip to content
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

Add pre-commit hook definition with test #596

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

dbast
Copy link

@dbast dbast commented Aug 20, 2024

pre-commit became pretty popular as framework to combine linters / code-formatters via hooks across different languages. It can be enabled as actual git hook or just used by running pre-commit run -a. pre-commit does its own dependency management (+cashing) and installs each hook into its own isolated folder.

This adds a .pre-commit-hooks.yaml (+ doc + test), which allows other projects to run Solhint via pre-commit.

Tested it also via my solhint fork with custom test tag, see dbast/sol-press#16

pre-commit installs a hook by cloning the repo, checking out the specified git rev (=tag, branch, commit hash), parsing the .pre-commit-hooks.yaml and installing the hook (in case of node based hooks: run npm pack (produces a tarball + npm install $tarball). Installed hooks are cached based on the rev for later repeated runs.

Had to remove the prepare script in package.json as that prevents npm pack from working with a plain node install (which is used by pre-commit during isolated hook installations). prepare is afaik not the right place to run husky install.

@dbast dbast changed the title Add pre-commit hook with test Add pre-commit hook definition with test Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant