Add git hooks with husky and lint-staged#1570
Open
RaananW wants to merge 1 commit into
Open
Conversation
- Install husky for git hook management - Install lint-staged to run linters on staged files only - Install prettier and markdownlint-cli as dev dependencies - Configure pre-commit hook to run lint-staged - Configure lint-staged to: - Format TS/TSX/JS/JSX files with prettier - Format and lint markdown files with prettier + markdownlint - Format JSON/SCSS/CSS files with prettier Fixes BabylonJS#1022
|
snapshot for this PR available at: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/DOCS/refs/pull/1570/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Set up pre-commit git hooks using husky + lint-staged to auto-format staged files on commit.
Fixes #1022
What's included
.husky/pre-commit.markdownlint.jsonrulesHow it works
On every
git commit, the pre-commit hook runslint-staged, which:*.{ts,tsx,js,jsx}with prettier*.mdwith prettier + markdownlint (--fix)*.{json,scss,css}with prettierBoth
.prettierrcand.markdownlint.jsonwere already in the repo — this PR just wires them into the commit workflow.Setup
After pulling, run
npm install— husky'spreparescript will install the git hooks automatically."