@jmlweb/commitlint-config 0.0.0 → 2.0.1

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @jmlweb/commitlint-config
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 6b73301: Add changelog section with link to CHANGELOG.md in package READMEs
8
+
9
+ ## 2.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - 738525c: Make config generic by removing hardcoded scopes and adding flexible scope options
14
+
15
+ ## 1.0.0
16
+
17
+ ### Major Changes
18
+
19
+ - 165d410: Make config generic by removing hardcoded scopes and adding flexible scope options
20
+
3
21
  ## 0.0.0
4
22
 
5
23
  Initial development version.
package/README.md CHANGED
@@ -5,18 +5,17 @@
5
5
  [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18.0.0-339933.svg)](https://nodejs.org/)
6
6
  [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
7
7
 
8
- > Shared commitlint configuration for enforcing Conventional Commits across projects. Includes predefined scopes for @jmlweb packages and configurable options.
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
- - 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
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
18
17
 
19
- ## Installation
18
+ ## 📦 Installation
20
19
 
21
20
  ```bash
22
21
  npm install --save-dev @jmlweb/commitlint-config @commitlint/cli @commitlint/config-conventional
@@ -28,7 +27,9 @@ Or with pnpm:
28
27
  pnpm add -D @jmlweb/commitlint-config @commitlint/cli @commitlint/config-conventional
29
28
  ```
30
29
 
31
- ## Quick Start
30
+ > 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
31
+
32
+ ## 🚀 Quick Start
32
33
 
33
34
  Create a `commitlint.config.js` file in your project root:
34
35
 
@@ -38,15 +39,66 @@ import commitlintConfig from '@jmlweb/commitlint-config';
38
39
  export default commitlintConfig;
39
40
  ```
40
41
 
41
- Or with CommonJS:
42
+ That's it! Any commit type/scope following Conventional Commits is allowed.
43
+
44
+ ## 💡 Examples
45
+
46
+ ### No Scope Restrictions (Default)
42
47
 
43
48
  ```javascript
44
- const commitlintConfig = require('@jmlweb/commitlint-config');
49
+ // commitlint.config.js
50
+ import commitlintConfig from '@jmlweb/commitlint-config';
51
+
52
+ export default commitlintConfig;
53
+ ```
54
+
55
+ Valid commits:
56
+
57
+ ```text
58
+ feat: add new feature
59
+ fix(auth): resolve login issue
60
+ chore(whatever-you-want): update deps
61
+ ```
62
+
63
+ ### Define Your Own Scopes
64
+
65
+ ```typescript
66
+ // commitlint.config.ts
67
+ import { createCommitlintConfig } from '@jmlweb/commitlint-config';
68
+
69
+ export default createCommitlintConfig({
70
+ scopes: ['api', 'ui', 'database', 'auth', 'deps'],
71
+ });
72
+ ```
73
+
74
+ ### Strict Configuration
45
75
 
46
- module.exports = commitlintConfig;
76
+ ```typescript
77
+ import { createCommitlintConfig } from '@jmlweb/commitlint-config';
78
+
79
+ export default createCommitlintConfig({
80
+ scopes: ['core', 'utils', 'config'],
81
+ scopeRequired: true,
82
+ headerMaxLength: 72,
83
+ });
84
+ ```
85
+
86
+ ### Ignore Specific Commits
87
+
88
+ ```typescript
89
+ import { createCommitlintConfig } from '@jmlweb/commitlint-config';
90
+
91
+ export default createCommitlintConfig({
92
+ ignores: [
93
+ (commit) => commit.startsWith('Merge'),
94
+ (commit) => /^\[dependabot\]/.test(commit),
95
+ ],
96
+ });
47
97
  ```
48
98
 
49
- ## Commit Message Format
99
+ ## 📋 Configuration Details
100
+
101
+ ### Commit Message Format
50
102
 
51
103
  This configuration enforces the Conventional Commits format:
52
104
 
@@ -58,19 +110,19 @@ This configuration enforces the Conventional Commits format:
58
110
  [optional footer(s)]
59
111
  ```
60
112
 
61
- ### Examples of Valid Commits
113
+ ### Example Commits
62
114
 
63
115
  ```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
116
+ feat(api): add user authentication endpoint
117
+ fix: correct date parsing logic
118
+ docs: update README with examples
67
119
  chore(deps): update dependencies
68
- refactor(tsconfig-base): simplify compiler options
69
- test(vitest-config): add unit tests for config factory
120
+ refactor(ui): simplify form validation
121
+ test: add unit tests for utils
70
122
  ci: add GitHub Actions workflow
71
123
  ```
72
124
 
73
- ## Allowed Types
125
+ ### Allowed Types
74
126
 
75
127
  | Type | Description |
76
128
  | ---------- | ------------------------------------- |
@@ -86,25 +138,46 @@ ci: add GitHub Actions workflow
86
138
  | `build` | Build system changes |
87
139
  | `revert` | Reverting previous commits |
88
140
 
89
- ## Allowed Scopes
141
+ ### Configuration Options
90
142
 
91
- ### Package Scopes
143
+ | Option | Type | Default | Description |
144
+ | ------------------ | --------------------------------- | ----------- | ---------------------------------------------- |
145
+ | `scopes` | `string[]` | `undefined` | Define allowed scopes (enables scope checking) |
146
+ | `additionalScopes` | `string[]` | `[]` | Add scopes when extending base configs |
147
+ | `additionalTypes` | `string[]` | `[]` | Additional commit types to allow |
148
+ | `headerMaxLength` | `number` | `100` | Maximum length for the header line |
149
+ | `scopeRequired` | `boolean` | `false` | Whether to require a scope |
150
+ | `bodyRequired` | `boolean` | `false` | Whether to require a commit body |
151
+ | `ignores` | `((commit: string) => boolean)[]` | `undefined` | Functions to ignore certain commits |
92
152
 
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`
153
+ ### Exports
99
154
 
100
- ### Common Scopes
155
+ ```typescript
156
+ // Default config - no scope restrictions
157
+ import config from '@jmlweb/commitlint-config';
101
158
 
102
- - `deps` - Dependency updates
103
- - `release` - Release-related changes
104
- - `scripts` - Build/CI scripts
105
- - `workspace` - Workspace configuration
159
+ // Factory function for custom configs
160
+ import { createCommitlintConfig } from '@jmlweb/commitlint-config';
106
161
 
107
- ## Customization
162
+ // Commit types constant
163
+ import { COMMIT_TYPES } from '@jmlweb/commitlint-config';
164
+ ```
165
+
166
+ ## 🎯 When to Use
167
+
168
+ Use this configuration when you want:
169
+
170
+ - ✅ Enforce Conventional Commits specification across your project
171
+ - ✅ Automatic changelog generation from commit messages
172
+ - ✅ Consistent commit message format across team members
173
+ - ✅ Optional scope restrictions for monorepos
174
+ - ✅ Integration with semantic-release or standard-version
175
+
176
+ **For projects without commitlint**, consider starting with this package to improve commit quality and enable automated versioning.
177
+
178
+ ## 🔧 Extending the Configuration
179
+
180
+ You can extend the configuration for your specific needs:
108
181
 
109
182
  ### Adding Custom Scopes
110
183
 
@@ -112,47 +185,41 @@ ci: add GitHub Actions workflow
112
185
  import { createCommitlintConfig } from '@jmlweb/commitlint-config';
113
186
 
114
187
  export default createCommitlintConfig({
115
- additionalScopes: ['api', 'ui', 'database', 'auth'],
188
+ scopes: ['frontend', 'backend', 'shared', 'docs'],
189
+ additionalTypes: ['wip'], // Add work-in-progress type
116
190
  });
117
191
  ```
118
192
 
119
- ### Stricter Configuration
193
+ ### Stricter Rules
120
194
 
121
195
  ```typescript
122
196
  import { createCommitlintConfig } from '@jmlweb/commitlint-config';
123
197
 
124
198
  export default createCommitlintConfig({
199
+ scopes: ['core', 'api', 'ui'],
125
200
  scopeRequired: true,
126
- headerMaxLength: 72,
127
201
  bodyRequired: true,
202
+ headerMaxLength: 72,
128
203
  });
129
204
  ```
130
205
 
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
- ```
206
+ ## 📝 Usage with Scripts
140
207
 
141
- ## Integration with Husky
208
+ ### Integration with Husky
142
209
 
143
- ### Step 1: Install husky
210
+ #### Step 1 - Install husky
144
211
 
145
212
  ```bash
146
213
  pnpm add -D husky
147
214
  ```
148
215
 
149
- ### Step 2: Initialize husky
216
+ #### Step 2 - Initialize husky
150
217
 
151
218
  ```bash
152
219
  pnpm exec husky init
153
220
  ```
154
221
 
155
- ### Step 3: Add commit-msg hook
222
+ #### Step 3 - Add commit-msg hook
156
223
 
157
224
  Create or edit `.husky/commit-msg`:
158
225
 
@@ -160,7 +227,7 @@ Create or edit `.husky/commit-msg`:
160
227
  pnpm exec commitlint --edit $1
161
228
  ```
162
229
 
163
- ### Step 4: Test your setup
230
+ #### Step 4 - Test your setup
164
231
 
165
232
  ```bash
166
233
  # This should fail
@@ -170,49 +237,61 @@ git commit -m "bad commit message"
170
237
  git commit -m "feat: add new feature"
171
238
  ```
172
239
 
173
- ## Configuration Options
240
+ ### Package.json Scripts
174
241
 
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';
242
+ ```json
243
+ {
244
+ "scripts": {
245
+ "commitlint": "commitlint --edit",
246
+ "commitlint:all": "commitlint --from HEAD~10"
247
+ }
248
+ }
202
249
  ```
203
250
 
204
- ## Requirements
251
+ ## 📋 Requirements
205
252
 
206
253
  - **Node.js** >= 18.0.0
207
254
  - **@commitlint/cli** >= 19.0.0
208
255
  - **@commitlint/config-conventional** >= 19.0.0
209
256
 
210
- ## Related Packages
257
+ ## 📦 Peer Dependencies
258
+
259
+ This package requires the following peer dependencies:
260
+
261
+ - `@commitlint/cli` (>=19.0.0)
262
+ - `@commitlint/config-conventional` (>=19.0.0)
263
+
264
+ ## 🔗 Related Packages
265
+
266
+ ### Internal Packages
211
267
 
212
268
  - [`@jmlweb/eslint-config-base`](../eslint-config-base) - ESLint configuration for TypeScript
213
269
  - [`@jmlweb/prettier-config-base`](../prettier-config-base) - Prettier configuration
214
270
  - [`@jmlweb/tsconfig-base`](../tsconfig-base) - TypeScript configuration
215
271
 
216
- ## License
272
+ ### External Tools
273
+
274
+ - [commitlint](https://commitlint.js.org/) - Lint commit messages according to conventional commits
275
+ - [Conventional Commits](https://www.conventionalcommits.org/) - A specification for adding meaning to commit messages
276
+ - [Husky](https://typicode.github.io/husky/) - Git hooks made easy (recommended for pre-commit integration)
277
+ - [semantic-release](https://semantic-release.gitbook.io/) - Automated versioning and changelog generation
278
+
279
+ ## 🔄 Migration Guide
280
+
281
+ ### Upgrading to a New Version
282
+
283
+ > **Note:** If no breaking changes were introduced in a version, it's safe to upgrade without additional steps.
284
+
285
+ **No breaking changes have been introduced yet.** This package follows semantic versioning. When breaking changes are introduced, detailed migration instructions will be provided here.
286
+
287
+ For version history, see the [Changelog](./CHANGELOG.md).
288
+
289
+ **Need Help?** If you encounter issues during migration, please [open an issue](https://github.com/jmlweb/tooling/issues/new).
290
+
291
+ ## 📜 Changelog
292
+
293
+ See [CHANGELOG.md](./CHANGELOG.md) for version history and release notes.
294
+
295
+ ## 📄 License
217
296
 
218
297
  MIT
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 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 = {}) => {
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
- const allScopes = [...COMMIT_SCOPES, ...additionalScopes];
92
- return {
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", allScopes],
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
- * Additional scopes to allow
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 with defaults
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
- * // With additional scopes for your project
64
+ * // Define allowed scopes for your project
58
65
  * import { createCommitlintConfig } from '@jmlweb/commitlint-config';
59
66
  * export default createCommitlintConfig({
60
- * additionalScopes: ['api', 'ui', 'database'],
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
- * Use this directly if you don't need customization
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 { COMMIT_SCOPES, COMMIT_TYPES, type CommitScope, type CommitType, type CommitlintConfigOptions, createCommitlintConfig, config as default };
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
- * Additional scopes to allow
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 with defaults
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
- * // With additional scopes for your project
64
+ * // Define allowed scopes for your project
58
65
  * import { createCommitlintConfig } from '@jmlweb/commitlint-config';
59
66
  * export default createCommitlintConfig({
60
- * additionalScopes: ['api', 'ui', 'database'],
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
- * Use this directly if you don't need customization
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 { COMMIT_SCOPES, COMMIT_TYPES, type CommitScope, type CommitType, type CommitlintConfigOptions, createCommitlintConfig, config as default };
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 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 = {}) => {
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
- const allScopes = [...COMMIT_SCOPES, ...additionalScopes];
65
- return {
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", allScopes],
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": "0.0.0",
3
+ "version": "2.0.1",
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": "jmlweb/tooling.git",
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": {