Featured

Prettier Pre-commit Hook

Auto-format code with Prettier before every commit

Category:hooks-configs
Type:hook
Difficulty:beginner
formatting
pre-commit
javascript
typescript
beginner

Description

Pre-commit hook configuration that automatically formats staged files with Prettier. Supports JavaScript, TypeScript, JSON, CSS, Markdown, and more. Prevents unformatted code from being committed.

Content

Resource Content
{
  "hooks": {
    "pre-commit": [
      {
        "name": "prettier-format",
        "command": "npx prettier --write --ignore-unknown",
        "match": "**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}",
        "description": "Format staged files with Prettier"
      }
    ]
  }
}