# @github/markdownlint-github 中文文档

规范地址：https://npmcn.com/package/%40github/markdownlint-github/

版本：0\.8\.5
npm 元数据更新时间：2026-10-21T21:32:12.721Z
中文译文更新时间：2026-11-16T10:59:55.025Z
软件包许可：ISC

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40github/markdownlint-github
原文对照：https://npmcn.com/package/%40github/markdownlint-github/?lang=original
项目主页：https://github.com/github/markdownlint-github#readme
源码仓库：https://github.com/github/markdownlint-github

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：44.6 kB，37 个文件
- 模块格式：ES Module
- TypeScript 类型：未声明
- Node.js 要求：^18\.14\.0 \|\| ^20\.0\.0 \|\| ^22\.0\.0 \|\| \>=24\.0\.0
- 运行依赖：2 个
- 首次发布：2022-08-10T11:46:46.032Z
- 最新版本发布：2026-10-21T21:32:12.338Z
- 近 30 天下载量：60847（2026-10-17 至 2026-11-15，npm 官方下载统计）
- 已发布版本数：20（近 12 个月 5 个）

## 中文简介

GitHub使用的马克德林特规则评论集.

## 安装

```sh
npm install @github/markdownlint-github
```

也可以使用：`pnpm add @github/markdownlint-github`、`yarn add @github/markdownlint-github`、`bun add @github/markdownlint-github`

## README

# 马克德林特-吉图布

这个寄存器提供了 GitHub 的推荐 [`markdownlint`](https://github.com/DavidAnson/markdownlint) 配置,以及用于GitHub开源和内部项目的附加规则.

## 意见

除以 `markdownlint`,我们使用这个寄存器来强制实施未默认定义的规则,包括我们自己的自定义规则.

见编纂的意见 [指数.js](https://npmcn.com/package/%40github/markdownlint-github/index.js)。 。 。 .

## 规则

以下是此插件中定义的自定义规则 .

-   [**GH001 号** _无默认文本_](https://npmcn.com/package/%40github/markdownlint-github/docs/rules/GH001-no-default-alt-text.md)
-   [**千兆赫002** _无常规链接文本_](https://npmcn.com/package/%40github/markdownlint-github/docs/rules/GH002-no-generic-link-text.md)
-   [**千兆赫003** _无空格_](https://npmcn.com/package/%40github/markdownlint-github/docs/rules/GH003-no-empty-alt-text.md)

见 [`markdownlint` 规则](https://github.com/DavidAnson/markdownlint#rules--aliases) 关于规则的文件 `markdownlint`。 。 。 .

## 使用量

**重要**:我们支持使用 `markdownlint` 结束 [`markdownlint-cli2`](https://github.com/DavidAnson/markdownlint-cli2) 改为 `markdownlint-cli` 的兼容性 [`vscode-markdownlint`](https://github.com/DavidAnson/vscode-markdownlint) 插件 .

1.  创建一个 `.markdownlint-cli2.mjs` 中的文件.
    
    ```bash
    touch .markdownlint-cli2.mjs
    ```
    
2.  安装软件包 .
    
    ```bash
    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.  添加/ 修改您的嵌入脚本 `package.json`。 。 。 .
    
    ```json
    "scripts": {
      "lint:markdown": "markdownlint-cli2 \"**/*.{md,mdx}\" \"!node_modules\""
    }
    ```
    
4.  编辑 `.markdownlint-cli2.mjs` 以适应您的需要。 开始
    
    ```js
    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
    ```
    
    或者,您也可以通过您想要覆盖默认的配置选项。 更多信息 [自定义配置](https://npmcn.com/package/%40github/markdownlint-github/#readme-customizing-configurations)。 。 。 . 这看起来像:
    
    ```js
    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.  安装 [`vscode-markdownlint`](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint) 确保的插件 `markdownlint` 违反情况在档案中出现。 此插件应该基于您的规则 `.markdownlint-cli2.mjs` 配置 。 当编辑到您的配置时, 您需要重新装入 VSCode 窗口(`Ctrl+Shift+P` - > (中文) `Reload Window`),以确保扩展同步. 如果您的工程运行在代码空间上, 请考虑在您的 `.devcontainer/devcontainer.json` 这样,这个扩展默认会安装到新的代码空间.
    

### 自定义配置

您可以确定此插件设置的默认不适合您的工程 .

此插件将在定义的默认值中拉动 `markdownlint`,其中几个与形式做法有关。 如果您确定这些规则不能为您的工程提供价值, 您可以选择禁用这些规则 .

但是,这些规则的其他条款应当 **没有** 残疾,因为它们鼓励最佳无障碍做法。 使这些规则失效将对无障碍环境产生不利影响。 这些规则的定义载于 [无障碍](https://npmcn.com/package/%40github/markdownlint-github/style/accessibility.json)。 。 。 .

审查由 `markdownlint`,参见 [`markdownlint-cli2` 配置](https://github.com/DavidAnson/markdownlint-cli2#configuration)。 。 。 .

### 高级: 在代码库中添加自定义规则

您可以在您的仓库里写自定义规则 。 跟着 [自定义规则指南 `markdownlint`](https://github.com/DavidAnson/markdownlint/blob/main/doc/CustomRules.md) 写你的规则.

在配置中需要启用规则 。 例如,如果你介绍 `some-rule.js` 名称“ some- rule ” , 您必须在 `.markdownlint-cli2.mjs` 文件 :

```js
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
```

见 [`markdownlint-cli2` 配置](https://github.com/DavidAnson/markdownlint-cli2#configuration)。 。 。 .

考虑将您认为有用的任何规则上游化, 作为向此存储库提出的建议 .

## 许可证

这个项目根据麻省理工学院开源许可证的规定获得许可. 请 参考 [麻省理工学院执照](https://npmcn.com/package/%40github/markdownlint-github/LICENSE.txt) 全部条件.

## 维护者

见 [消费者](https://npmcn.com/package/%40github/markdownlint-github/CODEOWNERS)。 。 。 .

## 捐款

请阅读 [贡献指南](https://npmcn.com/package/%40github/markdownlint-github/CONTRIBUTING.md) 更多信息.

## 常见问题

### @github/markdownlint-github 是什么？

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 和提交记录判断。

