Skip to content
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

[WIP] Perfect readme #11

Merged
merged 4 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
# commitlint-wizardoc

English | [中文文档](doc/README-zh.md)

commitlint-wizardoc is a configuration package for [commitlint](https://github.com/conventional-changelog/commitlint) that contain some rules and plugins to check that your commit message conform to the `Wizardoc` convention.

## Usage

If you have never used commitlint before, you can visit [commitlint document](https://commitlint.js.org/) for more detail.

### Install

You can install `commitlint-wizardoc` using NPM and YARN as well.

```shell
# NPM
npm i commitlint-wizardoc -D
npm i commitlint-config-wizardoc -D

# YARN
yarn add commitlint-wizardoc -D
yarn add commitlint-config-wizardoc -D
```

### Configuration

Create a [commitlint](https://github.com/conventional-changelog/commitlint) config in the root path of your project, and you can extends the `wizardoc` config to do all configuration work.

For instance, create `.commitlintrc.js` that looks like:

```js
module.exports = {
// This line config will read the NPM package named "commitlint-config-wizardoc", so please make sure you have installed it before config this line.
extends: 'wizardoc'
}
extends: "wizardoc",
};
```

Now, that's all you need to do.

## Convention

The commit message should consists of four parts:

```
![Feat::scope] some sentence
^ ^ ^ ^
Expand All @@ -54,17 +62,19 @@ The commit message should consists of four parts:
- Update
- Refactor
- Move
- New
- Perf
- Doc
- Add
- Patch
- Fix
- Test
- Stub
- Chore
- `Scope`: scope of modification
- `Subject`: description of the commit
- `Subject`: description of the commit

## Override configs

You can also override `Wizardoc` config to create your own configuration as well.

```js
Expand All @@ -78,4 +88,5 @@ module.exports = {
```

## LICENSE

MIT.
96 changes: 96 additions & 0 deletions doc/README-zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# commitlint-wizardoc

[English](/README.md) | 中文文档

commitlint-wizardoc 是 [commitlint](https://github.com/conventional-changelog/commitlint) 的配置包,其中包含某些规则和插件,以检查您的提交`commit-message`是否符合 `Wizardoc` 约定。

## 用法

如果你之前没有使用过 commitlint,你可以前往[commitlint document](https://commitlint.js.org/)来查看更多详情。

### 安装

你可以使用`npm`和`yarn`来安装`commitlint-wizardoc`。

```shell
# NPM
npm i commitlint-config-wizardoc -D

# YARN
yarn add commitlint-config-wizardoc -D
```

### 配置

在你项目的根目录下创建一个[commitlint](https://github.com/conventional-changelog/commitlint)的配置文件,你能通过`extends` `wizardoc`的`config`文件来完成配置。

例如,将以下代码加入到`.commitlintrc.js`文件。

```js
module.exports = {
// This line config will read the NPM package named "commitlint-config-wizardoc", so please make sure you have installed it before config this line.
extends: "wizardoc",
};
```

只需要做这些,你就可以使用`commitlint-wizardow`的`commit-message`的校验了。

## 规则

git 的`commit-message`由以下四部分组成:

```
![Feat::scope] some sentence
^ ^ ^ ^
| | | |
| | | |
| | | |- Subject(required)
| | |
| | |- Scope(optional)
| |
| |- Type(required)
|
|- Break change symbol(optional)
```

- `Break change symbol`:在提交破坏性更改的时候,需要使用时候用`Break change symbol`。
- `Type`:`commit-message`的`Type`必须是以下类型之一。

| 规范名 | 描述 |
| -------- | ------------------------------------ |
| Feat | 新增新功能 |
| Init | 新建项目时,对项目的初始化 |
| Remove | 小面积的文件删除 |
z825316969 marked this conversation as resolved.
Show resolved Hide resolved
| Delete | 大面积的文件删除 |
| Update | 对原有功能的修改 |
z825316969 marked this conversation as resolved.
Show resolved Hide resolved
| Refactor | 代码重构 |
| Move | 移动文件位置 |
| Perf | 优化相关,比如提升性能、体验 |
| Doc | 修改了文档,比如 README |
z825316969 marked this conversation as resolved.
Show resolved Hide resolved
| Add | 规模较小的新增 |
| Patch | 对公共方法的完善或者优化 |
z825316969 marked this conversation as resolved.
Show resolved Hide resolved
| Fix | 修复 bug |
| Test | 测试用例,包括单元测试、集成测试等 |
z825316969 marked this conversation as resolved.
Show resolved Hide resolved
| Stub | mock 的数据 |
z825316969 marked this conversation as resolved.
Show resolved Hide resolved
| Chore | 改变构建流程、或者增加依赖库、工具等 |
z825316969 marked this conversation as resolved.
Show resolved Hide resolved

- `Scope`: 修改的模块。
- `Subject`: 提交的具体描述信息。

## 覆盖配置

你可以覆盖 `Wizardoc` 的配置,来创建自己的配置

```js
module.exports = {
extends: 'wizardoc',
rules: [
// Set the $ as the third parameter if you wanna change break symbol to $
"break-change-prefix": [2, "always", '$'],
]
}
```

## LICENSE

MIT.
3 changes: 2 additions & 1 deletion packages/commitlint-config-wizardoc/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export enum CommitType {
UPDATE = "Update",
REFACTOR = "Refactor",
MOVE = "Move",
NEW = "New",
ADD = "Add",
PATCH = "Patch",
FIX = "Fix",
TEST = "Test",
STUB = "Stub",
CHORE = "Chore",
PERF = "Perf",
DOC = "Doc",
}

export const CONVERSION_MATCH_REGEX = /^(.?)\[(\w+?)(?:\:\:(\w*))?\]\s(.*)$/;