Skip to content

Commit 6d91c69

Browse files
chore: add husky and commitlint for improved commit message linting (#66)
* chore: add husky and commitlint for improved commit message linting * fix: add permissions to workflow to resolve code scanning alert Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * chore: update actions/checkout and actions/setup-node versions * chore: update husky hooks for commit and pre-push linting * chore: update commit message guidelines for clarity * chore: relax commitlint line length rules --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 816f0a7 commit 6d91c69

File tree

9 files changed

+934
-12
lines changed

9 files changed

+934
-12
lines changed

.github/CONTRIBUTING.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,17 @@ src/
7979

8080
### Commits
8181

82-
We follow conventional commits:
82+
We follow [Conventional Commits](https://www.conventionalcommits.org/) to automate our release process. We use `husky` and `commitlint` to enforce this standard locally.
8383

84-
- `feat:` New features
85-
- `fix:` Bug fixes
86-
- `docs:` Documentation changes
87-
- `test:` Test additions/changes
88-
- `refactor:` Code refactoring
89-
- `chore:` Maintenance tasks
84+
Release Please assumes you are using Conventional Commit messages.
9085

91-
Example: `feat: add auto-detection of PHPStan config files`
86+
The most important prefixes you should have in mind are:
87+
88+
- `fix`: which represents bug fixes, and correlates to a SemVer patch.
89+
- `feat`: which represents a new feature, and correlates to a SemVer minor.
90+
- `feat!`: or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major.
91+
92+
For a full list of types and rules, please visit [conventionalcommits.org](https://www.conventionalcommits.org/).
9293

9394
## Pull Request Process
9495

.github/copilot-instructions.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ This project is a VS Code extension that integrates PHPStan (Static Analysis) ru
5656
- Use Status Bar items effectively to show tool status (Ready, Error, etc.).
5757
- Provide "Quick Fixes" or buttons in error messages for common actions (like "Start DDEV").
5858

59+
5. **Commit Messages**:
60+
- STRICTLY follow [Conventional Commits](https://www.conventionalcommits.org/) format: `type(scope): description`.
61+
- Release Please assumes you are using Conventional Commit messages.
62+
- Most important prefixes:
63+
- `fix`: bug fixes (SemVer patch).
64+
- `feat`: new features (SemVer minor).
65+
- `feat!`, `fix!`, `refactor!`: breaking changes (SemVer major).
66+
5967
## Common Tasks
6068

6169
- **Adding a new setting**:

.github/workflows/commitlint.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Commit Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
commitlint:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
steps:
11+
- uses: actions/checkout@v5
12+
with:
13+
fetch-depth: 0
14+
- uses: actions/setup-node@v5
15+
with:
16+
node-version: latest
17+
- name: Install dependencies
18+
run: npm ci
19+
- name: Validate current commit (last commit)
20+
if: github.event_name == 'push'
21+
run: npx commitlint --from HEAD~1 --to HEAD --verbose
22+
- name: Validate PR commits
23+
if: github.event_name == 'pull_request'
24+
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

.husky/commit-msg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
npx --no -- commitlint --edit $1

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
npm run lint

.husky/pre-push

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
npm test

commitlint.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'body-max-line-length': [2, 'always', 300],
5+
'footer-max-line-length': [2, 'always', 300],
6+
},
7+
};
8+

0 commit comments

Comments
 (0)