From f5c5e524a40ba4b4134571e9da907ef36a695a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B9=A4=E4=BB=99?= Date: Mon, 12 Feb 2024 11:16:08 +0800 Subject: [PATCH] docs: translate --- docs/coding/common.md | 30 +++++++++++++++++++++++------- docs/coding/common.zh.md | 30 +++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/docs/coding/common.md b/docs/coding/common.md index bcfb712..ea80fa8 100644 --- a/docs/coding/common.md +++ b/docs/coding/common.md @@ -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 + + +∙∙∙∙ +∙∙∙∙∙∙∙∙ +∙∙∙∙ + + + + +∙∙ +∙∙∙∙ +∙∙ + ``` The decision is made based on the following reasons: @@ -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. diff --git a/docs/coding/common.zh.md b/docs/coding/common.zh.md index 4071841..2580d44 100644 --- a/docs/coding/common.zh.md +++ b/docs/coding/common.zh.md @@ -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 + + +∙∙∙∙ +∙∙∙∙∙∙∙∙ +∙∙∙∙ + + + + +∙∙ +∙∙∙∙ +∙∙ + ``` 之所以选择两个空格,是有以下考虑: @@ -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 字符。