You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -32,7 +32,7 @@ Inspired from [clean-code-javascript](https://github.com/ryanmcdermott/clean-cod
32
32
8.[并发](#并发)
33
33
9.[错误处理](#错误处理)
34
34
10.[格式化](#格式化)
35
-
11.[评论](#评论)
35
+
11.[注释](#注释)
36
36
12.[翻译](#翻译)
37
37
38
38
## Introduction
@@ -2765,8 +2765,12 @@ try {
2765
2765
2766
2766
## Formatting
2767
2767
2768
+
## 格式化
2769
+
2768
2770
Formatting is subjective. Like many rules herein, there is no hard and fast rule that you must follow. The main point is *DO NOT ARGUE* over formatting. There are tons of tools to automate this. Use one! It's a waste of time and money for engineers to argue over formatting. The general rule to follow is *keep consistent formatting rules*.
For TypeScript there is a powerful tool called [TSLint](https://palantir.github.io/tslint/). It's a static analysis tool that can help you improve dramatically the readability and maintainability of your code. There are ready to use TSLint configurations that you can reference in your projects:
2771
2775
2772
2776
-[TSLint Config Standard](https://www.npmjs.com/package/tslint-config-standard) - standard style rules
@@ -2785,11 +2789,31 @@ For TypeScript there is a powerful tool called [TSLint](https://palantir.github.
2785
2789
2786
2790
Refer also to this great [TypeScript StyleGuide and Coding Conventions](https://basarat.gitbooks.io/typescript/docs/styleguide/styleguide.html) source.
Capitalization tells you a lot about your variables, functions, etc. These rules are subjective, so your team can choose whatever they want. The point is, no matter what you all choose, just *be consistent*.
@@ -2872,7 +2903,7 @@ const review = new PerformanceReview(employee);
2872
2903
review.review();
2873
2904
```
2874
2905
2875
-
**Good:**
2906
+
**好的:**
2876
2907
2877
2908
```ts
2878
2909
classPerformanceReview {
@@ -2913,10 +2944,12 @@ const review = new PerformanceReview(employee);
2913
2944
review.review();
2914
2945
```
2915
2946
2916
-
**[⬆ back to top](#table-of-contents)**
2947
+
**[⬆ 返回目录](#目录)**
2917
2948
2918
2949
### Organize imports
2919
2950
2951
+
### 组织导入
2952
+
2920
2953
With clean and easy to read import statements you can quickly see the dependencies of current code. Make sure you apply following good practices for `import` statements:
2921
2954
2922
2955
- Import statements should be alphabetized and grouped.
@@ -2932,7 +2965,22 @@ With clean and easy to read import statements you can quickly see the dependenci
2932
2965
- modules from a parent directory (i.e. `import foo from '../foo'; import qux from '../../foo/qux';`)
2933
2966
- modules from the same or a sibling's directory (i.e. `import bar from './bar'; import baz from './bar/baz';`)
@@ -3066,22 +3140,27 @@ function combine(a: number, b: number): number {
3066
3140
}
3067
3141
```
3068
3142
3069
-
**Good:**
3143
+
**好的:**
3070
3144
3071
3145
```ts
3072
3146
function combine(a:number, b:number):number {
3073
3147
returna+b;
3074
3148
}
3075
3149
```
3076
3150
3077
-
**[⬆ back to top](#table-of-contents)**
3151
+
**[⬆ 返回目录](#目录)**
3078
3152
3079
3153
### Avoid positional markers
3080
3154
3155
+
### 避免占位符
3156
+
3081
3157
They usually just add noise. Let the functions and variable names along with the proper indentation and formatting give the visual structure to your code.
3082
3158
Most IDE support code folding feature that allows you to collapse/expand blocks of code (see Visual Studio Code [folding regions](https://code.visualstudio.com/updates/v1_17#_folding-regions)).
3083
3159
3084
-
**Bad:**
3160
+
它们仅仅添加了干扰。 让函数和变量名称与合适的缩进和格式化为你的代码提供视觉结构。
3161
+
绝大多数 IDE 支持代码折叠, 允许你展开/关闭代码段 (查看 Visual Studio Code [folding regions](https://code.visualstudio.com/updates/v1_17#_folding-regions) ) 。
0 commit comments