Skip to content

Commit 717d1c2

Browse files
committed
feat: use conventional config when using zero configuration
BREAKING CHANGE: consumers might depend on the "pass through" behaviour of unconfigured commitlint
1 parent ba90e8e commit 717d1c2

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

@commitlint/cli/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88

99
## Getting started
1010

11+
Commitlint works with zero configuration, it uses the `@commitlint/config-conventional` by default.
12+
13+
```
14+
npm install --save-dev @commitlint/cli
15+
```
16+
17+
If you want to use other conventions, you can to specify the configuration you want to use.
18+
1119
```
1220
npm install --save-dev @commitlint/cli @commitlint/config-angular
1321
echo "module.exports = {extends: ['@commitlint/config-angular']};" > commitlint.config.js

@commitlint/cli/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"tmp": "0.0.33"
7373
},
7474
"dependencies": {
75+
"@commitlint/config-conventional": "^7.5.0",
7576
"@commitlint/format": "^7.5.0",
7677
"@commitlint/lint": "^7.5.2",
7778
"@commitlint/load": "^7.5.0",

@commitlint/cli/src/cli.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,11 @@ function getSeed(seed) {
281281
const e = Array.isArray(seed.extends) ? seed.extends : [seed.extends];
282282
const n = e.filter(i => typeof i === 'string');
283283
return n.length > 0
284-
? {extends: n, parserPreset: seed.parserPreset}
285-
: {parserPreset: seed.parserPreset};
284+
? {parserPreset: seed.parserPreset, extends: n}
285+
: {
286+
parserPreset: seed.parserPreset,
287+
extends: ['@commitlint/config-conventional']
288+
};
286289
}
287290

288291
function selectParserOpts(parserPreset) {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ test('should produce no success output with -q flag', async t => {
4646
t.is(actual.stderr, '');
4747
});
4848

49-
test('should fail for input from stdin without rules', async t => {
49+
test('should succeed for input from stdin without configuration', async t => {
5050
const cwd = await git.bootstrap('fixtures/empty');
51-
const actual = await cli([], {cwd})('foo: bar');
52-
t.is(actual.code, 1);
51+
const actual = await cli([], {cwd})('feat: support zero configuration');
52+
t.is(actual.code, 0);
5353
});
5454

5555
test('should succeed for input from stdin with rules', async t => {

README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,12 @@ These can be modified by [your own configuration](#config).
7777
## Getting started
7878

7979
```sh
80-
# Install commitlint cli and conventional config
81-
npm install --save-dev @commitlint/{config-conventional,cli}
82-
# For Windows:
83-
npm install --save-dev @commitlint/config-conventional @commitlint/cli
80+
# Install commitlint cli
81+
npm install --save-dev @commitlint/cli
8482

85-
# Configure commitlint to use conventional config
86-
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js
83+
# Configure commitlint to use other conventions
84+
npm install --save-dev @commitlint/cli @commitlint/config-angular
85+
echo "module.exports = {extends: ['@commitlint/config-angular']}" > commitlint.config.js
8786
```
8887

8988

0 commit comments

Comments
 (0)