用于检查中文 markdown 编写格式规范的命令行工具,基于 AST 开发,且方便集成 ci。Cli tool to lint your markdown file for Chinese.
npm i -g lint-md
Usage:[options] lint your markdown files Options: -v, --version output the version number -c, --config [configure-file] use the configure file, default .lintmdrc -h, --help output usage information
Example:
lint-md README.md Document.md
检查规则来源于 chinese-document-style-guide.
目前仅仅检查了比较通用的类型, 欢迎 pull request ,在 rules 中增加自己的规则,开发约束:
rules
规则主要针对于中文 markdown 的编写规范
使用类 babel plugin 的方式来进行规则检查,一个插件对应一个规则
规则名称对应和插件文件名保持一致
先提 issue 进行讨论
AST 工具,使用其中的 markdown AST 辅助开发插件
默认所有的规则都是 error 类型,但是可以通过配置来指定规则类型。示例 .lintmdrc :
error
.lintmdrc
{ "excludeFiles": [], "rules": { "no-empty-code": 1 } }
通过 rules 来配置规则的等级。
0 :ignore 忽略不检查该规则
1 :warning 警告,但不阻断 ci
2 :error 错误,且阻断 ci
通过 excludeFiles 来忽略文件和目录,glob 语法。
在 .travis.yml 文件中配置以下内容。
.travis.yml
language: node_js node_js: - "10" before_install: - npm i -g lint-md script: lint-md README.md
在 package.json 中增加以下配置。
package.json
"lint-staged": { "src/**/*.{md,markdown}": [ "lind-md" ] }
MIT@hustcc.