Skip to content

chore: setup husky and lint-staged for pre-commit linting#799

Open
hemantch01 wants to merge 1 commit intoaccordproject:mainfrom
hemantch01:feature/add_pre_commit_hooks
Open

chore: setup husky and lint-staged for pre-commit linting#799
hemantch01 wants to merge 1 commit intoaccordproject:mainfrom
hemantch01:feature/add_pre_commit_hooks

Conversation

@hemantch01
Copy link

Closes #798

This pull request adds pre-commit hooks using husky and lint-staged to automatically run ESLint formatting automatically on staged TypeScript and React code before every commit.

Changes

  • Added husky and lint-staged as development dependencies.
  • Added a prepare script to package.json to properly initialize git hooks on npm install.
  • Configured .husky/pre-commit to execute npx lint-staged.
  • Created .lintstagedrc to run eslint --fix --max-warnings 0 against *.ts and *.tsx files.

Flags

  • Developers will now be blocked from creating a commit if ESLint detects unfixable warnings or errors in the files they are staging.
  • The prepare script will run automatically to install the hooks the next time anyone runs npm install for this repository.

Screenshots or Video

Screenshot 2026-03-09 090941 Screenshot 2026-03-09 091048

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:branchname

Signed-off-by: hemantch01 <hemantchaudhary905@gmail.com>
@hemantch01 hemantch01 requested a review from a team as a code owner March 9, 2026 03:46
@netlify
Copy link

netlify bot commented Mar 9, 2026

Deploy Preview for ap-template-playground ready!

Name Link
🔨 Latest commit adb805b
🔍 Latest deploy log https://app.netlify.com/projects/ap-template-playground/deploys/69ae429cf89de70008925359
😎 Deploy Preview https://deploy-preview-799--ap-template-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@@ -0,0 +1 @@
npx lint-staged
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Author

@hemantch01 hemantch01 Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(lint): add pre-commit hooks to enforce eslint rules

2 participants