@github/markdownlint-github

中文文档
0.8.5发布于 2026/10/22ISCES Module构建来源已验证近 30 天下载 6.1万

An opinionated collection of markdownlint rules used by GitHub.

原始使用文档
文档目录8 节
  1. Opinions
  2. Rules
  3. Usage
  4. Customizing configurations
  5. Advanced: Adding custom rules in your codebase
  6. License
  7. Maintainers
  8. Contributing

Markdownlint-github

This repository provides GitHub's recommended markdownlint configurations, and additional rules for use on GitHub open source and internal projects.

Opinions

In addition to defaults defined by markdownlint, we use this repository to enforce rules not defined by default, including our own custom rules.

See opinions codified in index.js.

Rules

The following are custom rules defined in this plugin.

See markdownlint rules for documentation on rules pulled in from markdownlint.

Usage

Important: We support the use of markdownlint through markdownlint-cli2 instead of markdownlint-cli for compatibility with the vscode-markdownlint plugin.

  1. Create a .markdownlint-cli2.mjs file in the root of your repository.

    touch .markdownlint-cli2.mjs
    
  2. Install packages.

    npm install -D markdownlint-cli2 # if updating existing package, check for updates
    npm install -D @github/markdownlint-github [--@github:registry=https://registry.npmjs.org]
    npm install -D markdownlint-cli2-formatter-pretty
    
  3. Add/modify your linting script in package.json.

    "scripts": {
      "lint:markdown": "markdownlint-cli2 \"**/*.{md,mdx}\" \"!node_modules\""
    }
    
  4. Edit .markdownlint-cli2.mjs file to suit your needs. Start with

    import markdownIt from "markdown-it"
    import configOptions, {init} from "@github/markdownlint-github"
    const markdownItFactory = () => markdownIt({ html: true })
    const options = {
        config: init(),
        customRules: ["@github/markdownlint-github"],
        markdownItFactory,
        outputFormatters: [
          [ "markdownlint-cli2-formatter-pretty", { "appendLink": true } ] // ensures the error message includes a link to the rule documentation
        ]
    }
    export default options
    

    Or, you can also pass in configuration options that you wish to override the default. Read more at Customizing configurations. This looks like:

    import markdownIt from "markdown-it"
    import configOptions, {init} from "@github/markdownlint-github"
    const overriddenOptions = init({
        'fenced-code-language': false, // Custom overrides
    })
    const markdownItFactory = () => markdownIt({ html: true })
    const options = {
        config: overriddenOptions,
        customRules: ["@github/markdownlint-github"],
        markdownItFactory,
        outputFormatters: [
          [ "markdownlint-cli2-formatter-pretty", { "appendLink": true } ]
        ]
    }
    export default options
    
  5. Install the vscode-markdownlint plugin to ensure markdownlint violations are surfaced in the file. This plugin should flag rules based off your .markdownlint-cli2.mjs configuration. When you make edits to your configuration, you will need to reload the VSCode window (Ctrl+Shift+P -> Reload Window) to ensure the extension syncs. If your project runs on Codespaces, consider adding this extension to your .devcontainer/devcontainer.json so that this extension is installed to new Codespaces by default.

Customizing configurations

You may determine that the defaults set by this plugin are not suitable for your project.

This plugin will pull in the the defaults defined by markdownlint, several of which pertain to stylistic practices. You may choose to disable these rules if you determine it doesn't provide value for your project.

However, others of these rules should NOT be disabled because they encourage best accessibility practices. Disabling these rules will negatively impact accessibility. These rules are defined in accessibility.json.

To review configurations supported by markdownlint, see markdownlint-cli2 configuration.

Advanced: Adding custom rules in your codebase

You may write custom rules within your repository. Follow the custom rules guide in markdownlint to write your rule.

The rule will need to be enabled in the configuration. For instance, if you introduce some-rule.js with the name "some-rule", you must set the path of the custom rule in the .markdownlint-cli2.mjs file:

import configOptions, {init} from "@github/markdownlint-github"
import markdownIt from "markdown-it"
const markdownItFactory = () => markdownIt({ html: true })
const options = init({
    "some-rule": true,
    customRules: ["@github/markdownlint-github", "some-rule.js"],
    markdownItFactory
})
export default options

See markdownlint-cli2 configuration.

Consider upstreaming any rules you find useful as proposals to this repository.

License

This project is licensed under the terms of the MIT open source license. Please refer to the MIT license for the full terms.

Maintainers

See CODEOWNERS.

Contributing

Please read Contributing Guide for more information.

版本与发布记录

@github/markdownlint-github 共发布 20 个版本,首次发布于 2022/08/10;过去 12 个月发布了 5 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.8.5latest2026/10/2225 天前
0.8.42026/09/231 个月前
0.8.32026/07/034 个月前
0.8.22026/06/254 个月前
0.8.12026/06/045 个月前
0.8.02025/04/241.6 年前

关于 @github/markdownlint-github 的常见问题

@github/markdownlint-github 是什么?

An opinionated collection of markdownlint rules used by GitHub.

如何安装 @github/markdownlint-github?

在项目目录运行 npm install @github/markdownlint-github,或使用 pnpm add / yarn add / bun add。

@github/markdownlint-github 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/github__markdownlint-github 是否存在。

@github/markdownlint-github 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@github/markdownlint-github 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@github/markdownlint-github 可以商用吗?

@github/markdownlint-github 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@github/markdownlint-github 的下载量有多少?

根据 npm 官方下载统计,@github/markdownlint-github 在 2026/10/17 – 2026/11/15 这 30 天内被下载 60,847 次,日均约 2,028 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@github/markdownlint-github 还在维护吗?

最新版本 0.8.5 发布于 2026/10/22(25 天前);至今共发布 20 个版本,其中过去 12 个月发布了 5 个;首次发布于 2022/08/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。