Skip to content

Commit b7d8768

Browse files
committed
docs: reflect new packages in docs
1 parent 620913b commit b7d8768

File tree

9 files changed

+144
-29
lines changed

9 files changed

+144
-29
lines changed

@commitlint/format/README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
1-
> Lint commit messages
1+
> Format commitlint reports
22
33
# @commitlint/format
44

55
## Getting started
66

77
```shell
8-
npm install --save-dev @commitlint/format
8+
npm install --save @commitlint/format
9+
```
10+
11+
## Example
12+
13+
```js
14+
const format = require('@commitlint/format');
15+
16+
format({
17+
warnings: [
18+
{
19+
level: 0,
20+
name: 'some-hint',
21+
message: 'This will not show up as it has level 0'
22+
},
23+
{
24+
level: 1,
25+
name: 'some-warning',
26+
message: 'This will show up yellow as it has level 1'
27+
}
28+
],
29+
errors: [
30+
{
31+
level: 2,
32+
name: 'some-error',
33+
message: 'This will show up red as it has level 2'
34+
}
35+
]
36+
}, {
37+
color: false
38+
});
39+
/* => [
40+
'✖ This will show up red as it has level 2 [some-error]',
41+
' This will not show up as it has level 0 [some-hint]',
42+
'⚠ This will show up yellow as it has level 1 [some-warning]',
43+
'✖ found 1 problems, 2 warnings'
44+
] */
945
```
1046

