In this example, the editor.formatOnSave
was turned off for the demonstration.
With an example of bad formatting, the pre-commit hook that validate format fails. We can remedy this with lint-staged
.
$ npm i -D lint-staged $ touch .lintstagedrc
In .lintstagedrc
:
{ "*.+(js|ts|tsx)": [ "eslint" ], "**/*.+(js|json|ts|tsx)": [ "prettier --write", "git add" ] }
The example then updates .huskyrc
to change the pre-commit
hook to lint-staged
.
$ npm i -D npm-run-all
The example npm validate
script was the updated:
{ "scripts": { "validate": "npm-run-all --parallel check-types check-format lint build" } }