Skip to content

Commit 23f7097

Browse files
committed
docs: add usage documentation
1 parent 50f657a commit 23f7097

11 files changed

Lines changed: 549 additions & 3 deletions

README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,48 @@
1-
Dart version commitlint - A tool to lint commit message.
1+
## commitlint
2+
3+
> Dart version commitlint - A tool to lint commit messages.
4+
5+
## Getting started
6+
7+
commitlint helps your team adhere to a commit convention. By supporting pub-installed configurations it makes sharing of commit conventions easy.
8+
9+
### Install
10+
11+
```bash
12+
# Install and configure if needed
13+
dart pub add --dev commitlint_cli commitlint_config
14+
```
15+
16+
### Configuration
17+
18+
```bash
19+
# Configure commitlint to use conventional config
20+
echo "include: package:commitlint_config/commitlint.yaml" > commitlint.yaml
21+
```
22+
23+
### Test
24+
25+
```bash
26+
# Lint from stdin
27+
echo 'foo: bar' | commitlint --input
28+
⧗ input: foo: bar
29+
type must be one of [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test] [type-enum]
30+
31+
✖ found 1 problems, 0 warnings
32+
ⓘ Get help: http://hyiso.github.io/commitlint/#/concepts-convensional-commits
33+
```
34+
35+
```bash
36+
# Lint last commit from history
37+
commitlint --from=HEAD~1
38+
```
39+
40+
?> To get the most out of `commitlint` you'll want to automate it in your project lifecycle. See our [Setup guide](./guides-setup.md) for next steps.
41+
42+
## Documentation
43+
44+
See [documention](https://hyiso.github.io/commitlint)
45+
46+
- **Guides** - Common use cases explained in a step-by-step pace
47+
- **Concepts** - Overarching topics important to understand the use of `commitlint`
48+
- **Reference** - Mostly technical documentation

commitlint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:commitlint_config/commitlint.yaml
1+
include: ./packages/commitlint_config/lib/commitlint.yaml
22

33
rules:
44
scope-enum:

docs/.nojekyll

Whitespace-only changes.

docs/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## commitlint
2+
3+
> Dart version commitlint - A tool to lint commit messages.
4+
5+
## Getting started
6+
7+
commitlint helps your team adhere to a commit convention. By supporting pub-installed configurations it makes sharing of commit conventions easy.
8+
9+
### Install
10+
11+
```bash
12+
# Install and configure if needed
13+
dart pub add --dev commitlint_cli commitlint_config
14+
```
15+
16+
### Configuration
17+
18+
```bash
19+
# Configure commitlint to use conventional config
20+
echo "include: package:commitlint_config/commitlint.yaml" > commitlint.yaml
21+
```
22+
23+
### Test
24+
25+
```bash
26+
# Lint from stdin
27+
echo 'foo: bar' | commitlint --input
28+
⧗ input: foo: bar
29+
type must be one of [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test] [type-enum]
30+
31+
✖ found 1 problems, 0 warnings
32+
ⓘ Get help: http://hyiso.github.io/commitlint/#/concepts-convensional-commits
33+
```
34+
35+
```bash
36+
# Lint last commit from history
37+
commitlint --from=HEAD~1
38+
```
39+
40+
?> To get the most out of `commitlint` you'll want to automate it in your project lifecycle. See our [Setup guide](./guides-setup.md) for next steps.
41+
42+
## Documentation
43+
44+
- **Guides** - Common use cases explained in a step-by-step pace
45+
- **Concepts** - Overarching topics important to understand the use of `commitlint`
46+
- **Reference** - Mostly technical documentation

docs/_sidebar.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- Guides
2+
- [Setup](guides-setup.md)
3+
- Concepts
4+
- [Convensional commits](concepts-convensional-commits.md)
5+
- [Shareable config](concepts-shareable-config.md)
6+
- References
7+
- [Rules](references-rules.md)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Concept: Convensional commits
2+
3+
[Convensional commits](https://www.conventionalcommits.org/) allow your team to add more semantic meaning to your git history. This e.g. includes `type`, `scope` or `breaking changes`.
4+
5+
With this additional information tools can derive useful human-readable information for releases of your project. Some examples are
6+
7+
- Automated, rich changelogs
8+
- Automatic version bumps
9+
- Filter for test harnesses to run
10+
11+
The most common convensional commits follow this pattern:
12+
13+
```
14+
type(scope?): subject
15+
body?
16+
footer?
17+
```
18+
19+
## Multiple scopes
20+
21+
Commitlint supports multiple scopes.
22+
Current delimiter options are:
23+
24+
- "/"
25+
- "\\"
26+
- ","

docs/concepts-shareable-config.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Concept: Shareable configuration
2+
3+
Most commonly shareable configuration is delivered as pub package exporting one or multi
4+
`.yaml` file(s) containing `rules` section. To use shared configuration you specify it as value for key `include`
5+
6+
```yaml
7+
# commitlint.yaml
8+
include: package:commitlint_config/commitlint.yaml
9+
```
10+
11+
This causes `commitlint` to pick up `commitlint_config/commitlint.yaml`. Make it available by installing it.
12+
13+
```bash
14+
dart pub add --dev commitlint_config
15+
```
16+
17+
The rules found in `commitlint_config/commitlint.yaml` are merged with the rules in `commitlint.yaml`, if any.
18+
19+
This works recursively, enabling shareable configuration to extend on an indefinite chain of other shareable configurations.
20+
21+
## Relative config
22+
23+
You can also load local configuration by using a relative path to the file.
24+
25+
> This must always start with a `.` (dot).
26+
27+
```yaml
28+
# commitlint.yaml
29+
include: ./lints/commitlint.yaml
30+
```

docs/guides-setup.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Guide: Setup
2+
3+
Get high commit message quality and short feedback cycles by linting commit messages right when they are authored.
4+
5+
This guide demonstrates how to achieve this via git hooks.
6+
7+
## Install commitlint
8+
9+
Install `commitlint_cli` and a `commitlint_config` of your choice as dev dependency and
10+
configure `commitlint` to use it.
11+
12+
```bash
13+
# Install and configure if needed
14+
dart pub add --dev commitlint_cli commitlint_config
15+
16+
# Configure commitlint to use conventional config
17+
echo "include: package:commitlint_config/commitlint.yaml" > commitlint.yaml
18+
```
19+
20+
## Install husky
21+
22+
Install [husky](https://pub.dev/packages/husky) as dev dependency, a handy git hook helper available on pub.
23+
24+
```sh
25+
# Install Husky
26+
dart pub add --dev husky
27+
28+
# Activate hooks
29+
dart run husky install
30+
```
31+
32+
### Add hook
33+
34+
```
35+
dart run husky add .husky/commit-msg 'dart run commitlint_cli --edit ${1}'
36+
```
37+
38+
## Test
39+
40+
### Test simple usage
41+
42+
For a first simple usage test of commitlint you can do the following:
43+
44+
```bash
45+
dart run commitlint_cli --from HEAD~1 --to HEAD
46+
```
47+
48+
This will check your last commit and return an error if invalid or a positive output if valid.
49+
50+
### Test the hook
51+
52+
You can test the hook by simply committing. You should see something like this if everything works.
53+
54+
```bash
55+
git commit -m "foo: this will fail"
56+
No staged files match any of provided globs.
57+
⧗ input: foo: this will fail
58+
type must be one of [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test] [type-enum]
59+
60+
✖ found 1 problems, 0 warnings
61+
ⓘ Get help: http://hyiso.github.io/commitlint/#/concepts-convensional-commits
62+
63+
husky - commit-msg hook exited with code 1 (add --no-verify to bypass)
64+
```
65+
66+
?> Local linting is fine for fast feedback but can easily be tinkered with. To ensure all commits are linted you'll want to check commits on an automated CI Server too. Learn how to in the [CI Setup guide](guides-ci-setup.md).

docs/index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>commitlint - Lint commit messages</title>
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7+
<meta name="description" content="Description">
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
9+
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
10+
</head>
11+
<body>
12+
<div id="app"></div>
13+
<script>
14+
window.$docsify = {
15+
name: 'commitlint',
16+
repo: 'https://github.com/hyiso/commitlint',
17+
18+
subMaxLevel: 2,
19+
loadSidebar: true,
20+
}
21+
</script>
22+
<!-- Docsify v4 -->
23+
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
24+
</body>
25+
</html>

0 commit comments

Comments
 (0)