Skip to content

Commit 178b852

Browse files
committed
docs(space-around-number): supplement rule document
1 parent 4e1d17d commit 178b852

3 files changed

Lines changed: 82 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ export default antfu(
121121
| Rule | Included in `recommended` | Autofix |
122122
| --- | --- | --- |
123123
| `md-style/space-around-inline-element` || 🔧 |
124+
| `md-style/space-around-number` | | 🔧 |
125+
| `md-style/space-around-word` | | 🔧 |
124126
| `md-style/valid-heading-anchor` || 🔧 |
125127

126128
## Why `@eslint/markdown` Is Required
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Space Around Number
2+
3+
Keep spacing between CJK characters and numbers consistent.
4+
5+
This rule focuses on number-boundary spacing in mixed CJK and technical writing. It prevents CJK characters and numbers from being written directly next to each other, and also removes extra spaces around them.
6+
7+
## Rule Details
8+
9+
By default, this rule requires:
10+
11+
- Exactly one space between a CJK character and an adjacent number
12+
- Multiple consecutive spaces around numbers to be automatically collapsed into one space
13+
- No extra spacing requirement when a number is adjacent to punctuation
14+
- Mixed English-and-number spacing is outside the scope of this rule and must be handled separately
15+
16+
Examples of **correct** code for this rule:
17+
18+
```md
19+
支持 123 个规则
20+
提升 4.0% 效率
21+
版本:2.0,现已发布。
22+
```
23+
24+
Examples of **incorrect** code for this rule:
25+
26+
```md
27+
支持123 个规则
28+
支持 123个规则
29+
支持123个规则
30+
提升4.0%效率
31+
支持 123 个规则
32+
支持 123 个规则
33+
支持 123 个规则
34+
```
35+
36+
This rule is autofixable.
37+
38+
## When Not To Use It
39+
40+
If your project does not want to enforce spacing between CJK characters and numbers, or if this is already handled entirely by another formatter, you can turn this rule off.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Space Around Number
2+
3+
保持 CJK 字符与数字之间的空格风格一致。
4+
5+
这条规则主要用于处理中英文混排的数字边界空格问题,避免中文和数字直接粘连,也会清理两侧多余的连续空格。
6+
7+
## 规则详情
8+
9+
默认情况下,这条规则要求:
10+
11+
- CJK 字符与相邻数字之间保留一个空格
12+
- 如果数字两侧已经存在多个连续空格,会自动压缩为一个空格
13+
- 如果数字与标点相邻,则不强制要求额外空格
14+
- 英文与数字之间的混排空格不在这条规则的处理范围内,需要自行处理
15+
16+
该规则的**正确**示例:
17+
18+
```md
19+
支持 123 个规则
20+
提升 4.0% 效率
21+
版本:2.0,现已发布。
22+
```
23+
24+
该规则的**错误**示例:
25+
26+
```md
27+
支持123 个规则
28+
支持 123个规则
29+
支持123个规则
30+
提升4.0%效率
31+
支持 123 个规则
32+
支持 123 个规则
33+
支持 123 个规则
34+
```
35+
36+
该规则支持自动修复。
37+
38+
## 不适用场景
39+
40+
如果你的项目不希望统一中文与数字之间的空格风格,或者这类问题已经完全交给其他格式化工具处理,可以关闭这条规则。

0 commit comments

Comments
 (0)