Skip to content

Commit

Permalink
refactor(config): [rules] prefer trailer-exists over signed-off-by
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
unicornware committed Mar 1, 2023
1 parent 3ce06b9 commit 135d3eb
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 65 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -168,7 +168,7 @@ This means every commit must conform to the following format:

[body]

[BREAKING CHANGE: <change>]
[BREAKING-CHANGE: <change>]

[footer(s)]
```
Expand Down
11 changes: 0 additions & 11 deletions README.md
Expand Up @@ -33,7 +33,6 @@ Shareable [`commitlint`][1] config enforcing [conventional commits][2]
- [`scope-enum`](#scope-enum)
- [`scope-max-length`](#scope-max-length)
- [`scope-min-length`](#scope-min-length)
- [`signed-off-by`](#signed-off-by)
- [`subject-empty`](#subject-empty)
- [`subject-full-stop`](#subject-full-stop)
- [`subject-min-length`](#subject-min-length)
Expand Down Expand Up @@ -271,16 +270,6 @@ code when not met.
min(scopes())
```

#### `signed-off-by`

- **condition**: `message` has `value`
- **rule**: `always`
- **value**:

```ts
'Signed-off-by:'
```

#### `subject-empty`

- **condition**: `subject` is empty
Expand Down
23 changes: 0 additions & 23 deletions src/config/__snapshots__/rules.integration.snap
Expand Up @@ -123,23 +123,6 @@ exports[`integration:config/rules > @commitlint/lint > scope-min-length > should
]
`;

exports[`integration:config/rules > @commitlint/lint > signed-off-by > should error without sign off 1`] = `
[
{
"level": 2,
"message": "message must be signed off",
"name": "signed-off-by",
"valid": false,
},
{
"level": 2,
"message": "message must have \`Signed-off-by:\` trailer",
"name": "trailer-exists",
"valid": false,
},
]
`;

exports[`integration:config/rules > @commitlint/lint > subject-empty > should error on missing subject 1`] = `
[
{
Expand Down Expand Up @@ -187,12 +170,6 @@ exports[`integration:config/rules > @commitlint/lint > subject-min-length > shou

exports[`integration:config/rules > @commitlint/lint > trailer-exists > should error on missing "Signed-off-by" trailer 1`] = `
[
{
"level": 2,
"message": "message must be signed off",
"name": "signed-off-by",
"valid": false,
},
{
"level": 2,
"message": "message must have \`Signed-off-by:\` trailer",
Expand Down
4 changes: 2 additions & 2 deletions src/config/__tests__/parser-preset.spec.ts
Expand Up @@ -226,8 +226,8 @@ describe('unit:config/parserPreset', () => {
subject = testSubject.parserOpts.noteKeywords
})

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

Expand Down
24 changes: 3 additions & 21 deletions src/config/__tests__/rules.integration.spec.ts
Expand Up @@ -145,7 +145,7 @@ describe('integration:config/rules', () => {
it('should error if footer comes after 1 new line', async () => {
// Arrange
const commit: string =
'test: some message\n\nbody\nBREAKING CHANGE: It will be significant'
'test: some message\n\nbody\nBREAKING-CHANGE: It will be significant'

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

describe('signed-off-by', () => {
let rule: string
let severity: Severity

beforeAll(() => {
rule = 'signed-off-by'
severity = Severity.Error
})

it('should error without sign off', async () => {
// Arrange
const commit: string =
'chore(tests): [codecov] label critical files\n\n- https://docs.codecov.com/docs/manual-critical-file-labelling'

// Act
const result = await linter(commit)

// Expect
expect(result.errors).to.have.ruleOutcome(rule, severity)
expect(result.warnings).to.be.an('array').that.is.empty
expect(result.errors).toMatchSnapshot()
it('should be disabled', () => {
expect(testSubject['body-case']).to.be.level(Severity.Disabled)
})
})

Expand Down
2 changes: 1 addition & 1 deletion src/config/parser-preset.ts
Expand Up @@ -29,7 +29,7 @@ const parserPreset: ParserPreset = {
issuePrefixesCaseSensitive: true,
mergeCorrespondence: null,
mergePattern: null,
noteKeywords: ['BREAKING CHANGE', 'BREAKING-CHANGE'],
noteKeywords: ['BREAKING-CHANGE'],
referenceActions: Object.values(ReferenceAction),
revertCorrespondence: [
'type',
Expand Down
2 changes: 1 addition & 1 deletion src/config/rules.ts
Expand Up @@ -42,7 +42,7 @@ const rules: RulesConfig = {
'scope-enum': [Severity.Error, 'always', scopes()],
'scope-max-length': [Severity.Error, 'always', max(scopes())],
'scope-min-length': [Severity.Error, 'always', min(scopes())],
'signed-off-by': [Severity.Error, 'always', 'Signed-off-by:'],
'signed-off-by': [Severity.Disabled],
'subject-case': [Severity.Disabled],
'subject-empty': [Severity.Error, 'never'],
'subject-exclamation-mark': [Severity.Disabled],
Expand Down
4 changes: 0 additions & 4 deletions src/types/__tests__/note-keyword.spec-d.ts
Expand Up @@ -6,10 +6,6 @@
import type TestSubject from '../note-keyword'

describe('unit-d:types/NoteKeyword', () => {
it('should extract "BREAKING CHANGE"', () => {
expectTypeOf<TestSubject>().extract('BREAKING CHANGE').toBeString()
})

it('should extract "BREAKING-CHANGE"', () => {
expectTypeOf<TestSubject>().extract('BREAKING-CHANGE').toBeString()
})
Expand Down
2 changes: 1 addition & 1 deletion src/types/note-keyword.ts
Expand Up @@ -8,6 +8,6 @@
*
* @see https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-commits-parser/README.md#notekeywords
*/
type NoteKeyword = 'BREAKING CHANGE' | 'BREAKING-CHANGE'
type NoteKeyword = 'BREAKING-CHANGE'

export type { NoteKeyword as default }

0 comments on commit 135d3eb

Please sign in to comment.