@jmlweb/commitlint-config 0.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 +5 -0
- package/README.md +218 -0
- package/dist/index.cjs +126 -0
- package/dist/index.d.cts +88 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +99 -0
- package/package.json +60 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# @jmlweb/commitlint-config
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@jmlweb/commitlint-config)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://conventionalcommits.org)
|
|
7
|
+
|
|
8
|
+
> Shared commitlint configuration for enforcing Conventional Commits across projects. Includes predefined scopes for @jmlweb packages and configurable options.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- Enforces [Conventional Commits](https://conventionalcommits.org) specification
|
|
13
|
+
- Predefined commit types: `feat`, `fix`, `docs`, `chore`, `refactor`, `test`, `ci`, `perf`, `style`, `build`, `revert`
|
|
14
|
+
- Predefined scopes matching @jmlweb package names
|
|
15
|
+
- Configurable options for custom scopes and stricter rules
|
|
16
|
+
- TypeScript support with full type definitions
|
|
17
|
+
- Easy integration with husky for Git hooks
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install --save-dev @jmlweb/commitlint-config @commitlint/cli @commitlint/config-conventional
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or with pnpm:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm add -D @jmlweb/commitlint-config @commitlint/cli @commitlint/config-conventional
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
Create a `commitlint.config.js` file in your project root:
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
import commitlintConfig from '@jmlweb/commitlint-config';
|
|
37
|
+
|
|
38
|
+
export default commitlintConfig;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or with CommonJS:
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
const commitlintConfig = require('@jmlweb/commitlint-config');
|
|
45
|
+
|
|
46
|
+
module.exports = commitlintConfig;
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Commit Message Format
|
|
50
|
+
|
|
51
|
+
This configuration enforces the Conventional Commits format:
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
<type>(<scope>): <subject>
|
|
55
|
+
|
|
56
|
+
[optional body]
|
|
57
|
+
|
|
58
|
+
[optional footer(s)]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Examples of Valid Commits
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
feat(eslint-config-base): add new rule for import sorting
|
|
65
|
+
fix(prettier-config-tailwind): correct plugin order
|
|
66
|
+
docs: update README with installation instructions
|
|
67
|
+
chore(deps): update dependencies
|
|
68
|
+
refactor(tsconfig-base): simplify compiler options
|
|
69
|
+
test(vitest-config): add unit tests for config factory
|
|
70
|
+
ci: add GitHub Actions workflow
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Allowed Types
|
|
74
|
+
|
|
75
|
+
| Type | Description |
|
|
76
|
+
| ---------- | ------------------------------------- |
|
|
77
|
+
| `feat` | New feature |
|
|
78
|
+
| `fix` | Bug fix |
|
|
79
|
+
| `docs` | Documentation changes |
|
|
80
|
+
| `chore` | Maintenance tasks |
|
|
81
|
+
| `refactor` | Code refactoring |
|
|
82
|
+
| `test` | Adding or updating tests |
|
|
83
|
+
| `ci` | CI/CD configuration |
|
|
84
|
+
| `perf` | Performance improvements |
|
|
85
|
+
| `style` | Code style changes (formatting, etc.) |
|
|
86
|
+
| `build` | Build system changes |
|
|
87
|
+
| `revert` | Reverting previous commits |
|
|
88
|
+
|
|
89
|
+
## Allowed Scopes
|
|
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
|
|
106
|
+
|
|
107
|
+
## Customization
|
|
108
|
+
|
|
109
|
+
### Adding Custom Scopes
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
113
|
+
|
|
114
|
+
export default createCommitlintConfig({
|
|
115
|
+
additionalScopes: ['api', 'ui', 'database', 'auth'],
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Stricter Configuration
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
123
|
+
|
|
124
|
+
export default createCommitlintConfig({
|
|
125
|
+
scopeRequired: true,
|
|
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
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Integration with Husky
|
|
142
|
+
|
|
143
|
+
### Step 1: Install husky
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
pnpm add -D husky
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Step 2: Initialize husky
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
pnpm exec husky init
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Step 3: Add commit-msg hook
|
|
156
|
+
|
|
157
|
+
Create or edit `.husky/commit-msg`:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
pnpm exec commitlint --edit $1
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Step 4: Test your setup
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# This should fail
|
|
167
|
+
git commit -m "bad commit message"
|
|
168
|
+
|
|
169
|
+
# This should pass
|
|
170
|
+
git commit -m "feat: add new feature"
|
|
171
|
+
```
|
|
172
|
+
|
|
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
|
+
## Requirements
|
|
205
|
+
|
|
206
|
+
- **Node.js** >= 18.0.0
|
|
207
|
+
- **@commitlint/cli** >= 19.0.0
|
|
208
|
+
- **@commitlint/config-conventional** >= 19.0.0
|
|
209
|
+
|
|
210
|
+
## Related Packages
|
|
211
|
+
|
|
212
|
+
- [`@jmlweb/eslint-config-base`](../eslint-config-base) - ESLint configuration for TypeScript
|
|
213
|
+
- [`@jmlweb/prettier-config-base`](../prettier-config-base) - Prettier configuration
|
|
214
|
+
- [`@jmlweb/tsconfig-base`](../tsconfig-base) - TypeScript configuration
|
|
215
|
+
|
|
216
|
+
## License
|
|
217
|
+
|
|
218
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
COMMIT_SCOPES: () => COMMIT_SCOPES,
|
|
24
|
+
COMMIT_TYPES: () => COMMIT_TYPES,
|
|
25
|
+
createCommitlintConfig: () => createCommitlintConfig,
|
|
26
|
+
default: () => index_default
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
var COMMIT_TYPES = [
|
|
30
|
+
"feat",
|
|
31
|
+
// New feature
|
|
32
|
+
"fix",
|
|
33
|
+
// Bug fix
|
|
34
|
+
"docs",
|
|
35
|
+
// Documentation changes
|
|
36
|
+
"chore",
|
|
37
|
+
// Maintenance tasks
|
|
38
|
+
"refactor",
|
|
39
|
+
// Code refactoring
|
|
40
|
+
"test",
|
|
41
|
+
// Adding or updating tests
|
|
42
|
+
"ci",
|
|
43
|
+
// CI/CD configuration
|
|
44
|
+
"perf",
|
|
45
|
+
// Performance improvements
|
|
46
|
+
"style",
|
|
47
|
+
// Code style changes (formatting, etc.)
|
|
48
|
+
"build",
|
|
49
|
+
// Build system changes
|
|
50
|
+
"revert"
|
|
51
|
+
// Reverting previous commits
|
|
52
|
+
];
|
|
53
|
+
var COMMIT_SCOPES = [
|
|
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 = {}) => {
|
|
83
|
+
const {
|
|
84
|
+
additionalTypes = [],
|
|
85
|
+
additionalScopes = [],
|
|
86
|
+
headerMaxLength = 100,
|
|
87
|
+
scopeRequired = false,
|
|
88
|
+
bodyRequired = false
|
|
89
|
+
} = options;
|
|
90
|
+
const allTypes = [...COMMIT_TYPES, ...additionalTypes];
|
|
91
|
+
const allScopes = [...COMMIT_SCOPES, ...additionalScopes];
|
|
92
|
+
return {
|
|
93
|
+
extends: ["@commitlint/config-conventional"],
|
|
94
|
+
rules: {
|
|
95
|
+
// Type rules
|
|
96
|
+
"type-enum": [2, "always", allTypes],
|
|
97
|
+
"type-case": [2, "always", "lower-case"],
|
|
98
|
+
"type-empty": [2, "never"],
|
|
99
|
+
// Scope rules
|
|
100
|
+
"scope-enum": [2, "always", allScopes],
|
|
101
|
+
"scope-case": [2, "always", "kebab-case"],
|
|
102
|
+
"scope-empty": scopeRequired ? [2, "never"] : [0],
|
|
103
|
+
// Subject rules
|
|
104
|
+
"subject-case": [2, "always", "lower-case"],
|
|
105
|
+
"subject-empty": [2, "never"],
|
|
106
|
+
"subject-full-stop": [2, "never", "."],
|
|
107
|
+
// Header rules
|
|
108
|
+
"header-max-length": [2, "always", headerMaxLength],
|
|
109
|
+
// Body rules
|
|
110
|
+
"body-leading-blank": [2, "always"],
|
|
111
|
+
"body-max-line-length": [2, "always", 100],
|
|
112
|
+
"body-empty": bodyRequired ? [2, "never"] : [0],
|
|
113
|
+
// Footer rules
|
|
114
|
+
"footer-leading-blank": [2, "always"],
|
|
115
|
+
"footer-max-line-length": [2, "always", 100]
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
var config = createCommitlintConfig();
|
|
120
|
+
var index_default = config;
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
COMMIT_SCOPES,
|
|
124
|
+
COMMIT_TYPES,
|
|
125
|
+
createCommitlintConfig
|
|
126
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { UserConfig } from '@commitlint/types';
|
|
2
|
+
export { UserConfig } from '@commitlint/types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Allowed commit types following Conventional Commits specification
|
|
6
|
+
*/
|
|
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
|
+
type CommitType = (typeof COMMIT_TYPES)[number];
|
|
14
|
+
type CommitScope = (typeof COMMIT_SCOPES)[number];
|
|
15
|
+
/**
|
|
16
|
+
* Options for creating a commitlint configuration
|
|
17
|
+
*/
|
|
18
|
+
interface CommitlintConfigOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Additional commit types to allow
|
|
21
|
+
* @default []
|
|
22
|
+
*/
|
|
23
|
+
additionalTypes?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Additional scopes to allow
|
|
26
|
+
* @default []
|
|
27
|
+
*/
|
|
28
|
+
additionalScopes?: string[];
|
|
29
|
+
/**
|
|
30
|
+
* Maximum length for the header line
|
|
31
|
+
* @default 100
|
|
32
|
+
*/
|
|
33
|
+
headerMaxLength?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to require a scope
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
scopeRequired?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to require body for certain commit types
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
bodyRequired?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates a commitlint configuration with sensible defaults
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Simple usage with defaults
|
|
51
|
+
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
52
|
+
* export default createCommitlintConfig();
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // With additional scopes for your project
|
|
58
|
+
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
59
|
+
* export default createCommitlintConfig({
|
|
60
|
+
* additionalScopes: ['api', 'ui', 'database'],
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* // Strict configuration with required scope
|
|
67
|
+
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
68
|
+
* export default createCommitlintConfig({
|
|
69
|
+
* scopeRequired: true,
|
|
70
|
+
* headerMaxLength: 72,
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare const createCommitlintConfig: (options?: CommitlintConfigOptions) => UserConfig;
|
|
75
|
+
/**
|
|
76
|
+
* Default commitlint configuration
|
|
77
|
+
* Use this directly if you don't need customization
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```javascript
|
|
81
|
+
* // commitlint.config.js
|
|
82
|
+
* import commitlintConfig from '@jmlweb/commitlint-config';
|
|
83
|
+
* export default commitlintConfig;
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare const config: UserConfig;
|
|
87
|
+
|
|
88
|
+
export { COMMIT_SCOPES, COMMIT_TYPES, type CommitScope, type CommitType, type CommitlintConfigOptions, createCommitlintConfig, config as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { UserConfig } from '@commitlint/types';
|
|
2
|
+
export { UserConfig } from '@commitlint/types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Allowed commit types following Conventional Commits specification
|
|
6
|
+
*/
|
|
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
|
+
type CommitType = (typeof COMMIT_TYPES)[number];
|
|
14
|
+
type CommitScope = (typeof COMMIT_SCOPES)[number];
|
|
15
|
+
/**
|
|
16
|
+
* Options for creating a commitlint configuration
|
|
17
|
+
*/
|
|
18
|
+
interface CommitlintConfigOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Additional commit types to allow
|
|
21
|
+
* @default []
|
|
22
|
+
*/
|
|
23
|
+
additionalTypes?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Additional scopes to allow
|
|
26
|
+
* @default []
|
|
27
|
+
*/
|
|
28
|
+
additionalScopes?: string[];
|
|
29
|
+
/**
|
|
30
|
+
* Maximum length for the header line
|
|
31
|
+
* @default 100
|
|
32
|
+
*/
|
|
33
|
+
headerMaxLength?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to require a scope
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
scopeRequired?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to require body for certain commit types
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
bodyRequired?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates a commitlint configuration with sensible defaults
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Simple usage with defaults
|
|
51
|
+
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
52
|
+
* export default createCommitlintConfig();
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // With additional scopes for your project
|
|
58
|
+
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
59
|
+
* export default createCommitlintConfig({
|
|
60
|
+
* additionalScopes: ['api', 'ui', 'database'],
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* // Strict configuration with required scope
|
|
67
|
+
* import { createCommitlintConfig } from '@jmlweb/commitlint-config';
|
|
68
|
+
* export default createCommitlintConfig({
|
|
69
|
+
* scopeRequired: true,
|
|
70
|
+
* headerMaxLength: 72,
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare const createCommitlintConfig: (options?: CommitlintConfigOptions) => UserConfig;
|
|
75
|
+
/**
|
|
76
|
+
* Default commitlint configuration
|
|
77
|
+
* Use this directly if you don't need customization
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```javascript
|
|
81
|
+
* // commitlint.config.js
|
|
82
|
+
* import commitlintConfig from '@jmlweb/commitlint-config';
|
|
83
|
+
* export default commitlintConfig;
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare const config: UserConfig;
|
|
87
|
+
|
|
88
|
+
export { COMMIT_SCOPES, COMMIT_TYPES, type CommitScope, type CommitType, type CommitlintConfigOptions, createCommitlintConfig, config as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var COMMIT_TYPES = [
|
|
3
|
+
"feat",
|
|
4
|
+
// New feature
|
|
5
|
+
"fix",
|
|
6
|
+
// Bug fix
|
|
7
|
+
"docs",
|
|
8
|
+
// Documentation changes
|
|
9
|
+
"chore",
|
|
10
|
+
// Maintenance tasks
|
|
11
|
+
"refactor",
|
|
12
|
+
// Code refactoring
|
|
13
|
+
"test",
|
|
14
|
+
// Adding or updating tests
|
|
15
|
+
"ci",
|
|
16
|
+
// CI/CD configuration
|
|
17
|
+
"perf",
|
|
18
|
+
// Performance improvements
|
|
19
|
+
"style",
|
|
20
|
+
// Code style changes (formatting, etc.)
|
|
21
|
+
"build",
|
|
22
|
+
// Build system changes
|
|
23
|
+
"revert"
|
|
24
|
+
// Reverting previous commits
|
|
25
|
+
];
|
|
26
|
+
var COMMIT_SCOPES = [
|
|
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 = {}) => {
|
|
56
|
+
const {
|
|
57
|
+
additionalTypes = [],
|
|
58
|
+
additionalScopes = [],
|
|
59
|
+
headerMaxLength = 100,
|
|
60
|
+
scopeRequired = false,
|
|
61
|
+
bodyRequired = false
|
|
62
|
+
} = options;
|
|
63
|
+
const allTypes = [...COMMIT_TYPES, ...additionalTypes];
|
|
64
|
+
const allScopes = [...COMMIT_SCOPES, ...additionalScopes];
|
|
65
|
+
return {
|
|
66
|
+
extends: ["@commitlint/config-conventional"],
|
|
67
|
+
rules: {
|
|
68
|
+
// Type rules
|
|
69
|
+
"type-enum": [2, "always", allTypes],
|
|
70
|
+
"type-case": [2, "always", "lower-case"],
|
|
71
|
+
"type-empty": [2, "never"],
|
|
72
|
+
// Scope rules
|
|
73
|
+
"scope-enum": [2, "always", allScopes],
|
|
74
|
+
"scope-case": [2, "always", "kebab-case"],
|
|
75
|
+
"scope-empty": scopeRequired ? [2, "never"] : [0],
|
|
76
|
+
// Subject rules
|
|
77
|
+
"subject-case": [2, "always", "lower-case"],
|
|
78
|
+
"subject-empty": [2, "never"],
|
|
79
|
+
"subject-full-stop": [2, "never", "."],
|
|
80
|
+
// Header rules
|
|
81
|
+
"header-max-length": [2, "always", headerMaxLength],
|
|
82
|
+
// Body rules
|
|
83
|
+
"body-leading-blank": [2, "always"],
|
|
84
|
+
"body-max-line-length": [2, "always", 100],
|
|
85
|
+
"body-empty": bodyRequired ? [2, "never"] : [0],
|
|
86
|
+
// Footer rules
|
|
87
|
+
"footer-leading-blank": [2, "always"],
|
|
88
|
+
"footer-max-line-length": [2, "always", 100]
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
var config = createCommitlintConfig();
|
|
93
|
+
var index_default = config;
|
|
94
|
+
export {
|
|
95
|
+
COMMIT_SCOPES,
|
|
96
|
+
COMMIT_TYPES,
|
|
97
|
+
createCommitlintConfig,
|
|
98
|
+
index_default as default
|
|
99
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jmlweb/commitlint-config",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Shared commitlint configuration for enforcing Conventional Commits",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"CHANGELOG.md"
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"commitlint",
|
|
28
|
+
"commitlint-config",
|
|
29
|
+
"conventional-commits",
|
|
30
|
+
"git",
|
|
31
|
+
"lint"
|
|
32
|
+
],
|
|
33
|
+
"author": "jmlweb",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": "jmlweb/tooling.git",
|
|
36
|
+
"bugs": "https://github.com/jmlweb/tooling/issues",
|
|
37
|
+
"homepage": "https://github.com/jmlweb/tooling/tree/main/packages/commitlint-config#readme",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@commitlint/cli": ">=19.0.0",
|
|
46
|
+
"@commitlint/config-conventional": ">=19.0.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@commitlint/cli": "^19.8.1",
|
|
50
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
51
|
+
"@commitlint/types": "^19.8.1",
|
|
52
|
+
"tsup": "^8.5.1",
|
|
53
|
+
"typescript": "^5.9.3",
|
|
54
|
+
"@jmlweb/tsconfig-internal": "0.0.1"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup",
|
|
58
|
+
"clean": "rm -rf dist"
|
|
59
|
+
}
|
|
60
|
+
}
|