A while ago, Dave Townsend wrote a commit hook for Mercurial for ESLint. I’ve just extended the code to create a commit hook for Git users.
To install the Git hook, go into the top-level of your mozilla-central Git repository, and enter (assuming you don’t already have a pre-commit hook):
ln -s ../../tools/git/git-lint-commit-hook.sh .git/hooks/pre-commit
That’s all you need to do. If you do have an existing pre-commit hook, then you’ll need to incorporate running git-lint-commit-hook.sh as well.
This will run ESLint on the affected files when committing and print warnings if they fail. The commit will still happen, but you should fix the issues up before pushing them for review.
- Automatic installation of hooks via mach (probably via bootstrap or something)
- Include Flake8 in the commit hooks
- ESLint hooks to additionally ensure the ESLint setup is up to date