Skip to content

Commit af51f90

Browse files
authored
feat: use lint-md 2.0.0 (#18)
* chore: init next version project * feat: parallel runner support (#15) * fix: fix typo * chore: update * chore: update * feat: parallel runner support * chore: remove useless files * chore(release): publish 2.0.0-beta.1 * feat: parallel runner support * feat: multiple thread options support (#16) * feat: test 1 * feat: use better group algorithm for thread starvation * feat: message print support * feat: warning and error print support * feat: fix options support * docs: update examples * test: remove fault unit test temporary * chore(release): publish 2.0.0-beta.4 * fix: fix config path resolve error * fix: fix suppressed rules still print as error * fix: fix path match rules * fix: fix suppress warning error * feat: support default cpu size thread count * chore(release): publish 2.0.0-beta.11 * chore: upgrade package version * fix: fix lint error
1 parent 268de39 commit af51f90

39 files changed

+578
-647
lines changed

.eslintrc.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
module.exports = {
2-
extends: ['plugin:@attachments/eslint-plugin/recommended'],
3-
plugins: ['@attachments/eslint-plugin']
2+
extends: '@attachments/eslint-config',
3+
rules: {
4+
'no-console': 'off',
5+
},
46
};

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ pnpm-lock.yaml
1616
# build files
1717
esm
1818
lib
19+
20+
examples/chinese

.prettierrc.json

-7
This file was deleted.

README.md

+2-133
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,5 @@
11
# @lint-md/cli
22

3-
> 用于检查中文 markdown 编写格式规范的命令行工具,基于 AST 开发,且方便集成 ci;同时提供 API 方法调用。Cli tool to lint your markdown file for Chinese.
3+
Lint Markdown 是检查中文 Markdown 编写格式的工具,让你的文档更加优雅规范。
44

5-
[![npm](https://img.shields.io/npm/v/@lint-md/cli.svg)](https://www.npmjs.com/package/@lint-md/cli)
6-
[![npm](https://img.shields.io/npm/dm/lint-md-cli.svg)](https://www.npmjs.com/package/@lint-md/cli)
7-
8-
## 安装
9-
10-
> **npm i -g @lint-md/cli**
11-
12-
## 使用
13-
14-
```bash
15-
Usage: <lint-md> <files...> [options]
16-
17-
lint your markdown files
18-
19-
Options:
20-
-v, --version output the version number
21-
-c, --config [configure-file] use the configure file, default .lintmdrc
22-
-f, --fix fix the errors automatically
23-
-h, --help output usage information
24-
```
25-
26-
- 校验 lint
27-
28-
```bash
29-
lint-md README.md Document.md
30-
```
31-
32-
- 修复 fix
33-
34-
```bash
35-
lint-md README.md Document.md --fix
36-
```
37-
38-
## 检查类型
39-
40-
基于 [lint-md](https://github.com/hustcc/lint-md/tree/master/packages/lint-md),具体支持的检查类型,请到该项目查看。
41-
42-
## 配置
43-
44-
默认所有的规则都是 `error` 类型,但是可以通过配置来指定规则类型。示例 `.lintmdrc`
45-
46-
```json
47-
{
48-
"excludeFiles": [],
49-
"rules": {
50-
"no-empty-code": 1,
51-
"no-long-code": [
52-
2,
53-
{
54-
"length": 100,
55-
"exclude": [
56-
"dot"
57-
]
58-
}
59-
]
60-
}
61-
}
62-
```
63-
64-
- 通过 rules 来配置规则。参考 [lint-md](https://github.com/hustcc/lint-md/tree/master/packages/lint-md) 文档说明。
65-
- 通过 excludeFiles 来忽略文件和目录,glob 语法。
66-
67-
## ci 集成
68-
69-
- Travis
70-
71-
> `.travis.yml` 文件中配置以下内容。
72-
73-
```yml
74-
language: node_js
75-
node_js:
76-
- "10"
77-
before_install:
78-
- npm i -g @lint-md/cli
79-
script: lint-md README.md
80-
```
81-
82-
- lint-stage
83-
84-
> 在 `package.json` 中增加以下配置。
85-
86-
```json
87-
{
88-
"lint-staged": {
89-
"src/**/*.{md,markdown}": [
90-
"lint-md"
91-
]
92-
}
93-
}
94-
```
95-
96-
## 基于 Docker
97-
98-
假设当前目录有一文件名为 `README.md`,可在本地使用以下命令:
99-
100-
```bash
101-
docker run --rm -it -v$(pwd):/docs yuque/lint-md:cli /docs/README.md # 也可直接带其它参数
102-
```
103-
104-
其中:
105-
106-
- `--rm` 表示在运行完毕后直接销毁容器。
107-
- `-it` 表示交互式 TTY,你可以理解为进入容器终端。
108-
- `-v$(pwd)/docs` 表示将当前目录「挂载」至容器内部的 `/docs` 目录。
109-
110-
另外,在基于 Docker 的 CI/CD 平台上,也可使用 `yuque/lint-md` 镜像。例如 GitLab CI/CD:
111-
112-
```yml
113-
lint:
114-
image: yuque/lint-md:cli
115-
script:
116-
- lint-md README.md # 或其它文件
117-
```
118-
119-
Circle CI:
120-
121-
```yml
122-
version: 2
123-
jobs:
124-
lint:
125-
docker:
126-
- image: yuque/lint-md:cli
127-
steps:
128-
- checkout
129-
- run: lint-md README.md # 或其它文件
130-
```
131-
132-
利用 Docker 作为 CI 的基础环境通常更有优势,不必每次构建都执行 `yarn install`;资源节省,速度也会更快些。
133-
134-
## License
135-
136-
MIT@[hustcc](https://github.com/hustcc).
5+
请参阅 [Lint Markdown 主仓库文档](https://github.com/lint-md/lint-md#%E4%BD%BF%E7%94%A8%E5%91%BD%E4%BB%A4%E8%A1%8Ccli)

__tests__/cli.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ describe('cli tests', () => {
88

99
test('if user does not pass any argument, we show show helps', () => {
1010
const helpMock = jest.fn();
11-
// @ts-ignore
12-
// eslint-disable-next-line no-import-assign
11+
// @ts-expect-error
1312
program.help = helpMock;
1413
require('../src/lint-md');
1514
expect(helpMock).toBeCalled();

__tests__/fix.spec.ts

-43
This file was deleted.

__tests__/lint.spec.ts

-58
This file was deleted.

examples/.lintmdrc

-6
This file was deleted.

examples/.lintmdrc.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"excludeFiles": [],
3+
"rules": {
4+
"no-empty-list": 1,
5+
"no-long-code": [
6+
2,
7+
{
8+
"length": 100,
9+
"exclude": ["dot"]
10+
}
11+
]
12+
}
13+
}

examples/no-empty-blockquote.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- right
1+
- right
22

33
> hello world!
44

examples/no-empty-code.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
- code
1+
- code
22

33
```js
44
```
5-
6-
- inline code
7-
8-
``

examples/no-empty-delete.md

-1
This file was deleted.

examples/no-empty-inline-code.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- inline code
2+
3+
` `

examples/no-fullwidth-number.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
33
> 这件蛋糕只卖 1000 元。
44
5-
> 这件蛋糕只卖 1000 元,要不要试试看呢。
5+
> 这件蛋糕只卖 1000 元,要不要试试看呢。
+2-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
- right
1+
> hello world!
22
3-
> hello world!
4-
5-
- wrong
6-
7-
> hello world!
3+
> hello world!333

examples/no-space-in-emphasis.md

-3
This file was deleted.

examples/no-space-in-inlinecode.md renamed to examples/no-space-in-inline-code.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- success
1+
- success
22

33
hello `world`.
44

examples/no-space-in-link.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[hello world](https://atool.vip)
22

33

4-
[ hello, ~~world~~ ](https://atool.vip)
4+
[ hello, ~~world~~ ](https://atool.vip)
File renamed without changes.

0 commit comments

Comments
 (0)