AprilSylph / XKit-Rewritten

🧰 The enhancement suite for Tumblr's new web interface
GNU General Public License v3.0
274 stars 44 forks source link

Create simple optional eslint pre-commit hook #1490

Closed marcustyphoon closed 2 weeks ago

marcustyphoon commented 2 weeks ago

Description

Similar to #1472.

This allows developers to—optionally—install a pre-commit hook that runs eslint locally on staged files before they're committed, preventing the commit if they are not in the semistandard style.

This uses simple-git-hooks, which has the drawback (vs husky) of making hooks annoying to uninstall, but as the advantage of not uninstalling hooks when you switch branches. This PR also forgoes lint-staged and makes the hook itself not depend on package.json, continuing this trend. I also didn't add .eslintcache to gitignore or add --cache to posttest.

Thus, this branch is a git hook installer that doesn't require changes to the repository. Whee. That is, one can switch to this PR branch, run npm run enable-hooks, switch to another branch, and have the hook continue to work until one manually deletes .git/hooks/pre-commit, which is what I'm doing.

Testing steps