I have the following husky pre-commit hook script:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn lint-staged
and a .linkstagedrc.js
file configured like this:
module.exports = {
// Type check TypeScript files
'**/*.(ts|tsx)': () => 'yarn tsc --noEmit',
// Lint & Prettify TS and JS files
'**/*.(ts|tsx|js)': (filenames) => [
`npx eslint ${filenames.join(' ')}`,
`npx prettier --write ${filenames.join(' ')}`,
],
// Prettify only Markdown and JSON files
'**/*.(md|json)': (filenames) => `yarn prettier --write ${filenames.join(' ')}`,
};
Now in a changed file in my NextJS project, I added: console.log(2);
which my IDE identifies as an eslint issue.
I then run git commit and it passes:
laptop:~/Projects/project (husky) $ git commit -am "test precommit hook"
yarn run v1.22.19
$ /home/Projects/project/node_modules/.bin/lint-staged
✔ Preparing lint-staged...
✔ Running tasks for staged files...
✔ Applying modifications from tasks...
✔ Cleaning up temporary files...
Done in 2.01s.
[husky 35445914] test precommit hook
2 files changed, 2 insertions(+), 7 deletions(-)
Any ideas why?