Skip to content

Commit d4bdcf6

Browse files
authored
feat(config-angular): update to latest convention (#123)
* refactor(config-angular): break out config-angular-type-enum * feat(config-angular-type-enum): remove chore type * feat(config-angular): disallow subject with uppercase first character * fix(core): interprete array values for subject-case correctly * test: adapt to new angular rules BREAKING CHANGE TL;DR * chore is no longer a valid commit type * subject with leading capitalized letter are forbidden now Angular has removed the chore type from their conventions as of January 2017 See angular/angular@dff6ee3#diff-6a3371457528722a734f3c51d9238c13L204 for reference This removes the previous chore type from the list of allowed types. Projects using the Angular commit convention will identify commits with chore type as faulty. Also, formerly working commit messages are now considered problems: * type: SOME MESSAGE * type: SomeMessage * type: Some Message
1 parent 5540abb commit d4bdcf6

37 files changed

+242
-211
lines changed

@commitlint/cli/src/cli.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ test('should work with husky commitmsg hook and git commit', async () => {
8888

8989
await execa('npm', ['install'], {cwd});
9090
await execa('git', ['add', 'package.json'], {cwd});
91-
await execa('git', ['commit', '-m', '"chore: this should work"'], {cwd});
91+
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
9292
});
9393

9494
test('should work with husky commitmsg hook in sub packages', async () => {
@@ -98,7 +98,7 @@ test('should work with husky commitmsg hook in sub packages', async () => {
9898

9999
await execa('npm', ['install'], {cwd});
100100
await execa('git', ['add', 'package.json'], {cwd});
101-
await execa('git', ['commit', '-m', '"chore: this should work"'], {cwd});
101+
await execa('git', ['commit', '-m', '"test: this should work"'], {cwd});
102102
});
103103

104104
test('should pick up parser preset and fail accordingly', async t => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# @commitlint/config-angular-type-enum
2+
3+
Shareable `commitlint` config enforcing the angular commit convention types.
4+
Use with [@commitlint/cli](../cli) and [@commitlint/prompt-cli](../prompt-cli).
5+
6+
See [@commitlint/config-angular](../config-angular) for full angular conventions.
7+
8+
## Getting started
9+
10+
```sh
11+
npm install --save-dev @commitlint/config-angular-types @commitlint/cli
12+
echo "module.exports = {extends: ['@commitlint/config-angular-type-enum']};" > commitlint.config.js
13+
```
14+
15+
## Usage
16+
17+
```sh
18+
echo "foo: bar" | commitlint # fails
19+
echo "build: bar" | commitlint # passes
20+
```
21+
22+
## Examples
23+
24+
```js
25+
// commitlint.config.js
26+
const types = require("@commitlint/config-angular-type-enum");
27+
28+
// Use as rule creating errors for non-allowed types
29+
module.exports = {
30+
rules: {
31+
...types.rules
32+
}
33+
};
34+
35+
// Warn for non-allowed types
36+
module.exports = {
37+
rules: {
38+
'type-enum': [1, 'always', types.values()]
39+
}
40+
};
41+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const types = [
2+
'build',
3+
'ci',
4+
'docs',
5+
'feat',
6+
'fix',
7+
'perf',
8+
'refactor',
9+
'revert',
10+
'style',
11+
'test'
12+
];
13+
14+
module.exports.rules = {
15+
'type-enum': [2, 'always', types]
16+
};
17+
18+
module.exports.value = () => types;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "@commitlint/config-angular-type-enum",
3+
"version": "4.3.0",
4+
"description": "Shareable commitlint config enforcing the angular commit convention types",
5+
"scripts": {
6+
"clean": "exit 0",
7+
"pretest": "dep-check",
8+
"start": "exit 0",
9+
"test": "exit 0"
10+
},
11+
"xo": false,
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/marionebl/commitlint.git"
15+
},
16+
"keywords": [
17+
"conventional-changelog",
18+
"commitlint",
19+
"commitlint-config",
20+
"angular"
21+
],
22+
"author": "Mario Nebl <[email protected]>",
23+
"license": "MIT",
24+
"bugs": {
25+
"url": "https://github.com/marionebl/commitlint/issues"
26+
},
27+
"homepage": "https://github.com/marionebl/commitlint#readme",
28+
"devDependencies": {
29+
"@commitlint/utils": "^4.2.1"
30+
}
31+
}

@commitlint/config-angular/README.md

+49-9
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Consult [docs/rules](http://marionebl.github.io/commitlint/#/reference-rules) fo
2727
```js
2828
[
2929
'build',
30-
'chore',
3130
'ci',
3231
'docs',
3332
'feat',
@@ -40,6 +39,11 @@ Consult [docs/rules](http://marionebl.github.io/commitlint/#/reference-rules) fo
4039
]
4140
```
4241

42+
```sh
43+
echo "foo: some message" # fails
44+
echo "fix: some message" # passes
45+
```
46+
4347
#### type-case
4448
* **description**: `type` is in case `value`
4549
* **rule**: `always`
@@ -48,21 +52,54 @@ Consult [docs/rules](http://marionebl.github.io/commitlint/#/reference-rules) fo
4852
'lowerCase'
4953
```
5054

55+
```sh
56+
echo "FIX: some message" # fails
57+
echo "fix: some message" # passes
58+
```
59+
5160
#### type-empty
5261
* **condition**: `type` is empty
5362
* **rule**: `never`
5463

64+
```sh
65+
echo ": some message" # fails
66+
echo "fix: some message" # passes
67+
```
68+
5569
#### scope-case
5670
* **condition**: `scope` is in case `value`
5771
* **rule**: `always`
5872
```js
5973
'lowerCase'
6074
```
6175

76+
```sh
77+
echo "fix(SCOPE): some message" # fails
78+
echo "fix(scope): some message" # passes
79+
```
80+
81+
#### subject-case
82+
* **condition**: `subject` is in one of the cases `['sentence-case', 'start-case', 'pascal-case', 'upper-case']`
83+
* **rule**: `never`
84+
85+
```sh
86+
echo "fix(SCOPE): Some message" # fails
87+
echo "fix(SCOPE): Some Message" # fails
88+
echo "fix(SCOPE): SomeMessage" # fails
89+
echo "fix(SCOPE): SOMEMESSAGE" # fails
90+
echo "fix(scope): some message" # passes
91+
echo "fix(scope): some Message" # passes
92+
```
93+
6294
#### subject-empty
6395
* **condition**: `subject` is empty
6496
* **rule**: `never`
6597

98+
```sh
99+
echo "fix:" # fails
100+
echo "fix: some message" # passes
101+
```
102+
66103
#### subject-full-stop
67104
* **condition**: `subject` ends with `value`
68105
* **rule**: `never`
@@ -71,6 +108,12 @@ Consult [docs/rules](http://marionebl.github.io/commitlint/#/reference-rules) fo
71108
'.'
72109
```
73110

111+
```sh
112+
echo "fix: some message." # fails
113+
echo "fix: some message" # passes
114+
```
115+
116+
74117
#### header-max-length
75118
* **condition**: `header` has `value` or less characters
76119
* **rule**: `always`
@@ -79,17 +122,14 @@ Consult [docs/rules](http://marionebl.github.io/commitlint/#/reference-rules) fo
79122
72
80123
```
81124

125+
```sh
126+
echo "fix: some message that is way too long and breaks the line max-length by several characters" # fails
127+
echo "fix: some message" # passes
128+
```
129+
82130
### Warnings
83131
The following rules are considered warnings for `@commitlint/config-angular` and will print warning messages when not met.
84132

85133
#### body-leading-blank
86134
* **condition**: Body begins with blank line
87135
* **rule**: `always`
88-
89-
#### lang
90-
* **condition**: `subject` is of language `value`
91-
* **rule**: `always`
92-
* **value**
93-
```js
94-
eng
95-
```

@commitlint/config-angular/index.js

+10-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
1+
const typeEnum = require('@commitlint/config-angular-type-enum');
2+
13
module.exports = {
24
rules: {
35
'body-leading-blank': [1, 'always'],
46
'footer-leading-blank': [1, 'always'],
57
'header-max-length': [2, 'always', 72],
6-
'scope-case': [2, 'always', 'lowerCase'],
8+
'scope-case': [2, 'always', 'lower-case'],
9+
'subject-case': [
10+
2,
11+
'never',
12+
['sentence-case', 'start-case', 'pascal-case', 'upper-case']
13+
],
714
'subject-empty': [2, 'never'],
815
'subject-full-stop': [2, 'never', '.'],
9-
'type-case': [2, 'always', 'lowerCase'],
16+
'type-case': [2, 'always', 'lower-case'],
1017
'type-empty': [2, 'never'],
11-
'type-enum': [
12-
2,
13-
'always',
14-
[
15-
'build',
16-
'chore',
17-
'ci',
18-
'docs',
19-
'feat',
20-
'fix',
21-
'perf',
22-
'refactor',
23-
'revert',
24-
'style',
25-
'test'
26-
]
27-
]
18+
'type-enum': typeEnum.rules['type-enum']
2819
}
2920
};

@commitlint/config-angular/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@
2727
"homepage": "https://github.com/marionebl/commitlint#readme",
2828
"devDependencies": {
2929
"@commitlint/utils": "^4.2.1"
30+
},
31+
"dependencies": {
32+
"@commitlint/config-angular-type-enum": "^4.3.0"
3033
}
3134
}

@commitlint/config-lerna-scopes/readme.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ packages
2626
├── app
2727
└── web
2828
29-
❯ echo "chore(api): fix something in api's build" | commitlint
30-
⧗ input: chore(api): fix something in api's build
29+
❯ echo "buid(api): change something in api's build" | commitlint
30+
⧗ input: build(api): change something in api's build
3131
✔ found 0 problems, 0 warnings
3232
33-
❯ echo "chore(foo): this won't pass" | commitlint
34-
⧗ input: chore(foo): this won't pass
33+
❯ echo "test(foo): this won't pass" | commitlint
34+
⧗ input: test(foo): this won't pass
3535
✖ scope must be one of [api, app, web] [scope-enum]
3636
✖ found 1 problems, 0 warnings
3737
38-
❯ echo "chore: do some general maintenance" | commitlint
39-
⧗ input: chore: do some general maintenance
38+
❯ echo "ci: do some general maintenance" | commitlint
39+
⧗ input: ci: do some general maintenance
4040
✔ found 0 problems, 0 warnings
4141
```
4242

@commitlint/core/fixtures/overridden-type-enums/extended.js

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = {
55
'always',
66
[
77
'build',
8-
'chore',
98
'ci',
109
'docs',
1110
'feat',

@commitlint/core/src/rules/body-case.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import parse from '../library/parse';
33
import bodyCase from './body-case';
44

55
const messages = {
6-
empty: 'chore: subject',
7-
lowercase: 'chore: subject\nbody',
8-
mixedcase: 'chore: subject\nBody',
9-
uppercase: 'chore: subject\nBODY'
6+
empty: 'test: subject',
7+
lowercase: 'test: subject\nbody',
8+
mixedcase: 'test: subject\nBody',
9+
uppercase: 'test: subject\nBODY'
1010
};
1111

1212
const parsed = {

@commitlint/core/src/rules/body-empty.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import parse from '../library/parse';
33
import bodyEmpty from './body-empty';
44

55
const messages = {
6-
empty: 'chore: subject',
7-
filled: 'chore: subject\nbody'
6+
empty: 'test: subject',
7+
filled: 'test: subject\nbody'
88
};
99

1010
const parsed = {

@commitlint/core/src/rules/body-leading-blank.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import parse from '../library/parse';
33
import bodyLeadingBlank from './body-leading-blank';
44

55
const messages = {
6-
simple: 'chore: subject',
7-
without: 'chore: subject\nbody',
8-
with: 'chore: subject\n\nbody'
6+
simple: 'test: subject',
7+
without: 'test: subject\nbody',
8+
with: 'test: subject\n\nbody'
99
};
1010

1111
const parsed = {

@commitlint/core/src/rules/body-max-length.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const long = 'ab';
88
const value = short.length;
99

1010
const messages = {
11-
empty: 'chore: subject',
12-
short: `chore: subject\n${short}`,
13-
long: `chore: subject\n${long}`
11+
empty: 'test: subject',
12+
short: `test: subject\n${short}`,
13+
long: `test: subject\n${long}`
1414
};
1515

1616
const parsed = {

@commitlint/core/src/rules/body-min-length.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const long = 'ab';
88
const value = long.length;
99

1010
const messages = {
11-
simple: 'chore: subject',
12-
short: `chore: subject\n${short}`,
13-
long: `chore: subject\n${long}`
11+
simple: 'test: subject',
12+
short: `test: subject\n${short}`,
13+
long: `test: subject\n${long}`
1414
};
1515

1616
const parsed = {

@commitlint/core/src/rules/body-tense.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import parse from '../library/parse';
33
import bodyTense from './body-tense';
44

55
test('returns deprecation warning', async t => {
6-
const actual = bodyTense(await parse('chore: \n'), 'always', [
6+
const actual = bodyTense(await parse('test: \n'), 'always', [
77
'present-imperative'
88
]);
99
t.deepEqual(actual, [

@commitlint/core/src/rules/footer-empty.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import parse from '../library/parse';
33
import footerEmpty from './footer-empty';
44

55
const messages = {
6-
simple: 'chore: subject',
7-
empty: 'chore: subject\nbody',
8-
filled: 'chore: subject\nBREAKING CHANGE: something important'
6+
simple: 'test: subject',
7+
empty: 'test: subject\nbody',
8+
filled: 'test: subject\nBREAKING CHANGE: something important'
99
};
1010

1111
const parsed = {

0 commit comments

Comments
 (0)