Skip to content

Commit

Permalink
docs: translate
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyunhe committed Feb 12, 2024
1 parent 57bd695 commit f5c5e52
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 14 deletions.
30 changes: 23 additions & 7 deletions docs/coding/common.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ order: 0
Common guidelines that apply to various programming languages. Linting tools like
[EditorConfig](https://editorconfig.org/) and [Prettier](https://prettier.io/) can be used.

## Indention

2 spaces.

```ini filename=".editorconfig"
indent_style = space
indent_size = 2
## `mandatory` Use 2 space indent

```html
<!-- bad -->
<html>
∙∙∙∙<head>
∙∙∙∙∙∙∙∙<title></title>
∙∙∙∙</head>
</html>

<!-- good -->
<html>
∙∙<head>
∙∙∙∙<title></title>
∙∙</head>
</html>
```

The decision is made based on the following reasons:
Expand All @@ -24,6 +33,13 @@ The decision is made based on the following reasons:
3. 2 spaces saves more spaces than 3 or 4 spaces, espacially for `html` and `jsx` syntax which can
have very deep nesting structure.

EditorConfig:

```ini filename=".editorconfig"
indent_style = space
indent_size = 2
```

## Max line length

100 chars.
Expand Down
30 changes: 23 additions & 7 deletions docs/coding/common.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ order: 0

适用于多种编程语言的编码规约。对应的规约工具主要是 [EditorConfig](https://editorconfig.org/)[Prettier](https://prettier.io/)

## 缩进

两个空格。

```ini filename=".editorconfig"
indent_style = space
indent_size = 2
## `强制` 使用 2 个空格缩进

```html
<!-- bad -->
<html>
∙∙∙∙<head>
∙∙∙∙∙∙∙∙<title></title>
∙∙∙∙</head>
</html>

<!-- good -->
<html>
∙∙<head>
∙∙∙∙<title></title>
∙∙</head>
</html>
```

之所以选择两个空格,是有以下考虑:
Expand All @@ -22,6 +31,13 @@ indent_size = 2
2. 2 个空格相比 1 个空格更加明显。
3. 2 个空格相比 3 个空格或 4 个空格更节约空间,适合 `html``jsx` 等层级较深的语法。

EditorConfig 配置:

```ini filename=".editorconfig"
indent_style = space
indent_size = 2
```

## 行宽

100 字符。
Expand Down

0 comments on commit f5c5e52

Please sign in to comment.