Skip to content

Commit

Permalink
docs: translate
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyunhe committed Feb 11, 2024
1 parent 27b6ce8 commit 2bb3bdd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 36 deletions.
38 changes: 17 additions & 21 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,27 @@ Run `npx f2elint` (if you use pnpm, run `pnpx f2elint`) in project root, and fol

![screenshot](https://github.com/alibaba/f2e-spec/assets/5836790/80b5c4fd-6ab1-4423-8ae5-0572777db0a7)

## 单条规约格式说明
## Specification format

### 规约级别和对应的 Lint 规则
### Specification level and lint rules

根据约束力强弱,一条规约依次分为强制、推荐、参考三个级别:
According to the strength of the strictness, specification rules are classified into three levels:

- 【强制】必须遵守。是不得不遵守的约定,违反本约定或将会引起严重的后果。如有对应 Lint 规则,配套规则包中级别为 `error`
- 【推荐】尽量遵守。长期遵守这样的规定,有助于系统稳定性和合作效率的提升。如有对应 Lint 规则,配套规则包中级别为 `warn`
- 【参考】充分理解。技术意识的引导,是个人学习、团队沟通、项目合作的方向。如有对应 Lint 规则,配套规则包中默认不开启,开发者可根据需要自行开启。
- `mandatory`: must follow. Breaking the rule can cause serious defects. And the rule itself doesn't
cause any defects (false positive, etc.). Lint tool severity is `error`.
- `recommended`: follow whenever possible. Breaking the rule can affect code quality but not serious.
Or the rule itself may cause defects (false positive, etc.). Lint tool severity is `warn`.
- `referenced`: understand and keep in mind. Breaking the rule is not always bad. Lint tools is not
smart enough to evaludate your code. Developers need to make decision on their own. Lint tool
severity is `off` or not supportted.

一条规约的级别会在规约描述的开头标注,如有对应的 Lint 规则会在结尾标注,例如:
Rule strictness level is marked at the beginning, while lint tool rule, if exists, is marked at the end.

- 1.1.1【强制】使用 2 个空格缩进。eslint: [indent](https://eslint.org/docs/rules/indent)
> 1.1.1 `mandatory` Use 2 space indent eslint: [indent](https://eslint.org/docs/rules/indent)
### 代码示例
### Code example

为了更加直观,规约描述之后通常会配上代码示例,例如:
To make it more intuitive, the specification description is usually followed by code examples. For example:

```js
// bad
Expand All @@ -68,17 +72,9 @@ function foo() {
}
```

我们约定用 `bad` 注释表示反例,用 `good` 注释表示正例。

除了 `bad``good`,有时你还会看到 `disallowed``allowed``best` 这几种注释,它们的含义如下:

```js
// disallowed - 禁止(用于部分明令禁止的用法)
// bad - 反例
// allowed - 中例(用于允许但不推荐的用法)
// good - 正例
// best - 最佳正例(多个正例中最好的实现)
```
1. `bad` for NOT recommended practice
2. `good` for recommended practice
3. spaces may be replaced with `` to make it easier to count

## How to participate

Expand Down
22 changes: 7 additions & 15 deletions docs/README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@

根据约束力强弱,一条规约依次分为强制、推荐、参考三个级别:

- 【强制】必须遵守。是不得不遵守的约定,违反本约定或将会引起严重的后果。如有对应 Lint 规则,配套规则包中级别为 `error`
- 【推荐】尽量遵守。长期遵守这样的规定,有助于系统稳定性和合作效率的提升。如有对应 Lint 规则,配套规则包中级别为 `warn`
- 【参考】充分理解。技术意识的引导,是个人学习、团队沟通、项目合作的方向。如有对应 Lint 规则,配套规则包中默认不开启,开发者可根据需要自行开启
- `强制`: 必须遵守。是不得不遵守的约定,违反本约定或将会引起严重的后果。如有对应 Lint 规则,配套规则包中级别为 `error`
- `推荐`: 尽量遵守。长期遵守这样的规定,有助于系统稳定性和合作效率的提升。如有对应 Lint 规则,配套规则包中级别为 `warn`
- `参考`: 充分理解。技术意识的引导,是个人学习、团队沟通、项目合作的方向。如有对应 Lint 规则,配套规则包中默认为 `off` 或不支持

一条规约的级别会在规约描述的开头标注,如有对应的 Lint 规则会在结尾标注,例如:

- 1.1.1【强制】使用 2 个空格缩进。eslint: [indent](https://eslint.org/docs/rules/indent)
> 1.1.1【强制】使用 2 个空格缩进。eslint: [indent](https://eslint.org/docs/rules/indent)
### 代码示例

Expand All @@ -65,17 +65,9 @@ function foo() {
}
```

我们约定用 `bad` 注释表示反例,用 `good` 注释表示正例。

除了 `bad``good`,有时你还会看到 `disallowed``allowed``best` 这几种注释,它们的含义如下:

```js
// disallowed - 禁止(用于部分明令禁止的用法)
// bad - 反例
// allowed - 中例(用于允许但不推荐的用法)
// good - 正例
// best - 最佳正例(多个正例中最好的实现)
```
1. `bad` 表示**不推荐**的用法
2. `good` 表示**推荐**的用法
3. 空格有时候会被 `` 替代以方便计数

## 如何参与

Expand Down

0 comments on commit 2bb3bdd

Please sign in to comment.