Skip to content

feat: use conventional config when using zero configuration #600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions @commitlint/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions @commitlint/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions @commitlint/cli/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions @commitlint/cli/src/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```


Expand Down