Skip to content

chore: add eslint-plugin-md-style to v4 branch#968

Merged
NoiseFan merged 7 commits into
vitest-dev:v4from
NoiseFan:4.x
Jul 21, 2026
Merged

chore: add eslint-plugin-md-style to v4 branch#968
NoiseFan merged 7 commits into
vitest-dev:v4from
NoiseFan:4.x

Conversation

@NoiseFan

@NoiseFan NoiseFan commented May 4, 2026

Copy link
Copy Markdown
Collaborator

在提交 PR 之前,请确保你执行以下操作:

  • 曾阅读过 翻译须知
  • 检查是否已经有 PR 以同样的方式解决问题,以避免创建重复。
  • 在此 PR 中描述正在解决的问题,或引用它解决的问题(例如:fixes #123)。

描述

添加新 eslint 包

添加 eslint-plugin-md-style 包,适用于 CJK 语言环境的 md 文档格式化。

其意图为:保证书写风格一致、后续无需为风格投入大量精力

初期在 v4 分支上进行测试,稳定之后将在 v1, v2, v3, dev 分支上线,如后续碰到问题可直接联系我~

移除无效文件

  • config/file.md

附加上下文

  1. 添加 valid-heading-anchor 对标题自定义锚点进行校验
  • 发现未添加的自定义 anchor
  • 自动修复 anchor:查找 md 文件内的标题,如果标题是 CJK 且 # 号后面有相关英文将会自动 fix

示例

原始内容:

## Mocking Functions and Objects

添加中文内容,并在 anchor 前添加一个 `#`

## 模拟函数和对象 #Mocking Functions and Objects

修复后结果:

## 模拟函数和对象 {#mocking-functions-and-objects}
  1. 添加 space-around-inline-element 对行内元素前后空格进行校验
  • 自动修复行内元素前后的空格
  • 其规则为:
    • 行内元素前后必须携带一个空格
    • 如果行内元素前后碰到对应标点符号则不需要添加空格
    • 如果以行内元素开头或结尾无需添加空格

示例

In the [Getting Started](/guide/) guide,
在。[入门指南](/guide/) 中,
  1. 添加 space-around-number 对数字前后的空格进行校验
  • 自动修复数字前后缺失或多余的空格
  • 中文、英文与数字之间必须保留一个空格
  • 数字与标点符号相邻时无需添加空格
  • 连续数字、小数、百分比和日期等内容会作为整体处理

示例

自 Vitest 4 起,测试结果有超过 2% 不同。
2025 年 10 月 22 日发布。
  1. 添加 space-around-word 对中英文之间的空格进行校验
  • 自动修复中文与英文单词之间缺失或多余的空格
  • 中文与英文单词之间必须保留一个空格
  • 英文单词与标点符号相邻时无需添加空格
  • Markdown 链接、行内代码、标题锚点和 HTML 标签等内容会根据其语义正确处理

示例

在 watch 模式下,编辑 setup 文件会触发所有测试重新运行。
目前,Vitest 还不支持该功能。

@NoiseFan

NoiseFan commented May 4, 2026

Copy link
Copy Markdown
Collaborator Author

从目前的 diff 中看 lint 之后的结果均符合预期。

@NoiseFan NoiseFan changed the title chore: add eslint-plugin-docs-style to v4 branch chore: add eslint-plugin-md-style to v4 branch May 5, 2026
@NoiseFan
NoiseFan merged commit 30adea9 into vitest-dev:v4 Jul 21, 2026
1 check passed
@NoiseFan
NoiseFan deleted the 4.x branch July 21, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant