Skip to content

Commit

Permalink
feat: sync v8.48.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kecrily committed Jan 25, 2024
1 parent 145194e commit f714c2b
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -2,7 +2,7 @@

> Simplified Chinese website
The synchronization frequency is the same as the ESLint release frequency (the last sync was [v8.47.0](https://github.com/eslint/eslint/tree/v8.47.0))
The synchronization frequency is the same as the ESLint release frequency (the last sync was [v8.48.0](https://github.com/eslint/eslint/tree/v8.48.0))

## Contribute

Expand Down
2 changes: 1 addition & 1 deletion src/contribute/core-rules.md
Expand Up @@ -4,7 +4,7 @@ eleventyNavigation:
key: contribute core rule
parent: contribute to eslint
title: 贡献核心规则
order: 10
order: 11
---

ESLint 核心规则是指那些包括在 ESLint 包里的规则。
Expand Down
2 changes: 1 addition & 1 deletion src/contribute/governance.md
Expand Up @@ -4,7 +4,7 @@ eleventyNavigation:
key: governance
parent: contribute to eslint
title: 治理
order: 11
order: 12
---

ESLint 是一个依赖于社区贡献者的开源项目。每个人都可以随时提交代码、参与讨论、提交建议或其他合适的贡献。本文档讲述了 ESLint 项目中几种类型的贡献者。
Expand Down
14 changes: 12 additions & 2 deletions src/contribute/package-json-conventions.md
@@ -1,6 +1,10 @@
---
title: Package.json 约定
edit_link: https://github.com/eslint/eslint/edit/main/docs/src/contribute/package-json-conventions.md
eleventyNavigation:
key: package.json conventions
parent: contribute to eslint
title: Package.json Conventions
order: 8
---

以下内容适用于 `package.json` 文件中的 `scripts` 部分。
Expand All @@ -14,7 +18,7 @@ npm 脚本名称必须仅包含小写字母,使用 `:` 分隔部分,使用 `
```abnf
name = life-cycle / main target? option* ":watch"?
life-cycle = "prepare" / "preinstall" / "install" / "postinstall" / "prepublish" / "preprepare" / "prepare" / "postprepare" / "prepack" / "postpack" / "prepublishOnly"
main = "build" / "lint" ":fix"? / "release" / "start" / "test"
main = "build" / "lint" ":fix"? / "release" / "start" / "test" / "fetch"
target = ":" word ("-" word)* / extension ("+" extension)*
option = ":" word ("-" word)*
word = ALPHA +
Expand All @@ -35,6 +39,12 @@ extension = ( ALPHA / DIGIT )+

如果一个包包含任何 `build:*` 脚本,那么可能会有一个名为 `build` 的脚本。如果有,它应该生成与单独运行每个 `build` 脚本相同的输出。它必须生成从运行这些脚本中的每一个脚本生成的输出的子集。

### Fetch

生成数据或资源来自外部文件的脚本,必须以 `fetch` 开头命名。

如果一个包含任何 `fetch:*` 脚本,可能会有一个名为 `fetch` 的脚本。如果有的话,它应该产生与单独运行每个 `fetch` 脚本相同的输出。它必须产生运行这些脚本时输出的一个子集。

### Release

具有公共副作用(发布网站、提交到 Git 等)的脚本名称必须以 `release` 开头。
Expand Down
2 changes: 1 addition & 1 deletion src/contribute/pull-requests.md
Expand Up @@ -4,7 +4,7 @@ eleventyNavigation:
key: submit pull request
parent: contribute to eslint
title: 提交拉取请求
order: 9
order: 10
---

如果你想为 ESLint 仓库做贡献,请使用 GitHub pull request。这是我们评估你的代码并将其合并到代码库的最快方式。请不要用代码片断来提交问题。这样做意味着我们需要手动合并这些变化,并更新任何适当的测试。这降低了你的代码被及时纳入的可能性。请使用拉取请求。
Expand Down
2 changes: 1 addition & 1 deletion src/contribute/report-security-vulnerability.md
Expand Up @@ -4,7 +4,7 @@ eleventyNavigation:
key: report security vulnerability
parent: contribute to eslint
title: 报告安全漏洞
order: 11
order: 13
---

要报告 ESLint 中的安全漏洞,请使用我们在 GitHub 的[创建建议表单](https://github.com/eslint/eslint/security/advisories/new)
2 changes: 1 addition & 1 deletion src/contribute/work-on-issue.md
Expand Up @@ -4,7 +4,7 @@ eleventyNavigation:
key: work on issues
parent: contribute to eslint
title: 处理议题
order: 8
order: 9
---

我们公开的[议题追踪器](https://github.com/eslint/eslint/issues)列出了所有我们计划去做的事,以及来自社区的建议。在开始着手处理议题前,请确保读完本页面的其余部分。
Expand Down
14 changes: 13 additions & 1 deletion src/rules/for-direction.md
Expand Up @@ -3,9 +3,11 @@ title: for-direction
rule_type: problem
---

一个包含永远无法达到的停止条件的 `for` 循环,将会一直运行,比如一个计数器朝着错误的方向变化。虽然有时会有意使用无限循环,但惯例是构建这样的循环时使用 `while` 循环。大多情况下一直运行的 `for` 循环通常其实是一个错误。

## 规则细节

一个有停止条件的 `for` 循环永远不会达到,比如一个向错误方向移动的计数器,将无限地运行。虽然在某些情况下会出现无限循环,但惯例是将这种循环构造为 `while` 循环。更典型的是,无限 for 循环是一个错误
该规则禁止使用计数变量的变化导致停止条件永远不会满足的 `for` 循环。例如,如果计数变量是递增的(即 `i++`),并且停止条件测试计数器是否大于零(`i >= 0`),那么循环将永远不会退出

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

Expand All @@ -21,6 +23,10 @@ for (var i = 10; i >= 0; i++) {

for (var i = 0; i > 10; i++) {
}

const n = -2;
for (let i = 0; i < 10; i += n) {
}
```

:::
Expand All @@ -33,6 +39,12 @@ for (var i = 0; i > 10; i++) {
/*eslint for-direction: "error"*/
for (var i = 0; i < 10; i++) {
}

for (let i = 10; i >= 0; i += this.step) { // direction unknown
}

for (let i = MIN; i <= MAX; i -= 0) { // not increasing or decreasing
}
```

:::

0 comments on commit f714c2b

Please sign in to comment.