@jmlweb/commitlint-config 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +142 -27
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @jmlweb/commitlint-config
|
|
2
2
|
|
|
3
|
+
## 2.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4a9ece1: Update documentation to use pnpm commands instead of npm
|
|
8
|
+
|
|
9
|
+
## 2.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 6b73301: Add changelog section with link to CHANGELOG.md in package READMEs
|
|
14
|
+
|
|
3
15
|
## 2.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -7,27 +7,23 @@
|
|
|
7
7
|
|
|
8
8
|
> Shared commitlint configuration for enforcing Conventional Commits across projects. Flexible design works out-of-the-box for any project, with optional scope restrictions.
|
|
9
9
|
|
|
10
|
-
## Features
|
|
10
|
+
## ✨ Features
|
|
11
11
|
|
|
12
|
-
- Enforces [Conventional Commits](https://conventionalcommits.org) specification
|
|
13
|
-
- **No scope restrictions by default
|
|
14
|
-
- Configurable scopes when you need them
|
|
15
|
-
- Custom
|
|
16
|
-
- TypeScript
|
|
12
|
+
- 📝 **Conventional Commits**: Enforces [Conventional Commits](https://conventionalcommits.org) specification
|
|
13
|
+
- 🎯 **Flexible Scopes**: No scope restrictions by default - works with any project structure
|
|
14
|
+
- ⚙️ **Configurable**: Customizable scopes when you need them
|
|
15
|
+
- 🚫 **Custom Ignores**: Ignore functions for merge commits, dependabot, etc.
|
|
16
|
+
- 📦 **TypeScript Support**: Full type definitions included
|
|
17
17
|
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm install --save-dev @jmlweb/commitlint-config @commitlint/cli @commitlint/config-conventional
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Or with pnpm:
|
|
18
|
+
## 📦 Installation
|
|
25
19
|
|
|
26
20
|
```bash
|
|
27
21
|
pnpm add -D @jmlweb/commitlint-config @commitlint/cli @commitlint/config-conventional
|
|
28
22
|
```
|
|
29
23
|
|
|
30
|
-
|
|
24
|
+
> 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
|
|
25
|
+
|
|
26
|
+
## 🚀 Quick Start
|
|
31
27
|
|
|
32
28
|
Create a `commitlint.config.js` file in your project root:
|
|
33
29
|
|
|
@@ -39,7 +35,7 @@ export default commitlintConfig;
|
|
|
39
35
|
|
|
40
36
|
That's it! Any commit type/scope following Conventional Commits is allowed.
|
|
41
37
|
|
|
42
|
-
##
|
|
38
|
+
## 💡 Examples
|
|
43
39
|
|
|
44
40
|
### No Scope Restrictions (Default)
|
|
45
41
|
|
|
@@ -94,7 +90,41 @@ export default createCommitlintConfig({
|
|
|
94
90
|
});
|
|
95
91
|
```
|
|
96
92
|
|
|
97
|
-
##
|
|
93
|
+
## 🤔 Why Use This?
|
|
94
|
+
|
|
95
|
+
> **Philosophy**: Structured commit messages enable automation, improve collaboration, and make project history meaningful and navigable.
|
|
96
|
+
|
|
97
|
+
This package enforces Conventional Commits to standardize commit messages across teams. Structured commits aren't just about consistency - they enable automated versioning, changelog generation, and make your git history actually useful for understanding project evolution.
|
|
98
|
+
|
|
99
|
+
### Design Decisions
|
|
100
|
+
|
|
101
|
+
**Conventional Commits Format**: Structured commit messages with types
|
|
102
|
+
|
|
103
|
+
- **Why**: The Conventional Commits specification enables powerful automation like semantic-release (automatic versioning), automatic changelog generation, and better git history navigation. It forces developers to think about what their change actually does (feat vs fix vs refactor), which improves code review quality
|
|
104
|
+
- **Trade-off**: Slightly more overhead when committing - must categorize changes. But the automation benefits and improved history are worth it
|
|
105
|
+
- **When to override**: For personal projects where automation isn't needed. But even solo developers benefit from clear commit history
|
|
106
|
+
|
|
107
|
+
**No Scope Restrictions by Default**: Works for any project structure
|
|
108
|
+
|
|
109
|
+
- **Why**: Different projects have different scopes (monorepo packages, feature areas, components). Not enforcing scopes makes this config flexible and zero-configuration for most projects. Teams can add scope restrictions when needed
|
|
110
|
+
- **Trade-off**: No validation that scopes make sense for your project. But this prevents the config from being opinionated about project structure
|
|
111
|
+
- **When to override**: For monorepos or large projects, define allowed scopes to ensure consistency (e.g., `['api', 'ui', 'docs']`)
|
|
112
|
+
|
|
113
|
+
**100 Character Header Limit**: Readable in all tools
|
|
114
|
+
|
|
115
|
+
- **Why**: 100 characters fits comfortably in GitHub's UI, terminal output, and git GUIs without wrapping. It's long enough for descriptive messages but short enough to enforce conciseness. This makes git log and GitHub history readable
|
|
116
|
+
- **Trade-off**: Sometimes you want longer descriptions. But that's what the body is for
|
|
117
|
+
- **When to override**: For teams that prefer shorter (72 chars) or longer headers. But 100 is a good standard
|
|
118
|
+
|
|
119
|
+
**Flexible Scope Requirement**: Optional by default
|
|
120
|
+
|
|
121
|
+
- **Why**: Not all changes fit neatly into scopes. Making scopes optional allows quick commits while still enabling teams to enforce scopes when structure is important (like in monorepos where scope = package name)
|
|
122
|
+
- **Trade-off**: Scopes aren't enforced unless explicitly enabled
|
|
123
|
+
- **When to override**: Set `scopeRequired: true` for monorepos or projects where scope categorization is important
|
|
124
|
+
|
|
125
|
+
## 📋 Configuration Details
|
|
126
|
+
|
|
127
|
+
### Commit Message Format
|
|
98
128
|
|
|
99
129
|
This configuration enforces the Conventional Commits format:
|
|
100
130
|
|
|
@@ -118,7 +148,7 @@ test: add unit tests for utils
|
|
|
118
148
|
ci: add GitHub Actions workflow
|
|
119
149
|
```
|
|
120
150
|
|
|
121
|
-
|
|
151
|
+
### Allowed Types
|
|
122
152
|
|
|
123
153
|
| Type | Description |
|
|
124
154
|
| ---------- | ------------------------------------- |
|
|
@@ -134,7 +164,7 @@ ci: add GitHub Actions workflow
|
|
|
134
164
|
| `build` | Build system changes |
|
|
135
165
|
| `revert` | Reverting previous commits |
|
|
136
166
|
|
|
137
|
-
|
|
167
|
+
### Configuration Options
|
|
138
168
|
|
|
139
169
|
| Option | Type | Default | Description |
|
|
140
170
|
| ------------------ | --------------------------------- | ----------- | ---------------------------------------------- |
|
|
@@ -146,7 +176,7 @@ ci: add GitHub Actions workflow
|
|
|
146
176
|
| `bodyRequired` | `boolean` | `false` | Whether to require a commit body |
|
|
147
177
|
| `ignores` | `((commit: string) => boolean)[]` | `undefined` | Functions to ignore certain commits |
|
|
148
178
|
|
|
149
|
-
|
|
179
|
+
### Exports
|
|
150
180
|
|
|
151
181
|
```typescript
|
|
152
182
|
// Default config - no scope restrictions
|
|
@@ -159,21 +189,63 @@ import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
|
159
189
|
import { COMMIT_TYPES } from '@jmlweb/commitlint-config';
|
|
160
190
|
```
|
|
161
191
|
|
|
162
|
-
##
|
|
192
|
+
## 🎯 When to Use
|
|
193
|
+
|
|
194
|
+
Use this configuration when you want:
|
|
195
|
+
|
|
196
|
+
- ✅ Enforce Conventional Commits specification across your project
|
|
197
|
+
- ✅ Automatic changelog generation from commit messages
|
|
198
|
+
- ✅ Consistent commit message format across team members
|
|
199
|
+
- ✅ Optional scope restrictions for monorepos
|
|
200
|
+
- ✅ Integration with semantic-release or standard-version
|
|
201
|
+
|
|
202
|
+
**For projects without commitlint**, consider starting with this package to improve commit quality and enable automated versioning.
|
|
203
|
+
|
|
204
|
+
## 🔧 Extending the Configuration
|
|
205
|
+
|
|
206
|
+
You can extend the configuration for your specific needs:
|
|
207
|
+
|
|
208
|
+
### Adding Custom Scopes
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
212
|
+
|
|
213
|
+
export default createCommitlintConfig({
|
|
214
|
+
scopes: ['frontend', 'backend', 'shared', 'docs'],
|
|
215
|
+
additionalTypes: ['wip'], // Add work-in-progress type
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Stricter Rules
|
|
163
220
|
|
|
164
|
-
|
|
221
|
+
```typescript
|
|
222
|
+
import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
223
|
+
|
|
224
|
+
export default createCommitlintConfig({
|
|
225
|
+
scopes: ['core', 'api', 'ui'],
|
|
226
|
+
scopeRequired: true,
|
|
227
|
+
bodyRequired: true,
|
|
228
|
+
headerMaxLength: 72,
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## 📝 Usage with Scripts
|
|
233
|
+
|
|
234
|
+
### Integration with Husky
|
|
235
|
+
|
|
236
|
+
#### Step 1 - Install husky
|
|
165
237
|
|
|
166
238
|
```bash
|
|
167
239
|
pnpm add -D husky
|
|
168
240
|
```
|
|
169
241
|
|
|
170
|
-
|
|
242
|
+
#### Step 2 - Initialize husky
|
|
171
243
|
|
|
172
244
|
```bash
|
|
173
245
|
pnpm exec husky init
|
|
174
246
|
```
|
|
175
247
|
|
|
176
|
-
|
|
248
|
+
#### Step 3 - Add commit-msg hook
|
|
177
249
|
|
|
178
250
|
Create or edit `.husky/commit-msg`:
|
|
179
251
|
|
|
@@ -181,7 +253,7 @@ Create or edit `.husky/commit-msg`:
|
|
|
181
253
|
pnpm exec commitlint --edit $1
|
|
182
254
|
```
|
|
183
255
|
|
|
184
|
-
|
|
256
|
+
#### Step 4 - Test your setup
|
|
185
257
|
|
|
186
258
|
```bash
|
|
187
259
|
# This should fail
|
|
@@ -191,18 +263,61 @@ git commit -m "bad commit message"
|
|
|
191
263
|
git commit -m "feat: add new feature"
|
|
192
264
|
```
|
|
193
265
|
|
|
194
|
-
|
|
266
|
+
### Package.json Scripts
|
|
267
|
+
|
|
268
|
+
```json
|
|
269
|
+
{
|
|
270
|
+
"scripts": {
|
|
271
|
+
"commitlint": "commitlint --edit",
|
|
272
|
+
"commitlint:all": "commitlint --from HEAD~10"
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## 📋 Requirements
|
|
195
278
|
|
|
196
279
|
- **Node.js** >= 18.0.0
|
|
197
280
|
- **@commitlint/cli** >= 19.0.0
|
|
198
281
|
- **@commitlint/config-conventional** >= 19.0.0
|
|
199
282
|
|
|
200
|
-
##
|
|
283
|
+
## 📦 Peer Dependencies
|
|
284
|
+
|
|
285
|
+
This package requires the following peer dependencies:
|
|
286
|
+
|
|
287
|
+
- `@commitlint/cli` (>=19.0.0)
|
|
288
|
+
- `@commitlint/config-conventional` (>=19.0.0)
|
|
289
|
+
|
|
290
|
+
## 🔗 Related Packages
|
|
291
|
+
|
|
292
|
+
### Internal Packages
|
|
201
293
|
|
|
202
294
|
- [`@jmlweb/eslint-config-base`](../eslint-config-base) - ESLint configuration for TypeScript
|
|
203
295
|
- [`@jmlweb/prettier-config-base`](../prettier-config-base) - Prettier configuration
|
|
204
296
|
- [`@jmlweb/tsconfig-base`](../tsconfig-base) - TypeScript configuration
|
|
205
297
|
|
|
206
|
-
|
|
298
|
+
### External Tools
|
|
299
|
+
|
|
300
|
+
- [commitlint](https://commitlint.js.org/) - Lint commit messages according to conventional commits
|
|
301
|
+
- [Conventional Commits](https://www.conventionalcommits.org/) - A specification for adding meaning to commit messages
|
|
302
|
+
- [Husky](https://typicode.github.io/husky/) - Git hooks made easy (recommended for pre-commit integration)
|
|
303
|
+
- [semantic-release](https://semantic-release.gitbook.io/) - Automated versioning and changelog generation
|
|
304
|
+
|
|
305
|
+
## 🔄 Migration Guide
|
|
306
|
+
|
|
307
|
+
### Upgrading to a New Version
|
|
308
|
+
|
|
309
|
+
> **Note:** If no breaking changes were introduced in a version, it's safe to upgrade without additional steps.
|
|
310
|
+
|
|
311
|
+
**No breaking changes have been introduced yet.** This package follows semantic versioning. When breaking changes are introduced, detailed migration instructions will be provided here.
|
|
312
|
+
|
|
313
|
+
For version history, see the [Changelog](./CHANGELOG.md).
|
|
314
|
+
|
|
315
|
+
**Need Help?** If you encounter issues during migration, please [open an issue](https://github.com/jmlweb/tooling/issues/new).
|
|
316
|
+
|
|
317
|
+
## 📜 Changelog
|
|
318
|
+
|
|
319
|
+
See [CHANGELOG.md](./CHANGELOG.md) for version history and release notes.
|
|
320
|
+
|
|
321
|
+
## 📄 License
|
|
207
322
|
|
|
208
323
|
MIT
|