Skip to content

Add git hooks with husky and lint-staged#1570

Open
RaananW wants to merge 1 commit into
BabylonJS:masterfrom
RaananW:fix/git-hooks-1022
Open

Add git hooks with husky and lint-staged#1570
RaananW wants to merge 1 commit into
BabylonJS:masterfrom
RaananW:fix/git-hooks-1022

Conversation

@RaananW
Copy link
Copy Markdown
Member

@RaananW RaananW commented May 4, 2026

Summary

Set up pre-commit git hooks using husky + lint-staged to auto-format staged files on commit.

Fixes #1022

What's included

  • husky — manages git hooks via .husky/pre-commit
  • lint-staged — runs linters only on staged files for fast commits
  • prettier (dev dep) — formats TS/TSX/JS/JSX/JSON/SCSS/CSS/MD files
  • markdownlint-cli (dev dep) — lints markdown files with existing .markdownlint.json rules

How it works

On every git commit, the pre-commit hook runs lint-staged, which:

  1. Formats *.{ts,tsx,js,jsx} with prettier
  2. Formats and lints *.md with prettier + markdownlint (--fix)
  3. Formats *.{json,scss,css} with prettier

Both .prettierrc and .markdownlint.json were already in the repo — this PR just wires them into the commit workflow.

Setup

After pulling, run npm install — husky's prepare script will install the git hooks automatically."

- 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
@bjsplat
Copy link
Copy Markdown

bjsplat commented May 4, 2026

snapshot for this PR available at:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/DOCS/refs/pull/1570/merge

@RaananW RaananW enabled auto-merge (squash) May 5, 2026 14:09
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.

Git-hooks for Doc Repo

2 participants