chore: setup husky and lint-staged for pre-commit linting#799
chore: setup husky and lint-staged for pre-commit linting#799hemantch01 wants to merge 1 commit intoaccordproject:mainfrom
Conversation
Signed-off-by: hemantch01 <hemantchaudhary905@gmail.com>
✅ Deploy Preview for ap-template-playground ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| @@ -0,0 +1 @@ | |||
| npx lint-staged | |||
There was a problem hiding this comment.
If we have lint-staged as a dev deps, should really use invoke it from a script? Wouldn't npx redownload it every time when you'd try to commit?
There was a problem hiding this comment.
in modern environments, if a package is installed as a devDependencies like lint-staged, typing npx package_name will actually just execute the local binary (in node_modules/.bin/* ) without redownloading it. husky also automatically adds your local node_modules/.bin to the path. So, usually, npx lint-staged is very safe. in older versions of npx in ci/cd where paths differ, npx might fail to resolve the local binary and try to hit the internet.
but there is another way i can add lint-staged in scripts object and then in pre-commit we can call that using
npm run lint-staged instead of npx lint-staged... should i do that??
Closes #798
This pull request adds pre-commit hooks using
huskyandlint-stagedto automatically run ESLint formatting automatically on staged TypeScript and React code before every commit.Changes
huskyandlint-stagedas development dependencies.preparescript to package.json to properly initialize git hooks onnpm install.npx lint-staged.eslint --fix --max-warnings 0against*.tsand*.tsxfiles.Flags
preparescript will run automatically to install the hooks the next time anyone runsnpm installfor this repository.Screenshots or Video
Related Issues
Author Checklist
--signoffoption of git commit.mainfromfork:branchname