Skip to content

Conversation

@Jamesllllllllll
Copy link
Contributor

What issue is this solving?

Closes #15

Description

  • Adds Husky & Lint-Staged for linting & formatting on commit.
  • Using --fix with ES Lint and --write with Prettier to fix lint errors (if possible) and formatting, respectively.

Notes

✔️ Run npm i to install Husky and Lint-Staged

Linting or formatting error messages may not be developer-friendly

Solution: Added CONTRIBUTING.md to describe how staged files are checked for linting and formatting errors, and to look for the errors if the commit is blocked.

Here is how it appears to me using VS Code on Windows. I tested a commit with a lint error and get this popup:

Windows error message

Click "Open Git Log":

Git Log

This may be a hurdle for some newbie devs. Since there may not be a one-size-fits-all solution, the documentation in CONTRIBUTING.md will help devs understand pre-commit checks.

Please make sure you've attempted to meet the following coding standards

  • Code has been tested and does not produce errors
  • Code is readable and formatted
  • There isn't any unnecessary commented-out code

Copy link
Collaborator

@aedwardg aedwardg left a comment

Choose a reason for hiding this comment

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

LGTM. If we run into too many people struggling with it, we can always change over to a pre-push hook instead.

@Jamesllllllllll Jamesllllllllll merged commit 055afbb into main Dec 28, 2024
3 checks passed
@Jamesllllllllll Jamesllllllllll deleted the enhancement/husky-for-auto-lint-on-commit branch December 28, 2024 18:28
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.

Add git hook for linting and formatting

3 participants