Skip to content

Commit

Permalink
docs: use inline code for rule options name
Browse files Browse the repository at this point in the history
  • Loading branch information
kecrily committed Feb 19, 2023
1 parent e85e58d commit cfe2fb9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/rules/class-methods-use-this.md
Expand Up @@ -117,9 +117,9 @@ class A {
"class-methods-use-this": [<enabled>, { "exceptMethods": [<...exceptions>] }]
```

`exceptMethods` 选项允许你传递一个数组的方法名称,你希望忽略这些方法的警告。例如,你可能有一个来自外部库的规范,要求你把一个方法作为普通函数(而不是静态方法)覆盖,并且在函数体中不使用 `this`。在这种情况下,你可以在警告中添加该方法来忽略。
`"exceptMethods"` 选项允许传递包含你想要忽略警告的方法名的数组。例如,你可能有一个来自外部库的规范,要求你将方法作为普通函数(而不是静态方法)覆盖,并且在函数体中不能使用 `this`。在这种情况下,你可以在警告中添加该方法来忽略。

使用此规则不使用 `exceptMethods`**错误**示例:
使用此规则不使用 `"exceptMethods"` **错误**示例:

::: incorrect

Expand Down
4 changes: 2 additions & 2 deletions src/rules/eqeqeq.md
Expand Up @@ -40,7 +40,7 @@ if (obj.getStuff() != undefined) { }

### always

默认的 `"always"` 选项强制在任何情况下使用 `===``!==`(除非你选择了对 `null` 的更具体处理[见下文])。
默认的 `"always"` 选项强制在任何情况下使用 `===``!==`(除非你选择了对 `null` 的更具体处理见下文)。

使用 `"always"` 选项的**错误**示例:

Expand Down Expand Up @@ -137,7 +137,7 @@ foo == null

### allow-null

**废弃**:使用 `"always"` 代替这个选项,并传递一个 `"null"` 选项属性,值为 `"ignore"`。这将告诉 ESLint,除了与 `null` 字面量比较时,总是执行严格的相等判断
**废弃**:使用 `"always"` 代替这个选项,并传递值为 `"ignore"` `"null"` 选项属性。这将告诉 ESLint,除与 `null` 字面量比较外,其他时候总是执行严格的相等判断

```js
["error", "always", {"null": "ignore"}]
Expand Down
4 changes: 2 additions & 2 deletions src/rules/func-name-matching.md
Expand Up @@ -144,7 +144,7 @@ module['exports'] = function foo(name) {};

## 选项

这个规则需要一个 `always``never` 的可选字符串(当省略时,默认为 `always`),以及一个带有两个属性 `considerPropertyDescriptor``includeCommonJSModuleExports` 的可选选项对象。
这个规则需要一个 `"always"``"never"` 的可选字符串(当省略时,默认为 `"always"`),以及包括两个属性 `considerPropertyDescriptor``includeCommonJSModuleExports` 的可选选项对象。

### considerPropertyDescriptor

Expand Down Expand Up @@ -184,7 +184,7 @@ Reflect.defineProperty(obj, 'foo', {value: function value() {}});

### includeCommonJSModuleExports

布尔值,默认为 `false`。如果 `includeCommonJSModuleExports` 被设置为 true,此规则将检查 `module.exports``module["exports"]`
布尔值,默认为 `false`。如果 `includeCommonJSModuleExports` 设置为 `true`,此规则将检查 `module.exports``module["exports"]`

使用 `{ includeCommonJSModuleExports: true }` 选项的**错误**示例:

Expand Down
12 changes: 6 additions & 6 deletions src/rules/generator-star-spacing.md
Expand Up @@ -49,14 +49,14 @@ function * generator() {

## 选项

规则需要一个选项,一个对象,它有两个键 `before``after`,可以是布尔值 `true``false`
规则需要一个选项,一个对象,它有两个键 `"before"``"after"`,可以是布尔值 `true``false`

* `before``*``function` 关键词之间强制执行间隔。
* `"before"``*``function` 关键词之间强制执行间隔。
如果它是 `true`,则需要一个空格,否则不允许有空格。

在对象字面量速记方法中,不检查`*` 之前的间隔,因为它们缺少 `function` 关键字。

* `after` 强制要求在 `*` 和函数名(或匿名生成器函数的开头括号)之间有间距。
* `"after"` 强制要求在 `*` 和函数名(或匿名生成器函数的开头括号)之间有间距。
如果它是 `true`,则需要一个空格,否则不允许有空格。

默认值是 `{"before": true, "after": false}`
Expand All @@ -74,7 +74,7 @@ function * generator() {
* `{"before": true, "after": true}``"both"`
* `{"before": false, "after": false}``"neither"`

速记配置实力
速记配置示例

```json
"generator-star-spacing": ["error", "after"]
Expand All @@ -97,8 +97,8 @@ function * generator() {
}]
```

在上面的配置示例中,顶层的 `before``after` 选项定义了规则的默认行为。规则,而 `anonymous``method` 选项则覆盖了默认行为。
覆盖可以是一个带有 `before``after`的对象,也可以是上述的速记字符串。
在上面的配置示例中,顶层的 `"before"``"after"` 选项定义了规则的默认行为。规则,而 `anonymous``method` 选项则覆盖了默认行为。
覆盖可以是一个带有 `"before"``"after"`的对象,也可以是上述的速记字符串。

## 示例

Expand Down

0 comments on commit cfe2fb9

Please sign in to comment.