@jmlweb/commitlint-config 0.0.0 → 2.0.0
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 +82 -92
- package/dist/index.cjs +17 -37
- package/dist/index.d.cts +35 -15
- package/dist/index.d.ts +35 -15
- package/dist/index.js +17 -36
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @jmlweb/commitlint-config
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 738525c: Make config generic by removing hardcoded scopes and adding flexible scope options
|
|
8
|
+
|
|
9
|
+
## 1.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- 165d410: Make config generic by removing hardcoded scopes and adding flexible scope options
|
|
14
|
+
|
|
3
15
|
## 0.0.0
|
|
4
16
|
|
|
5
17
|
Initial development version.
|
package/README.md
CHANGED
|
@@ -5,16 +5,15 @@
|
|
|
5
5
|
[](https://nodejs.org/)
|
|
6
6
|
[](https://conventionalcommits.org)
|
|
7
7
|
|
|
8
|
-
> Shared commitlint configuration for enforcing Conventional Commits across projects.
|
|
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
10
|
## Features
|
|
11
11
|
|
|
12
12
|
- Enforces [Conventional Commits](https://conventionalcommits.org) specification
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
13
|
+
- **No scope restrictions by default** - works with any project structure
|
|
14
|
+
- Configurable scopes when you need them
|
|
15
|
+
- Custom ignore functions for merge commits, dependabot, etc.
|
|
16
16
|
- TypeScript support with full type definitions
|
|
17
|
-
- Easy integration with husky for Git hooks
|
|
18
17
|
|
|
19
18
|
## Installation
|
|
20
19
|
|
|
@@ -38,12 +37,61 @@ import commitlintConfig from '@jmlweb/commitlint-config';
|
|
|
38
37
|
export default commitlintConfig;
|
|
39
38
|
```
|
|
40
39
|
|
|
41
|
-
|
|
40
|
+
That's it! Any commit type/scope following Conventional Commits is allowed.
|
|
41
|
+
|
|
42
|
+
## Usage Examples
|
|
43
|
+
|
|
44
|
+
### No Scope Restrictions (Default)
|
|
42
45
|
|
|
43
46
|
```javascript
|
|
44
|
-
|
|
47
|
+
// commitlint.config.js
|
|
48
|
+
import commitlintConfig from '@jmlweb/commitlint-config';
|
|
49
|
+
|
|
50
|
+
export default commitlintConfig;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Valid commits:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
feat: add new feature
|
|
57
|
+
fix(auth): resolve login issue
|
|
58
|
+
chore(whatever-you-want): update deps
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Define Your Own Scopes
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// commitlint.config.ts
|
|
65
|
+
import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
66
|
+
|
|
67
|
+
export default createCommitlintConfig({
|
|
68
|
+
scopes: ['api', 'ui', 'database', 'auth', 'deps'],
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Strict Configuration
|
|
45
73
|
|
|
46
|
-
|
|
74
|
+
```typescript
|
|
75
|
+
import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
76
|
+
|
|
77
|
+
export default createCommitlintConfig({
|
|
78
|
+
scopes: ['core', 'utils', 'config'],
|
|
79
|
+
scopeRequired: true,
|
|
80
|
+
headerMaxLength: 72,
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Ignore Specific Commits
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
88
|
+
|
|
89
|
+
export default createCommitlintConfig({
|
|
90
|
+
ignores: [
|
|
91
|
+
(commit) => commit.startsWith('Merge'),
|
|
92
|
+
(commit) => /^\[dependabot\]/.test(commit),
|
|
93
|
+
],
|
|
94
|
+
});
|
|
47
95
|
```
|
|
48
96
|
|
|
49
97
|
## Commit Message Format
|
|
@@ -58,15 +106,15 @@ This configuration enforces the Conventional Commits format:
|
|
|
58
106
|
[optional footer(s)]
|
|
59
107
|
```
|
|
60
108
|
|
|
61
|
-
###
|
|
109
|
+
### Example Commits
|
|
62
110
|
|
|
63
111
|
```text
|
|
64
|
-
feat(
|
|
65
|
-
fix
|
|
66
|
-
docs: update README with
|
|
112
|
+
feat(api): add user authentication endpoint
|
|
113
|
+
fix: correct date parsing logic
|
|
114
|
+
docs: update README with examples
|
|
67
115
|
chore(deps): update dependencies
|
|
68
|
-
refactor(
|
|
69
|
-
test
|
|
116
|
+
refactor(ui): simplify form validation
|
|
117
|
+
test: add unit tests for utils
|
|
70
118
|
ci: add GitHub Actions workflow
|
|
71
119
|
```
|
|
72
120
|
|
|
@@ -86,73 +134,46 @@ ci: add GitHub Actions workflow
|
|
|
86
134
|
| `build` | Build system changes |
|
|
87
135
|
| `revert` | Reverting previous commits |
|
|
88
136
|
|
|
89
|
-
##
|
|
90
|
-
|
|
91
|
-
### Package Scopes
|
|
92
|
-
|
|
93
|
-
- `eslint-config-base`, `eslint-config-base-js`, `eslint-config-react`
|
|
94
|
-
- `prettier-config-base`, `prettier-config-tailwind`
|
|
95
|
-
- `tsconfig-base`, `tsconfig-internal`, `tsconfig-nextjs`, `tsconfig-react`
|
|
96
|
-
- `tsup-config-base`
|
|
97
|
-
- `vitest-config`
|
|
98
|
-
- `commitlint-config`
|
|
99
|
-
|
|
100
|
-
### Common Scopes
|
|
101
|
-
|
|
102
|
-
- `deps` - Dependency updates
|
|
103
|
-
- `release` - Release-related changes
|
|
104
|
-
- `scripts` - Build/CI scripts
|
|
105
|
-
- `workspace` - Workspace configuration
|
|
137
|
+
## Configuration Options
|
|
106
138
|
|
|
107
|
-
|
|
139
|
+
| Option | Type | Default | Description |
|
|
140
|
+
| ------------------ | --------------------------------- | ----------- | ---------------------------------------------- |
|
|
141
|
+
| `scopes` | `string[]` | `undefined` | Define allowed scopes (enables scope checking) |
|
|
142
|
+
| `additionalScopes` | `string[]` | `[]` | Add scopes when extending base configs |
|
|
143
|
+
| `additionalTypes` | `string[]` | `[]` | Additional commit types to allow |
|
|
144
|
+
| `headerMaxLength` | `number` | `100` | Maximum length for the header line |
|
|
145
|
+
| `scopeRequired` | `boolean` | `false` | Whether to require a scope |
|
|
146
|
+
| `bodyRequired` | `boolean` | `false` | Whether to require a commit body |
|
|
147
|
+
| `ignores` | `((commit: string) => boolean)[]` | `undefined` | Functions to ignore certain commits |
|
|
108
148
|
|
|
109
|
-
|
|
149
|
+
## Exports
|
|
110
150
|
|
|
111
151
|
```typescript
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
export default createCommitlintConfig({
|
|
115
|
-
additionalScopes: ['api', 'ui', 'database', 'auth'],
|
|
116
|
-
});
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Stricter Configuration
|
|
152
|
+
// Default config - no scope restrictions
|
|
153
|
+
import config from '@jmlweb/commitlint-config';
|
|
120
154
|
|
|
121
|
-
|
|
155
|
+
// Factory function for custom configs
|
|
122
156
|
import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
123
157
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
headerMaxLength: 72,
|
|
127
|
-
bodyRequired: true,
|
|
128
|
-
});
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Adding Custom Types
|
|
132
|
-
|
|
133
|
-
```typescript
|
|
134
|
-
import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
135
|
-
|
|
136
|
-
export default createCommitlintConfig({
|
|
137
|
-
additionalTypes: ['wip', 'merge'],
|
|
138
|
-
});
|
|
158
|
+
// Commit types constant
|
|
159
|
+
import { COMMIT_TYPES } from '@jmlweb/commitlint-config';
|
|
139
160
|
```
|
|
140
161
|
|
|
141
162
|
## Integration with Husky
|
|
142
163
|
|
|
143
|
-
### Step 1
|
|
164
|
+
### Step 1 - Install husky
|
|
144
165
|
|
|
145
166
|
```bash
|
|
146
167
|
pnpm add -D husky
|
|
147
168
|
```
|
|
148
169
|
|
|
149
|
-
### Step 2
|
|
170
|
+
### Step 2 - Initialize husky
|
|
150
171
|
|
|
151
172
|
```bash
|
|
152
173
|
pnpm exec husky init
|
|
153
174
|
```
|
|
154
175
|
|
|
155
|
-
### Step 3
|
|
176
|
+
### Step 3 - Add commit-msg hook
|
|
156
177
|
|
|
157
178
|
Create or edit `.husky/commit-msg`:
|
|
158
179
|
|
|
@@ -160,7 +181,7 @@ Create or edit `.husky/commit-msg`:
|
|
|
160
181
|
pnpm exec commitlint --edit $1
|
|
161
182
|
```
|
|
162
183
|
|
|
163
|
-
### Step 4
|
|
184
|
+
### Step 4 - Test your setup
|
|
164
185
|
|
|
165
186
|
```bash
|
|
166
187
|
# This should fail
|
|
@@ -170,37 +191,6 @@ git commit -m "bad commit message"
|
|
|
170
191
|
git commit -m "feat: add new feature"
|
|
171
192
|
```
|
|
172
193
|
|
|
173
|
-
## Configuration Options
|
|
174
|
-
|
|
175
|
-
| Option | Type | Default | Description |
|
|
176
|
-
| ------------------ | ---------- | ------- | ---------------------------------- |
|
|
177
|
-
| `additionalTypes` | `string[]` | `[]` | Additional commit types to allow |
|
|
178
|
-
| `additionalScopes` | `string[]` | `[]` | Additional scopes to allow |
|
|
179
|
-
| `headerMaxLength` | `number` | `100` | Maximum length for the header line |
|
|
180
|
-
| `scopeRequired` | `boolean` | `false` | Whether to require a scope |
|
|
181
|
-
| `bodyRequired` | `boolean` | `false` | Whether to require a commit body |
|
|
182
|
-
|
|
183
|
-
## Exports
|
|
184
|
-
|
|
185
|
-
### Default Export
|
|
186
|
-
|
|
187
|
-
The default export is a ready-to-use commitlint configuration:
|
|
188
|
-
|
|
189
|
-
```javascript
|
|
190
|
-
import config from '@jmlweb/commitlint-config';
|
|
191
|
-
export default config;
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### Named Exports
|
|
195
|
-
|
|
196
|
-
```typescript
|
|
197
|
-
import {
|
|
198
|
-
createCommitlintConfig, // Factory function for custom configs
|
|
199
|
-
COMMIT_TYPES, // Array of allowed commit types
|
|
200
|
-
COMMIT_SCOPES, // Array of allowed scopes
|
|
201
|
-
} from '@jmlweb/commitlint-config';
|
|
202
|
-
```
|
|
203
|
-
|
|
204
194
|
## Requirements
|
|
205
195
|
|
|
206
196
|
- **Node.js** >= 18.0.0
|
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
COMMIT_SCOPES: () => COMMIT_SCOPES,
|
|
24
23
|
COMMIT_TYPES: () => COMMIT_TYPES,
|
|
25
24
|
createCommitlintConfig: () => createCommitlintConfig,
|
|
26
25
|
default: () => index_default
|
|
@@ -50,54 +49,32 @@ var COMMIT_TYPES = [
|
|
|
50
49
|
"revert"
|
|
51
50
|
// Reverting previous commits
|
|
52
51
|
];
|
|
53
|
-
var
|
|
54
|
-
// ESLint configs
|
|
55
|
-
"eslint-config-base",
|
|
56
|
-
"eslint-config-base-js",
|
|
57
|
-
"eslint-config-react",
|
|
58
|
-
// Prettier configs
|
|
59
|
-
"prettier-config-base",
|
|
60
|
-
"prettier-config-tailwind",
|
|
61
|
-
// TypeScript configs
|
|
62
|
-
"tsconfig-base",
|
|
63
|
-
"tsconfig-internal",
|
|
64
|
-
"tsconfig-nextjs",
|
|
65
|
-
"tsconfig-react",
|
|
66
|
-
// Build configs
|
|
67
|
-
"tsup-config-base",
|
|
68
|
-
// Test configs
|
|
69
|
-
"vitest-config",
|
|
70
|
-
// Commitlint config
|
|
71
|
-
"commitlint-config",
|
|
72
|
-
// Common scopes
|
|
73
|
-
"deps",
|
|
74
|
-
// Dependency updates
|
|
75
|
-
"release",
|
|
76
|
-
// Release-related changes
|
|
77
|
-
"scripts",
|
|
78
|
-
// Build/CI scripts
|
|
79
|
-
"workspace"
|
|
80
|
-
// Workspace configuration
|
|
81
|
-
];
|
|
82
|
-
var createCommitlintConfig = (options = {}) => {
|
|
52
|
+
var createCommitlintConfig = (options = {}, baseScopes) => {
|
|
83
53
|
const {
|
|
84
54
|
additionalTypes = [],
|
|
55
|
+
scopes,
|
|
85
56
|
additionalScopes = [],
|
|
86
57
|
headerMaxLength = 100,
|
|
87
58
|
scopeRequired = false,
|
|
88
|
-
bodyRequired = false
|
|
59
|
+
bodyRequired = false,
|
|
60
|
+
ignores
|
|
89
61
|
} = options;
|
|
90
62
|
const allTypes = [...COMMIT_TYPES, ...additionalTypes];
|
|
91
|
-
|
|
92
|
-
|
|
63
|
+
let finalScopes;
|
|
64
|
+
if (scopes !== void 0) {
|
|
65
|
+
finalScopes = scopes;
|
|
66
|
+
} else if (baseScopes !== void 0 || additionalScopes.length > 0) {
|
|
67
|
+
finalScopes = [...baseScopes ?? [], ...additionalScopes];
|
|
68
|
+
}
|
|
69
|
+
const config2 = {
|
|
93
70
|
extends: ["@commitlint/config-conventional"],
|
|
94
71
|
rules: {
|
|
95
72
|
// Type rules
|
|
96
73
|
"type-enum": [2, "always", allTypes],
|
|
97
74
|
"type-case": [2, "always", "lower-case"],
|
|
98
75
|
"type-empty": [2, "never"],
|
|
99
|
-
// Scope rules
|
|
100
|
-
"scope-enum": [2, "always",
|
|
76
|
+
// Scope rules - only enforce enum if scopes are defined
|
|
77
|
+
"scope-enum": finalScopes ? [2, "always", finalScopes] : [0],
|
|
101
78
|
"scope-case": [2, "always", "kebab-case"],
|
|
102
79
|
"scope-empty": scopeRequired ? [2, "never"] : [0],
|
|
103
80
|
// Subject rules
|
|
@@ -115,12 +92,15 @@ var createCommitlintConfig = (options = {}) => {
|
|
|
115
92
|
"footer-max-line-length": [2, "always", 100]
|
|
116
93
|
}
|
|
117
94
|
};
|
|
95
|
+
if (ignores && ignores.length > 0) {
|
|
96
|
+
config2.ignores = ignores;
|
|
97
|
+
}
|
|
98
|
+
return config2;
|
|
118
99
|
};
|
|
119
100
|
var config = createCommitlintConfig();
|
|
120
101
|
var index_default = config;
|
|
121
102
|
// Annotate the CommonJS export names for ESM import in node:
|
|
122
103
|
0 && (module.exports = {
|
|
123
|
-
COMMIT_SCOPES,
|
|
124
104
|
COMMIT_TYPES,
|
|
125
105
|
createCommitlintConfig
|
|
126
106
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -5,24 +5,25 @@ export { UserConfig } from '@commitlint/types';
|
|
|
5
5
|
* Allowed commit types following Conventional Commits specification
|
|
6
6
|
*/
|
|
7
7
|
declare const COMMIT_TYPES: readonly ["feat", "fix", "docs", "chore", "refactor", "test", "ci", "perf", "style", "build", "revert"];
|
|
8
|
-
/**
|
|
9
|
-
* Allowed scopes matching @jmlweb package names
|
|
10
|
-
* These are extracted from the package names without the @jmlweb/ prefix
|
|
11
|
-
*/
|
|
12
|
-
declare const COMMIT_SCOPES: readonly ["eslint-config-base", "eslint-config-base-js", "eslint-config-react", "prettier-config-base", "prettier-config-tailwind", "tsconfig-base", "tsconfig-internal", "tsconfig-nextjs", "tsconfig-react", "tsup-config-base", "vitest-config", "commitlint-config", "deps", "release", "scripts", "workspace"];
|
|
13
8
|
type CommitType = (typeof COMMIT_TYPES)[number];
|
|
14
|
-
type CommitScope = (typeof COMMIT_SCOPES)[number];
|
|
15
9
|
/**
|
|
16
10
|
* Options for creating a commitlint configuration
|
|
17
11
|
*/
|
|
18
12
|
interface CommitlintConfigOptions {
|
|
19
13
|
/**
|
|
20
|
-
* Additional commit types to allow
|
|
14
|
+
* Additional commit types to allow (merged with defaults)
|
|
21
15
|
* @default []
|
|
22
16
|
*/
|
|
23
17
|
additionalTypes?: string[];
|
|
24
18
|
/**
|
|
25
|
-
*
|
|
19
|
+
* Scopes to allow. When provided, completely replaces any base scopes.
|
|
20
|
+
* Use this when you want full control over allowed scopes.
|
|
21
|
+
* @default undefined (no scope restrictions)
|
|
22
|
+
*/
|
|
23
|
+
scopes?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Additional scopes to allow (merged with base scopes if any).
|
|
26
|
+
* Only used when `scopes` is not provided.
|
|
26
27
|
* @default []
|
|
27
28
|
*/
|
|
28
29
|
additionalScopes?: string[];
|
|
@@ -41,23 +42,29 @@ interface CommitlintConfigOptions {
|
|
|
41
42
|
* @default false
|
|
42
43
|
*/
|
|
43
44
|
bodyRequired?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Custom function to ignore certain commits (e.g., merge commits, dependabot)
|
|
47
|
+
* Return true to skip validation for a commit
|
|
48
|
+
*/
|
|
49
|
+
ignores?: ((commit: string) => boolean)[];
|
|
44
50
|
}
|
|
45
51
|
/**
|
|
46
|
-
* Creates a commitlint configuration with sensible defaults
|
|
52
|
+
* Creates a commitlint configuration with sensible defaults.
|
|
53
|
+
* By default, no scope restrictions are applied - any scope is allowed.
|
|
47
54
|
*
|
|
48
55
|
* @example
|
|
49
56
|
* ```typescript
|
|
50
|
-
* // Simple usage
|
|
57
|
+
* // Simple usage - any scope is allowed
|
|
51
58
|
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
52
59
|
* export default createCommitlintConfig();
|
|
53
60
|
* ```
|
|
54
61
|
*
|
|
55
62
|
* @example
|
|
56
63
|
* ```typescript
|
|
57
|
-
* //
|
|
64
|
+
* // Define allowed scopes for your project
|
|
58
65
|
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
59
66
|
* export default createCommitlintConfig({
|
|
60
|
-
*
|
|
67
|
+
* scopes: ['api', 'ui', 'database', 'auth'],
|
|
61
68
|
* });
|
|
62
69
|
* ```
|
|
63
70
|
*
|
|
@@ -66,15 +73,28 @@ interface CommitlintConfigOptions {
|
|
|
66
73
|
* // Strict configuration with required scope
|
|
67
74
|
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
68
75
|
* export default createCommitlintConfig({
|
|
76
|
+
* scopes: ['core', 'utils', 'deps'],
|
|
69
77
|
* scopeRequired: true,
|
|
70
78
|
* headerMaxLength: 72,
|
|
71
79
|
* });
|
|
72
80
|
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* // Ignore merge commits and dependabot
|
|
85
|
+
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
86
|
+
* export default createCommitlintConfig({
|
|
87
|
+
* ignores: [
|
|
88
|
+
* (commit) => commit.startsWith('Merge'),
|
|
89
|
+
* (commit) => /^chore\(deps\)/.test(commit),
|
|
90
|
+
* ],
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
73
93
|
*/
|
|
74
|
-
declare const createCommitlintConfig: (options?: CommitlintConfigOptions) => UserConfig;
|
|
94
|
+
declare const createCommitlintConfig: (options?: CommitlintConfigOptions, baseScopes?: readonly string[]) => UserConfig;
|
|
75
95
|
/**
|
|
76
96
|
* Default commitlint configuration
|
|
77
|
-
*
|
|
97
|
+
* Generic configuration with no scope restrictions - suitable for any project.
|
|
78
98
|
*
|
|
79
99
|
* @example
|
|
80
100
|
* ```javascript
|
|
@@ -85,4 +105,4 @@ declare const createCommitlintConfig: (options?: CommitlintConfigOptions) => Use
|
|
|
85
105
|
*/
|
|
86
106
|
declare const config: UserConfig;
|
|
87
107
|
|
|
88
|
-
export {
|
|
108
|
+
export { COMMIT_TYPES, type CommitType, type CommitlintConfigOptions, createCommitlintConfig, config as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,24 +5,25 @@ export { UserConfig } from '@commitlint/types';
|
|
|
5
5
|
* Allowed commit types following Conventional Commits specification
|
|
6
6
|
*/
|
|
7
7
|
declare const COMMIT_TYPES: readonly ["feat", "fix", "docs", "chore", "refactor", "test", "ci", "perf", "style", "build", "revert"];
|
|
8
|
-
/**
|
|
9
|
-
* Allowed scopes matching @jmlweb package names
|
|
10
|
-
* These are extracted from the package names without the @jmlweb/ prefix
|
|
11
|
-
*/
|
|
12
|
-
declare const COMMIT_SCOPES: readonly ["eslint-config-base", "eslint-config-base-js", "eslint-config-react", "prettier-config-base", "prettier-config-tailwind", "tsconfig-base", "tsconfig-internal", "tsconfig-nextjs", "tsconfig-react", "tsup-config-base", "vitest-config", "commitlint-config", "deps", "release", "scripts", "workspace"];
|
|
13
8
|
type CommitType = (typeof COMMIT_TYPES)[number];
|
|
14
|
-
type CommitScope = (typeof COMMIT_SCOPES)[number];
|
|
15
9
|
/**
|
|
16
10
|
* Options for creating a commitlint configuration
|
|
17
11
|
*/
|
|
18
12
|
interface CommitlintConfigOptions {
|
|
19
13
|
/**
|
|
20
|
-
* Additional commit types to allow
|
|
14
|
+
* Additional commit types to allow (merged with defaults)
|
|
21
15
|
* @default []
|
|
22
16
|
*/
|
|
23
17
|
additionalTypes?: string[];
|
|
24
18
|
/**
|
|
25
|
-
*
|
|
19
|
+
* Scopes to allow. When provided, completely replaces any base scopes.
|
|
20
|
+
* Use this when you want full control over allowed scopes.
|
|
21
|
+
* @default undefined (no scope restrictions)
|
|
22
|
+
*/
|
|
23
|
+
scopes?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Additional scopes to allow (merged with base scopes if any).
|
|
26
|
+
* Only used when `scopes` is not provided.
|
|
26
27
|
* @default []
|
|
27
28
|
*/
|
|
28
29
|
additionalScopes?: string[];
|
|
@@ -41,23 +42,29 @@ interface CommitlintConfigOptions {
|
|
|
41
42
|
* @default false
|
|
42
43
|
*/
|
|
43
44
|
bodyRequired?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Custom function to ignore certain commits (e.g., merge commits, dependabot)
|
|
47
|
+
* Return true to skip validation for a commit
|
|
48
|
+
*/
|
|
49
|
+
ignores?: ((commit: string) => boolean)[];
|
|
44
50
|
}
|
|
45
51
|
/**
|
|
46
|
-
* Creates a commitlint configuration with sensible defaults
|
|
52
|
+
* Creates a commitlint configuration with sensible defaults.
|
|
53
|
+
* By default, no scope restrictions are applied - any scope is allowed.
|
|
47
54
|
*
|
|
48
55
|
* @example
|
|
49
56
|
* ```typescript
|
|
50
|
-
* // Simple usage
|
|
57
|
+
* // Simple usage - any scope is allowed
|
|
51
58
|
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
52
59
|
* export default createCommitlintConfig();
|
|
53
60
|
* ```
|
|
54
61
|
*
|
|
55
62
|
* @example
|
|
56
63
|
* ```typescript
|
|
57
|
-
* //
|
|
64
|
+
* // Define allowed scopes for your project
|
|
58
65
|
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
59
66
|
* export default createCommitlintConfig({
|
|
60
|
-
*
|
|
67
|
+
* scopes: ['api', 'ui', 'database', 'auth'],
|
|
61
68
|
* });
|
|
62
69
|
* ```
|
|
63
70
|
*
|
|
@@ -66,15 +73,28 @@ interface CommitlintConfigOptions {
|
|
|
66
73
|
* // Strict configuration with required scope
|
|
67
74
|
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
68
75
|
* export default createCommitlintConfig({
|
|
76
|
+
* scopes: ['core', 'utils', 'deps'],
|
|
69
77
|
* scopeRequired: true,
|
|
70
78
|
* headerMaxLength: 72,
|
|
71
79
|
* });
|
|
72
80
|
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* // Ignore merge commits and dependabot
|
|
85
|
+
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
86
|
+
* export default createCommitlintConfig({
|
|
87
|
+
* ignores: [
|
|
88
|
+
* (commit) => commit.startsWith('Merge'),
|
|
89
|
+
* (commit) => /^chore\(deps\)/.test(commit),
|
|
90
|
+
* ],
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
73
93
|
*/
|
|
74
|
-
declare const createCommitlintConfig: (options?: CommitlintConfigOptions) => UserConfig;
|
|
94
|
+
declare const createCommitlintConfig: (options?: CommitlintConfigOptions, baseScopes?: readonly string[]) => UserConfig;
|
|
75
95
|
/**
|
|
76
96
|
* Default commitlint configuration
|
|
77
|
-
*
|
|
97
|
+
* Generic configuration with no scope restrictions - suitable for any project.
|
|
78
98
|
*
|
|
79
99
|
* @example
|
|
80
100
|
* ```javascript
|
|
@@ -85,4 +105,4 @@ declare const createCommitlintConfig: (options?: CommitlintConfigOptions) => Use
|
|
|
85
105
|
*/
|
|
86
106
|
declare const config: UserConfig;
|
|
87
107
|
|
|
88
|
-
export {
|
|
108
|
+
export { COMMIT_TYPES, type CommitType, type CommitlintConfigOptions, createCommitlintConfig, config as default };
|
package/dist/index.js
CHANGED
|
@@ -23,54 +23,32 @@ var COMMIT_TYPES = [
|
|
|
23
23
|
"revert"
|
|
24
24
|
// Reverting previous commits
|
|
25
25
|
];
|
|
26
|
-
var
|
|
27
|
-
// ESLint configs
|
|
28
|
-
"eslint-config-base",
|
|
29
|
-
"eslint-config-base-js",
|
|
30
|
-
"eslint-config-react",
|
|
31
|
-
// Prettier configs
|
|
32
|
-
"prettier-config-base",
|
|
33
|
-
"prettier-config-tailwind",
|
|
34
|
-
// TypeScript configs
|
|
35
|
-
"tsconfig-base",
|
|
36
|
-
"tsconfig-internal",
|
|
37
|
-
"tsconfig-nextjs",
|
|
38
|
-
"tsconfig-react",
|
|
39
|
-
// Build configs
|
|
40
|
-
"tsup-config-base",
|
|
41
|
-
// Test configs
|
|
42
|
-
"vitest-config",
|
|
43
|
-
// Commitlint config
|
|
44
|
-
"commitlint-config",
|
|
45
|
-
// Common scopes
|
|
46
|
-
"deps",
|
|
47
|
-
// Dependency updates
|
|
48
|
-
"release",
|
|
49
|
-
// Release-related changes
|
|
50
|
-
"scripts",
|
|
51
|
-
// Build/CI scripts
|
|
52
|
-
"workspace"
|
|
53
|
-
// Workspace configuration
|
|
54
|
-
];
|
|
55
|
-
var createCommitlintConfig = (options = {}) => {
|
|
26
|
+
var createCommitlintConfig = (options = {}, baseScopes) => {
|
|
56
27
|
const {
|
|
57
28
|
additionalTypes = [],
|
|
29
|
+
scopes,
|
|
58
30
|
additionalScopes = [],
|
|
59
31
|
headerMaxLength = 100,
|
|
60
32
|
scopeRequired = false,
|
|
61
|
-
bodyRequired = false
|
|
33
|
+
bodyRequired = false,
|
|
34
|
+
ignores
|
|
62
35
|
} = options;
|
|
63
36
|
const allTypes = [...COMMIT_TYPES, ...additionalTypes];
|
|
64
|
-
|
|
65
|
-
|
|
37
|
+
let finalScopes;
|
|
38
|
+
if (scopes !== void 0) {
|
|
39
|
+
finalScopes = scopes;
|
|
40
|
+
} else if (baseScopes !== void 0 || additionalScopes.length > 0) {
|
|
41
|
+
finalScopes = [...baseScopes ?? [], ...additionalScopes];
|
|
42
|
+
}
|
|
43
|
+
const config2 = {
|
|
66
44
|
extends: ["@commitlint/config-conventional"],
|
|
67
45
|
rules: {
|
|
68
46
|
// Type rules
|
|
69
47
|
"type-enum": [2, "always", allTypes],
|
|
70
48
|
"type-case": [2, "always", "lower-case"],
|
|
71
49
|
"type-empty": [2, "never"],
|
|
72
|
-
// Scope rules
|
|
73
|
-
"scope-enum": [2, "always",
|
|
50
|
+
// Scope rules - only enforce enum if scopes are defined
|
|
51
|
+
"scope-enum": finalScopes ? [2, "always", finalScopes] : [0],
|
|
74
52
|
"scope-case": [2, "always", "kebab-case"],
|
|
75
53
|
"scope-empty": scopeRequired ? [2, "never"] : [0],
|
|
76
54
|
// Subject rules
|
|
@@ -88,11 +66,14 @@ var createCommitlintConfig = (options = {}) => {
|
|
|
88
66
|
"footer-max-line-length": [2, "always", 100]
|
|
89
67
|
}
|
|
90
68
|
};
|
|
69
|
+
if (ignores && ignores.length > 0) {
|
|
70
|
+
config2.ignores = ignores;
|
|
71
|
+
}
|
|
72
|
+
return config2;
|
|
91
73
|
};
|
|
92
74
|
var config = createCommitlintConfig();
|
|
93
75
|
var index_default = config;
|
|
94
76
|
export {
|
|
95
|
-
COMMIT_SCOPES,
|
|
96
77
|
COMMIT_TYPES,
|
|
97
78
|
createCommitlintConfig,
|
|
98
79
|
index_default as default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jmlweb/commitlint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Shared commitlint configuration for enforcing Conventional Commits",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -32,7 +32,10 @@
|
|
|
32
32
|
],
|
|
33
33
|
"author": "jmlweb",
|
|
34
34
|
"license": "MIT",
|
|
35
|
-
"repository":
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/jmlweb/tooling.git"
|
|
38
|
+
},
|
|
36
39
|
"bugs": "https://github.com/jmlweb/tooling/issues",
|
|
37
40
|
"homepage": "https://github.com/jmlweb/tooling/tree/main/packages/commitlint-config#readme",
|
|
38
41
|
"engines": {
|