Update pre commit hook to lint only staged files#7326
Update pre commit hook to lint only staged files#7326CodexRaunak wants to merge 10 commits intolayer5io:masterfrom
Conversation
Signed-off-by: Raunak Madan <madanraunak24@gmail.com>
Signed-off-by: Raunak Madan <madanraunak24@gmail.com>
Signed-off-by: Raunak Madan <madanraunak24@gmail.com>
|
🚀 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.
@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
|
🚀 Preview for commit 02bbaab at: https://696f8f6c5c48ea6d94ea68ae--layer5.netlify.app |
|
🚀 Preview for commit 0f9aa26 at: https://698382ae36ee13329139d6f0--layer5.netlify.app |
Description
This PR fixes #7325
Notes for Reviewers
Signed commits