-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Update pre commit hook to lint only staged files #7326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Raunak Madan <[email protected]>
Signed-off-by: Raunak Madan <[email protected]>
Signed-off-by: Raunak Madan <[email protected]>
|
🚀 Preview for commit c58a322 at: https://695d8bc2aaec2abb0550c9fc--layer5.netlify.app |
|
🚀 Preview for commit 4bd11dc at: https://696141381db43028a2cdeca5--layer5.netlify.app |
|
🚀 Preview for commit b625e2a at: https://696435b79b1d4bd76d83b7ab--layer5.netlify.app |
|
So, whenever a commit is made, the staged files are automatically linted and fixed before the commit is completed? |
|
🚀 Preview for commit c18ac0b at: https://6967e59ce4e5d9a657e3aa99--layer5.netlify.app |
Exactly |
|
🚀 Preview for commit 3bf66f7 at: https://69685a5ba315d25d2770e85e--layer5.netlify.app |
| module.exports = { | ||
| // Lint & Prettify TS and JS files - only the staged files | ||
| "**/*.(ts|tsx|js|jsx)": (filenames) => [ | ||
| `cross-env NODE_ENV=test npx eslint --fix --max-warnings=0 ${filenames.map((f) => `'${f.replace(/'/g, "'\\''")}'`).join(" ")}`, | ||
| `npx prettier --write ${filenames.map((f) => `'${f.replace(/'/g, "'\\''")}'`).join(" ")}`, | ||
| ], | ||
|
|
||
| // Prettify only Markdown and JSON files | ||
| "**/*.(md|json)": (filenames) => | ||
| `npx prettier --write ${filenames.map((f) => `'${f.replace(/'/g, "'\\''")}'`).join(" ")}`, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CodexRaunak I think this file is over-engineered because some lint-staged already:
- Passes staged filenames automatically
- Handles spaces safely
And I have question why you're using npx why not npm run lint which already point to eslint --fix
Description
This PR fixes #7325
Notes for Reviewers
Signed commits