1147
Consult [docs/api](http://marionebl.github.io/commitlint/#/reference-api) for comprehensive documentation.

@commitlint/format/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@commitlint/format",
33
"version": "6.1.0",
4-
"description": "Lint your commit messages",
4+
"description": "Format commitlint reports",
55
"main": "lib/index.js",
66
"files": [
77
"lib/"

@commitlint/lint/README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1-
> Lint commit messages
1+
> Lint a string against commitlint rules
22
33
# @commitlint/lint
44

55
## Getting started
66

77
```shell
8-
npm install --save-dev @commitlint/lint
8+
npm install --save @commitlint/lint
9+
```
10+
11+
## Example
12+
13+
```js
14+
const lint = require('@commitlint/lint');
15+
16+
lint('foo: bar', {'type-enum': [1, 'always', ['foo']]})
17+
.then(report => console.log(report));
18+
// => { valid: true, errors: [], warnings: [] }
19+
20+
lint('foo: bar', {'type-enum': [1, 'always', ['bar']]})
21+
.then(report => console.log(report));
22+
/* =>
23+
{ valid: true,
24+
errors: [],
25+
warnings:
26+
[ { level: 1,
27+
valid: false,
28+
name: 'type-enum',
29+
message: 'type must be one of [bar]' } ] }
30+
*/
931
```
1032

1133
Consult [docs/api](http://marionebl.github.io/commitlint/#/reference-api) for comprehensive documentation.

@commitlint/lint/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@commitlint/lint",
33
"version": "6.1.0",
4-
"description": "Lint your commit messages",
4+
"description": "Lint a string against commitlint rules",
55
"main": "lib/index.js",
66
"files": [
77
"lib/"

@commitlint/load/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
> Lint commit messages
1+
> Load shared commitlint configuration
22
33
# @commitlint/load
44

@@ -8,4 +8,14 @@
88
npm install --save-dev @commitlint/load
99
```
1010

11+
## Example
12+
13+
```js
14+
const load = require('@commitlint/load');
15+
16+
load({extends: ['./package']})
17+
.then(config => console.log(config));
18+
// => { extends: ['./package', './package-b'], rules: {} }
19+
```
20+
1121
Consult [docs/api](http://marionebl.github.io/commitlint/#/reference-api) for comprehensive documentation.

@commitlint/load/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@commitlint/load",
33
"version": "6.1.0",
4-
"description": "Lint your commit messages",
4+
"description": "Load shared commitlint configuration",
55
"main": "lib/index.js",
66
"files": [
77
"lib/"

@commitlint/read/README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
> Lint commit messages
1+
> Read commit messages from a specified range or last edit
22
33
# @commitlint/read
44

55
## Getting started
66

77
```shell
8-
npm install --save-dev @commitlint/read
8+
npm install --save @commitlint/read
9+
```
10+
11+
## Example
12+
13+
```js
14+
const read = require('@commitlint/read');
15+
16+
// Read last edited commit message
17+
read({edit: true})
18+
.then(messages => console.log(messages));
19+
// => ['I did something\n\n']
20+
21+
// Read from the third to second commit message from HEAD
22+
read({from: 'HEAD~2', to: 'HEAD~1'})
23+
.then(messages => console.log(messages));
24+
// => ['Initial commit\n\n']
925
```
1026

1127
Consult [docs/api](http://marionebl.github.io/commitlint/#/reference-api) for comprehensive documentation.

@commitlint/read/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@commitlint/read",
33
"version": "6.1.0",
4-
"description": "Lint your commit messages",
4+
"description": "Read commit messages from a specified range or last edit",
55
"main": "lib/index.js",
66
"files": [
77
"lib/"

docs/reference-api.md

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# API
22

3-
## Install
3+
## @commitlint/format
4+
5+
> Format commitlint reports
6+
7+
### Install
48

59
```
6-
npm install --save @commitlint/core
10+
npm install --save @commitlint/format
711
```
812

9-
## Methods
10-
11-
### format
12-
> Format commitlint report data to a human-readable format
13+
### Usage
1314

1415
* **Signature**
1516

@@ -47,7 +48,7 @@ format(report?: Report = {}, options?: formatOptions = {}) => string[];
4748
* **Example**
4849

4950
```js
50-
const {format} = require('@commitlint/core');
51+
const format = require('@commitlint/format');
5152

5253
format(); // => [ '\u001b[1m\u001b[32m✔\u001b[39m found 0 problems, 0 warnings\u001b[22m' ]
5354

@@ -82,9 +83,17 @@ format({
8283
] */
8384
```
8485

85-
### load
86+
## @commitlint/load
87+
88+
> Load shared commitlint configuration
89+
90+
### Install
8691

87-
> load all relevant shared configuration
92+
```
93+
npm install --save @commitlint/load
94+
```
95+
96+
### Usage
8897

8998
* **Signature**
9099

@@ -186,7 +195,7 @@ load(seed: Seed = {}) => Promise<Config>;
186195
* **Example**
187196

188197
```js
189-
const {load} = require('@commitlint/core');
198+
const load = require('@commitlint/load');
190199

191200
load({
192201
rules: {
@@ -205,9 +214,17 @@ load({parserPreset: './parser-preset.js'})
205214
// => { extends: [], rules: {}, parserPreset: {name: './parser-preset.js', path: './parser-preset.js', opts: {}}}
206215
```
207216

208-
### read
217+
### @commitlint/read
209218

210-
> Read commit messages from as specified range
219+
> Read commit messages from a specified range or disk
220+
221+
### Install
222+
223+
```
224+
npm install --save @commitlint/read
225+
```
226+
227+
### Usage
211228

212229
* **Signature**
213230

@@ -228,7 +245,7 @@ read(range: Range) => Promise<string[]>
228245

229246
```js
230247
// git commit -m "I did something"
231-
const {read} = require('@commitlint/core');
248+
const read = require('@commitlint/read');
232249

233250
read({edit: true})
234251
.then(messages => console.log(messages));
@@ -249,6 +266,16 @@ read({from: 'HEAD~2', to: 'HEAD~1'})
249266

250267
### lint
251268

269+
> Lint a string against commitlint rules
270+
271+
### Install
272+
273+
```
274+
npm install --save @commitlint/lint
275+
```
276+
277+
### Usage
278+
252279
* **Signature**
253280

254281
```ts
@@ -284,7 +311,7 @@ lint(message: string, rules: {[ruleName: string]: Rule}, opts?: Options) => Prom
284311
* **Basic Example**
285312

286313
```js
287-
const {lint} = require('@commitlint/core');
314+
const lint = require('@commitlint/lint');
288315

289316
lint('foo: bar')
290317
.then(report => console.log(report));
@@ -315,10 +342,11 @@ lint('foo-bar', {'type-enum': [2, 'always', ['foo']]}, opts).then(report => cons
315342
* **Load configuration**
316343

317344
```js
318-
const {lint, load} = require('@commitlint/core');
345+
const load = require('@commitlint/load');
346+
const lint = require('@commitlint/lint');
319347

320348
const CONFIG = {
321-
extends: ['./@commitlint/config-conventional']
349+
extends: ['@commitlint/config-conventional']
322350
};
323351

324352
load(CONFIG)
@@ -338,7 +366,8 @@ load(CONFIG)
338366
* **Read git history**
339367

340368
```js
341-
const {lint, read} = require('@commitlint/core');
369+
const lint = require('@commitlint/lint');
370+
const read = require('@commitlint/read');
342371

343372
const RULES = {
344373
'type-enum': [2, 'always', ['foo']]
@@ -353,7 +382,9 @@ read({to: 'HEAD', from: 'HEAD~2'})
353382
* **Simplfied last-commit checker**
354383

355384
```js
356-
const {lint, load, read} = require('@commitlint/core');
385+
const load = require('@commitlint/load');
386+
const read = require('@commitlint/read');
387+
const lint = require('@commitlint/lint');
357388

358389
Promise.all([load(), read({from: 'HEAD~1'})])
359390
.then(tasks => {

0 commit comments

Comments
 (0)