From 717d1c2ff062ae0e2f221916ed2c55914be25c11 Mon Sep 17 00:00:00 2001 From: Cedric van Putten Date: Sat, 23 Mar 2019 23:06:52 +0100 Subject: [PATCH] feat: use conventional config when using zero configuration BREAKING CHANGE: consumers might depend on the "pass through" behaviour of unconfigured commitlint --- @commitlint/cli/README.md | 8 ++++++++ @commitlint/cli/package.json | 1 + @commitlint/cli/src/cli.js | 7 +++++-- @commitlint/cli/src/cli.test.js | 6 +++--- README.md | 11 +++++------ 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/@commitlint/cli/README.md b/@commitlint/cli/README.md index 75f3b0fa4c..a86bba6ebc 100644 --- a/@commitlint/cli/README.md +++ b/@commitlint/cli/README.md @@ -8,6 +8,14 @@ ## Getting started +Commitlint works with zero configuration, it uses the `@commitlint/config-conventional` by default. + +``` +npm install --save-dev @commitlint/cli +``` + +If you want to use other conventions, you can to specify the configuration you want to use. + ``` npm install --save-dev @commitlint/cli @commitlint/config-angular echo "module.exports = {extends: ['@commitlint/config-angular']};" > commitlint.config.js diff --git a/@commitlint/cli/package.json b/@commitlint/cli/package.json index 88e2f2a3d8..5a45ca560d 100644 --- a/@commitlint/cli/package.json +++ b/@commitlint/cli/package.json @@ -72,6 +72,7 @@ "tmp": "0.0.33" }, "dependencies": { + "@commitlint/config-conventional": "^7.5.0", "@commitlint/format": "^7.5.0", "@commitlint/lint": "^7.5.2", "@commitlint/load": "^7.5.0", diff --git a/@commitlint/cli/src/cli.js b/@commitlint/cli/src/cli.js index 49afd48258..6f12618139 100755 --- a/@commitlint/cli/src/cli.js +++ b/@commitlint/cli/src/cli.js @@ -281,8 +281,11 @@ function getSeed(seed) { const e = Array.isArray(seed.extends) ? seed.extends : [seed.extends]; const n = e.filter(i => typeof i === 'string'); return n.length > 0 - ? {extends: n, parserPreset: seed.parserPreset} - : {parserPreset: seed.parserPreset}; + ? {parserPreset: seed.parserPreset, extends: n} + : { + parserPreset: seed.parserPreset, + extends: ['@commitlint/config-conventional'] + }; } function selectParserOpts(parserPreset) { diff --git a/@commitlint/cli/src/cli.test.js b/@commitlint/cli/src/cli.test.js index 0f454d9333..27095d8abe 100644 --- a/@commitlint/cli/src/cli.test.js +++ b/@commitlint/cli/src/cli.test.js @@ -46,10 +46,10 @@ test('should produce no success output with -q flag', async t => { t.is(actual.stderr, ''); }); -test('should fail for input from stdin without rules', async t => { +test('should succeed for input from stdin without configuration', async t => { const cwd = await git.bootstrap('fixtures/empty'); - const actual = await cli([], {cwd})('foo: bar'); - t.is(actual.code, 1); + const actual = await cli([], {cwd})('feat: support zero configuration'); + t.is(actual.code, 0); }); test('should succeed for input from stdin with rules', async t => { diff --git a/README.md b/README.md index 872f939634..067414a182 100644 --- a/README.md +++ b/README.md @@ -77,13 +77,12 @@ These can be modified by [your own configuration](#config). ## Getting started ```sh -# Install commitlint cli and conventional config -npm install --save-dev @commitlint/{config-conventional,cli} -# For Windows: -npm install --save-dev @commitlint/config-conventional @commitlint/cli +# Install commitlint cli +npm install --save-dev @commitlint/cli -# Configure commitlint to use conventional config -echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js +# Configure commitlint to use other conventions +npm install --save-dev @commitlint/cli @commitlint/config-angular +echo "module.exports = {extends: ['@commitlint/config-angular']}" > commitlint.config.js ```