Skip to content

Commit 589fd88

Browse files
committed
chore(docs): add description for package.json support, improve document
1 parent 1a04907 commit 589fd88

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

README.md

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@
55
[![Build status][appveyor-image]][appveyor-url]
66
[![Coverage Status][coveralls-image]][coveralls-url]
77

8-
[commitlint][] sharable configuration files, which also includes modules & API
9-
for config conversion.
8+
[commitlint][] sharable configuration files for [cz-customizable][]
9+
(customizable [Commitizen][commitizen] adapter for [conventional commits][conventional-commits] and [conventional changelog][conventional-changelog]).
1010

11-
If `.cz-config.js` that is for [@whizark/cz-cli][] or
12-
[cz-customizable][] exists in your package root directory, its
13-
`{types,scopes,scopeOverrides}` are merged with
14-
`rules.{type-enum,scope-enum}`.
11+
You can now **consistently manage your commit types/scopes** for cz-customizable and commitlint **in one place**.
12+
13+
commitlint-config-cz **merges** `{types,scopes,scopeOverrides}` (cz-customizable config) with
14+
`rules.{type-enum,scope-enum}` (commitlint config) and **includes some modules and API** for config conversion.
15+
16+
## Supported Config
17+
18+
commitlint-config-cz use only one config in the following order of precedence.
19+
20+
1. [`config.cz-customizable.config`][cz-customizable-configure] in `package.json`.
21+
2. `.cz-config.js` in your package root (supported by [@whizark/cz-cli][]).
1522

1623
## Installation
1724

@@ -23,7 +30,7 @@ npm install commitlint-config-cz --save-dev
2330

2431
## Usage
2532

26-
Extend `commitlint-config-cz` in `commitlint.config.js`.
33+
Extend your commitlint config by `cz` in `commitlint.config.js`.
2734

2835
```js
2936
module.exports = {
@@ -36,19 +43,19 @@ module.exports = {
3643

3744
## Modules & API
3845

39-
There are some modules and API to convert `cz-customizable`'s config into `commitlint`'s config.
46+
commitlint-config-cz includes some modules and API for config conversion.
4047

4148
### `config.js`
4249

43-
Gets the `commitlint` config from the `.cz-config.js` in the package root.
50+
Gets the converted commitlint config from the cz-customizable config which is defined in `package.json` or `.cz-config.js` in your package root.
4451

4552
```js
4653
const config = require('commitlint-config-cz/lib/config')();
4754
````
4855

4956
#### `get(pathOrCzConfig: string | Object, defaultConfig?: Object): Object`
5057

51-
Gets the `commitlint` config from a `cz-customizable` config.
58+
Gets the commitlint config from a path to config file.
5259

5360
```js
5461
const getConfig = require('commitlint-config-cz/lib/config').get;
@@ -87,24 +94,24 @@ const defaultConfig = { // The default `commitlint` config.
8794
const config = getConfig(czConfig, defaultConfig);
8895
````
8996
90-
1. If `cz-customizable` config has `scopes`, `scopeOverrides` or `types` field,
91-
the value(s) [3] of the default `commitlint` config is/are **REPLACED** by converted value(s).
97+
1. If cz-customizable config has `scopes`, `scopeOverrides` or `types` field,
98+
the value(s) [3] of the default commitlint config is/are **REPLACED** by converted value(s).
9299
Level [1] and applicability [2] remain as they are.
93-
2. `scope-enum` rule or/and `type-enum` rule is/are completely **REMOVED**, if its value is an empty array.
100+
2. `scope-enum` rule or/and `type-enum` rule is/are **REMOVED**, if its value is an empty array.
94101
95102
---
96103
97104
### `cz-config.js`
98105
99-
Gets the `.cz-config.js` as an object in the package root.
106+
Gets the cz-customizable config as an object from `package.json` or `.cz-config.js` in your package root.
100107
101108
```js
102109
const czConfig = require('commitlint-config-cz/lib/cz-config')();
103110
````
104111

105112
#### `get(path: string): Object`
106113

107-
Gets the `cz-customizable` config object from a path.
114+
Gets the cz-customizable config as an object from a path.
108115

109116
```js
110117
const getCzConfig = require('commitlint-config-cz/lib/cz-config').get;
@@ -116,19 +123,19 @@ const czConfig = getCzConfig('path/to/.cz-config.js');
116123
117124
### `scopes.js`
118125
119-
Gets the `value` for [scope-enum][] rule from the `.cz-config.js` in the package root.
126+
Gets the value for [scope-enum][] rule from `package.json` or `.cz-config.js` in your package root.
120127
121128
```js
122129
const scopes = require('commitlint-config-cz/lib/scopes')();
123130
````
124131

125132
#### `get(czConfig: Object): string[]`
126133

127-
Gets the `value` for [scope-enum][] rule from a `cz-customizable` config object.
134+
Gets the value for [scope-enum][] rule from a cz-customizable config object.
128135

129136
```js
130137
const getScopes = require('commitlint-config-cz/lib/scopes').get;
131-
const czConfig = { /* `cz-customizable` config object. */ };
138+
const czConfig = { /* cz-customizable config object. */ };
132139
133140
const scopes = getScopes(czConfig);
134141
````
@@ -137,15 +144,15 @@ const scopes = getScopes(czConfig);
137144
138145
### `types.js`
139146
140-
Gets the `value` for [type-enum][] rule from the `.cz-config.js` in the package root.
147+
Gets the value for [type-enum][] rule from `package.json` or `.cz-config.js` in your package root.
141148
142149
```js
143150
const types = require('commitlint-config-cz/lib/types')();
144151
````
145152

146153
#### `get(czConfig: Object): string[]`
147154

148-
Gets the `value` for [type-enum][] rule from a `cz-customizable` config object.
155+
Gets the value for [type-enum][] rule from `package.json` or `cz-customizable` config object.
149156

150157
```js
151158
const getTypes = require('commitlint-config-cz/lib/types').get;
@@ -155,8 +162,12 @@ const types = getTypes(czConfig);
155162
````
156163
157164
[commitlint]: https://github.com/marionebl/commitlint
158-
[@whizark/cz-cli]: https://github.com/whizark/cz-cli
159165
[cz-customizable]: https://github.com/leonardoanalista/cz-customizable
166+
[commitizen]: https://github.com/commitizen/cz-cli
167+
[conventional-commits]: https://www.conventionalcommits.org
168+
[conventional-changelog]: https://github.com/conventional-changelog/conventional-changelog
169+
[cz-customizable-configure]: https://github.com/leonardoanalista/cz-customizable#configure
170+
[@whizark/cz-cli]: https://github.com/whizark/cz-cli
160171
161172
[npm-image]: https://img.shields.io/npm/v/commitlint-config-cz.svg
162173
[npm-url]: https://www.npmjs.com/commitlint-config-cz

0 commit comments

Comments
 (0)