Skip to content

Commit

Permalink
docs: ignore directives for no-fallthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
kecrily committed Feb 19, 2023
1 parent cfe2fb9 commit 35cc72f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/rules/no-fallthrough.md
Expand Up @@ -5,7 +5,7 @@ related_rules:
- default-case
---

JavaScript 中的 `switch` 语句是该语言中最容易出错的结构之一,部分原因是它能够从一个 `case` “滑”到下一个。比如:
JavaScript 中的 `switch` 语句是该语言中最容易出错的结构之一,部分原因是它能够从一个 `case` 下沉到下一个。比如:

```js
switch(foo) {
Expand All @@ -30,7 +30,7 @@ switch(foo) {
}
```

当你不想要突破的时候,这样做很好,但是如果突破是故意的呢,在语言中没有办法表明这一点。最好的做法是使用与 `/falls?\s?through/i` 正则表达式相匹配的注释来表明突破是故意的
当你不想要下沉的时候,这样做没问题,但是如果是故意要下沉的呢,在语言中没有办法表明这一点。最好的做法是使用与 `/falls?\s?through/i` 正则表达式相匹配但非指令的注释来表明是故意要下沉的

```js
switch(foo) {
Expand Down Expand Up @@ -76,7 +76,7 @@ switch(foo) {

## 规则细节

这条规则的目的是为了消除无意中从一个子句突破到另一个子句。因此,它标记了任何没有被注释标记的突破情况。
这条规则的目的是为了消除无意中从一个子句到另一个子句。因此,它标记了任何没有被注释标记的突破情况。

使用此规则的**错误**示例:

Expand Down Expand Up @@ -165,11 +165,11 @@ switch(foo) {

## 选项

这个规则有一个对象选项。
此规则有一个对象选项:

*`commentPattern` 选项设置为正则表达式字符串,以改变对故意落空的注释的测试
*`commentPattern` 选项设置为正则表达式字符串,以改变对故意下沉的注释的测试。如果下沉注释与指令相匹配,则优先于 `commentPattern`

*`allowEmptyCase` 选项设置为 `true`,以允许空的情况,而不管布局如何。默认情况下,只有当空的 `case` 和下一个 `case` 在同一行或连续的行上时,该规则才不要求在空的 `case` 后有落空的注释
*`allowEmptyCase` 选项设置为 `true`,以允许空的情况,而不管布局如何。默认情况下,只有当空的 `case` 和下一个 `case` 在同一行或连续的行上时,该规则才不要求在空的 `case` 后有下沉的注释

### commentPattern

Expand Down

0 comments on commit 35cc72f

Please sign in to comment.