Skip to content

Latest commit

 

History

History
90 lines (61 loc) · 1.89 KB

File metadata and controls

90 lines (61 loc) · 1.89 KB

Commitlint Setup

This repository uses commitlint to enforce our conventional commit standards.

Installation

If you want to run commitlint locally, install the dependencies:

npm install

Usage

Manual Validation

Check the last commit:

npm run commitlint

Check commits in a range (CI):

npm run commitlint-ci

Git Hooks (Optional)

To automatically validate commits before they're created, you can install a git hook:

# Install husky (one-time setup)
npm install --save-dev husky
npx husky install

# Add commit-msg hook
npx husky add .husky/commit-msg 'npx --no-install commitlint --edit "$1"'

Configuration

The commitlint configuration is in .commitlintrc.js and follows our standards:

  • Types: feat, fix, docs, style, refactor, perf, test, chore, build, ci, revert
  • Format: type(scope): subject (scope is optional)
  • Subject: 10-72 characters, lowercase, no period
  • Body: Should include "Files changed:" section

Examples

Good commits:

feat: add commitlint configuration

Files changed:
- `.commitlintrc.js` - commitlint configuration
- `package.json` - commitlint dependencies

fix(api): handle null response in user service

Files changed:
- `src/api/user.service.js` - add null check

Bad commits:

Fixed stuff                    # No type
feat: Add new feature.         # Period at end
feat: a                        # Too short
FEAT: new feature              # Wrong case

Integration

Commitlint is automatically enabled in our Super Linter configuration via:

  • VALIDATE_GIT_COMMITLINT=true in .github/super-linter.env
  • Integrated in .github/workflows/reusable-super-linter.yml