|
| 1 | +/* [commitlint](https://github.com/conventional-changelog/commitlint) configuration |
| 2 | + * |
| 3 | + * Bottlerocket kit repos use a `scope: description` convention where the scope |
| 4 | + * is typically a package name (e.g. `kernel-6.12: update to 6.12.94`) or an |
| 5 | + * area (e.g. `changelog: add release notes for v7.1.0`). |
| 6 | + * |
| 7 | + * This differs from standard Conventional Commits which require a fixed type |
| 8 | + * prefix (feat, fix, etc.). We enforce the structural rules (colon separator, |
| 9 | + * line lengths, casing) while allowing any lowercase scope before the colon. |
| 10 | + */ |
| 11 | +import { RuleConfigSeverity } from "@commitlint/types"; |
| 12 | + |
| 13 | +// Custom plugin to validate the "scope: description" format used in kit repos. |
| 14 | +const kitScopePlugin = { |
| 15 | + rules: { |
| 16 | + // Validates that the header matches `lowercase-scope: lowercase description` |
| 17 | + "kit-scope-format": (parsed, _when, _value) => { |
| 18 | + const header = parsed.header; |
| 19 | + // Match: one or more lowercase words/numbers/dots/dashes, colon, space, then description |
| 20 | + const pattern = /^[a-z][a-z0-9._-]*: .+$/; |
| 21 | + return [ |
| 22 | + pattern.test(header), |
| 23 | + "header must match the format 'scope: description' (e.g. 'kernel-6.12: update to 6.12.94')", |
| 24 | + ]; |
| 25 | + }, |
| 26 | + }, |
| 27 | +}; |
| 28 | + |
| 29 | +export default { |
| 30 | + plugins: [kitScopePlugin], |
| 31 | + rules: { |
| 32 | + // Structural rules |
| 33 | + "header-max-length": [RuleConfigSeverity.Error, "always", 72], |
| 34 | + "header-trim": [RuleConfigSeverity.Error, "always"], |
| 35 | + "body-max-line-length": [RuleConfigSeverity.Error, "always", 72], |
| 36 | + "body-leading-blank": [RuleConfigSeverity.Error, "always"], |
| 37 | + |
| 38 | + // Subject rules (applied to text after the colon) |
| 39 | + "subject-full-stop": [RuleConfigSeverity.Error, "never", "."], |
| 40 | + |
| 41 | + // Custom kit scope format |
| 42 | + "kit-scope-format": [RuleConfigSeverity.Error, "always"], |
| 43 | + }, |
| 44 | + ignores: [ |
| 45 | + (message) => message.includes("Merge pull request #"), |
| 46 | + (message) => message.startsWith("Revert \""), |
| 47 | + ], |
| 48 | +}; |
0 commit comments