govuk-frontend
govuk-frontend copied to clipboard
For discussion: Add Git hook to lint `.(m)js` and `.scss` file `pre-commit`
Not a PR to merge, but more to initiate a discussion around running linting before commit to prevent discovering linting issues only on CI.
It relies on two tools:
-
lint-staged which handles detecting which files are being commited and running the linting on them. It stashes/unstashes any changes that are not staged so the linting runs on the files in the state they are actually commited, in case you're using
git add -p
. Thought there'd be some caution to have around thepackage
anddist
folder to avoid messing with compiled files, butstandard
is already configured to avoid those -
husky which handles the creation and installation of Git hooks, mostly pointing Git to the relevant scripts in
.husky
(configurable) through itscore.hooksPath
config.
Happy to park it for now if it's not something we'd want to dip our toes into, but thought it'd be best discussed alongside how it could look as these two tools make managing the situation a bit less scary than it sounds.