Skip to content

Commit 135d3eb

Browse files
committed
refactor(config): [rules] prefer trailer-exists over signed-off-by
- conventional-changelog/commitlint#2578 - allows use of `Co-authored-by` trailer - requires use of `BREAKING-CHANGE` trailer over `BREAKING CHANGE` keyword Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 3ce06b9 commit 135d3eb

9 files changed

+9
-65
lines changed

Diff for: CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ This means every commit must conform to the following format:
168168

169169
[body]
170170

171-
[BREAKING CHANGE: <change>]
171+
[BREAKING-CHANGE: <change>]
172172

173173
[footer(s)]
174174
```

Diff for: README.md

-11
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Shareable [`commitlint`][1] config enforcing [conventional commits][2]
3333
- [`scope-enum`](#scope-enum)
3434
- [`scope-max-length`](#scope-max-length)
3535
- [`scope-min-length`](#scope-min-length)
36-
- [`signed-off-by`](#signed-off-by)
3736
- [`subject-empty`](#subject-empty)
3837
- [`subject-full-stop`](#subject-full-stop)
3938
- [`subject-min-length`](#subject-min-length)
@@ -271,16 +270,6 @@ code when not met.
271270
min(scopes())
272271
```
273272

274-
#### `signed-off-by`
275-
276-
- **condition**: `message` has `value`
277-
- **rule**: `always`
278-
- **value**:
279-
280-
```ts
281-
'Signed-off-by:'
282-
```
283-
284273
#### `subject-empty`
285274

286275
- **condition**: `subject` is empty

Diff for: src/config/__snapshots__/rules.integration.snap

-23
Original file line numberDiff line numberDiff line change
@@ -123,23 +123,6 @@ exports[`integration:config/rules > @commitlint/lint > scope-min-length > should
123123
]
124124
`;
125125

126-
exports[`integration:config/rules > @commitlint/lint > signed-off-by > should error without sign off 1`] = `
127-
[
128-
{
129-
"level": 2,
130-
"message": "message must be signed off",
131-
"name": "signed-off-by",
132-
"valid": false,
133-
},
134-
{
135-
"level": 2,
136-
"message": "message must have \`Signed-off-by:\` trailer",
137-
"name": "trailer-exists",
138-
"valid": false,
139-
},
140-
]
141-
`;
142-
143126
exports[`integration:config/rules > @commitlint/lint > subject-empty > should error on missing subject 1`] = `
144127
[
145128
{
@@ -187,12 +170,6 @@ exports[`integration:config/rules > @commitlint/lint > subject-min-length > shou
187170

188171
exports[`integration:config/rules > @commitlint/lint > trailer-exists > should error on missing "Signed-off-by" trailer 1`] = `
189172
[
190-
{
191-
"level": 2,
192-
"message": "message must be signed off",
193-
"name": "signed-off-by",
194-
"valid": false,
195-
},
196173
{
197174
"level": 2,
198175
"message": "message must have \`Signed-off-by:\` trailer",

Diff for: src/config/__tests__/parser-preset.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ describe('unit:config/parserPreset', () => {
226226
subject = testSubject.parserOpts.noteKeywords
227227
})
228228

229-
it('should only contain 2 keywords', () => {
230-
expect(subject).to.deep.equal(['BREAKING CHANGE', 'BREAKING-CHANGE'])
229+
it('should only contain 1 keyword', () => {
230+
expect(subject).to.deep.equal(['BREAKING-CHANGE'])
231231
})
232232
})
233233

Diff for: src/config/__tests__/rules.integration.spec.ts

+3-21
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('integration:config/rules', () => {
145145
it('should error if footer comes after 1 new line', async () => {
146146
// Arrange
147147
const commit: string =
148-
'test: some message\n\nbody\nBREAKING CHANGE: It will be significant'
148+
'test: some message\n\nbody\nBREAKING-CHANGE: It will be significant'
149149

150150
// Act
151151
const result = await linter(signoff(commit, 0))
@@ -355,26 +355,8 @@ describe('integration:config/rules', () => {
355355
})
356356

357357
describe('signed-off-by', () => {
358-
let rule: string
359-
let severity: Severity
360-
361-
beforeAll(() => {
362-
rule = 'signed-off-by'
363-
severity = Severity.Error
364-
})
365-
366-
it('should error without sign off', async () => {
367-
// Arrange
368-
const commit: string =
369-
'chore(tests): [codecov] label critical files\n\n- https://docs.codecov.com/docs/manual-critical-file-labelling'
370-
371-
// Act
372-
const result = await linter(commit)
373-
374-
// Expect
375-
expect(result.errors).to.have.ruleOutcome(rule, severity)
376-
expect(result.warnings).to.be.an('array').that.is.empty
377-
expect(result.errors).toMatchSnapshot()
358+
it('should be disabled', () => {
359+
expect(testSubject['body-case']).to.be.level(Severity.Disabled)
378360
})
379361
})
380362

Diff for: src/config/parser-preset.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const parserPreset: ParserPreset = {
2929
issuePrefixesCaseSensitive: true,
3030
mergeCorrespondence: null,
3131
mergePattern: null,
32-
noteKeywords: ['BREAKING CHANGE', 'BREAKING-CHANGE'],
32+
noteKeywords: ['BREAKING-CHANGE'],
3333
referenceActions: Object.values(ReferenceAction),
3434
revertCorrespondence: [
3535
'type',

Diff for: src/config/rules.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const rules: RulesConfig = {
4242
'scope-enum': [Severity.Error, 'always', scopes()],
4343
'scope-max-length': [Severity.Error, 'always', max(scopes())],
4444
'scope-min-length': [Severity.Error, 'always', min(scopes())],
45-
'signed-off-by': [Severity.Error, 'always', 'Signed-off-by:'],
45+
'signed-off-by': [Severity.Disabled],
4646
'subject-case': [Severity.Disabled],
4747
'subject-empty': [Severity.Error, 'never'],
4848
'subject-exclamation-mark': [Severity.Disabled],

Diff for: src/types/__tests__/note-keyword.spec-d.ts

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
import type TestSubject from '../note-keyword'
77

88
describe('unit-d:types/NoteKeyword', () => {
9-
it('should extract "BREAKING CHANGE"', () => {
10-
expectTypeOf<TestSubject>().extract('BREAKING CHANGE').toBeString()
11-
})
12-
139
it('should extract "BREAKING-CHANGE"', () => {
1410
expectTypeOf<TestSubject>().extract('BREAKING-CHANGE').toBeString()
1511
})

Diff for: src/types/note-keyword.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
*
99
* @see https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-commits-parser/README.md#notekeywords
1010
*/
11-
type NoteKeyword = 'BREAKING CHANGE' | 'BREAKING-CHANGE'
11+
type NoteKeyword = 'BREAKING-CHANGE'
1212

1313
export type { NoteKeyword as default }

0 commit comments

Comments
 (0)