Skip to content

Commit

Permalink
fix: 增加漏掉的 19.9
Browse files Browse the repository at this point in the history
  • Loading branch information
harrisoff committed May 23, 2019
1 parent 884c217 commit 808324c
Showing 1 changed file with 75 additions and 22 deletions.
97 changes: 75 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2780,9 +2780,62 @@ Other Style Guides
}
```

<a name="19.9"></a>
<a name="whitespace--no-multiple-blanks"></a>
- [19.9](#whitespace--no-multiple-blanks)不要在代码之间使用多个空白行填充。 eslint: [`no-multiple-empty-lines`](https://eslint.org/docs/rules/no-multiple-empty-lines)

```javascript
// bad
class Person {
constructor(fullName, email, birthday) {
this.fullName = fullName;


this.email = email;


this.setAge(birthday);
}


setAge(birthday) {
const today = new Date();


const age = this.getAge(today, birthday);


this.age = age;
}


getAge(today, birthday) {
// ..
}
}

// good
class Person {
constructor(fullName, email, birthday) {
this.fullName = fullName;
this.email = email;
this.setAge(birthday);
}

setAge(birthday) {
const today = new Date();
const age = getAge(today, birthday);
this.age = age;
}

getAge(today, birthday) {
// ..
}
}
```

<a name="19.10"></a>
<a name="whitespace--in-parens"></a>
- [19.9](#whitespace--in-parens) 圆括号里不要加空格。 eslint: [`space-in-parens`](http:https://eslint.org/docs/rules/space-in-parens.html)
- [19.10](#whitespace--in-parens) 圆括号里不要加空格。 eslint: [`space-in-parens`](http:https://eslint.org/docs/rules/space-in-parens.html)

```javascript
// bad
Expand All @@ -2806,9 +2859,9 @@ Other Style Guides
}
```

<a name="19.10"></a>
<a name="19.11"></a>
<a name="whitespace--in-brackets"></a>
- [19.10](#whitespace--in-brackets) 方括号里不要加空格。看示例。 eslint: [`array-bracket-spacing`](http:https://eslint.org/docs/rules/array-bracket-spacing.html)
- [19.11](#whitespace--in-brackets) 方括号里不要加空格。看示例。 eslint: [`array-bracket-spacing`](http:https://eslint.org/docs/rules/array-bracket-spacing.html)

```javascript
// bad
Expand All @@ -2820,9 +2873,9 @@ Other Style Guides
console.log(foo[0]);
```

<a name="19.11"></a>
<a name="19.12"></a>
<a name="whitespace--in-braces"></a>
- [19.11](#whitespace--in-braces) 花括号里加空格。 eslint: [`object-curly-spacing`](http:https://eslint.org/docs/rules/object-curly-spacing.html)
- [19.12](#whitespace--in-braces) 花括号里加空格。 eslint: [`object-curly-spacing`](http:https://eslint.org/docs/rules/object-curly-spacing.html)

```javascript
// bad
Expand All @@ -2832,9 +2885,9 @@ Other Style Guides
const foo = { clark: 'kent' };
```

<a name="19.12"></a>
<a name="19.13"></a>
<a name="whitespace--max-len"></a>
- [19.12](#whitespace--max-len) 避免一行代码超过100个字符(包含空格)。
- [19.13](#whitespace--max-len) 避免一行代码超过100个字符(包含空格)。
- 注意: 对于[上面——strings--line-length](#strings--line-length),长字符串不受此规则限制,不应分解。 eslint: [`max-len`](http:https://eslint.org/docs/rules/max-len.html)

> Why? 这样确保可读性和可维护性
Expand Down Expand Up @@ -2864,9 +2917,9 @@ Other Style Guides
.fail(() => console.log('You have failed this city.'));
```

<a name="19.13"></a>
<a name="19.14"></a>
<a name="whitespace--block-spacing"></a>
- [19.13](#whitespace--block-spacing) 作为语句的花括号内也要加空格 —— `{` 后和 `}` 前都需要空格。 eslint: [`block-spacing`](https://eslint.org/docs/rules/block-spacing)
- [19.14](#whitespace--block-spacing) 作为语句的花括号内也要加空格 —— `{` 后和 `}` 前都需要空格。 eslint: [`block-spacing`](https://eslint.org/docs/rules/block-spacing)

```javascript
// bad
Expand All @@ -2878,9 +2931,9 @@ Other Style Guides
if (foo) { bar = 0; }
```

<a name="19.14"></a>
<a name="19.15"></a>
<a name="whitespace--comma-spacing"></a>
- [19.14](#whitespace--comma-spacing) `,` 前不要空格, `,` 后需要空格。 eslint: [`comma-spacing`](https://eslint.org/docs/rules/comma-spacing)
- [19.15](#whitespace--comma-spacing) `,` 前不要空格, `,` 后需要空格。 eslint: [`comma-spacing`](https://eslint.org/docs/rules/comma-spacing)

```javascript
// bad
Expand All @@ -2892,9 +2945,9 @@ Other Style Guides
var arr = [1, 2];
```

<a name="19.15"></a>
<a name="19.16"></a>
<a name="whitespace--computed-property-spacing"></a>
- [19.15](#whitespace--computed-property-spacing) 计算属性内要空格。参考上述花括号和中括号的规则。 eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing)
- [19.16](#whitespace--computed-property-spacing) 计算属性内要空格。参考上述花括号和中括号的规则。 eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing)

```javascript
// bad
Expand All @@ -2910,9 +2963,9 @@ Other Style Guides
obj[foo[bar]]
```

<a name="19.16"></a>
<a name="19.17"></a>
<a name="whitespace--func-call-spacing"></a>
- [19.16](#whitespace--func-call-spacing) 调用函数时,函数名和小括号之间不要空格。 eslint: [`func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing)
- [19.17](#whitespace--func-call-spacing) 调用函数时,函数名和小括号之间不要空格。 eslint: [`func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing)

```javascript
// bad
Expand All @@ -2925,9 +2978,9 @@ Other Style Guides
func();
```

<a name="19.17"></a>
<a name="19.18"></a>
<a name="whitespace--key-spacing"></a>
- [19.17](#whitespace--key-spacing) 在对象的字面量属性中, `key` `value` 之间要有空格。 eslint: [`key-spacing`](https://eslint.org/docs/rules/key-spacing)
- [19.18](#whitespace--key-spacing) 在对象的字面量属性中, `key` `value` 之间要有空格。 eslint: [`key-spacing`](https://eslint.org/docs/rules/key-spacing)

```javascript
// bad
Expand All @@ -2938,13 +2991,13 @@ Other Style Guides
var obj = { "foo": 42 };
```

<a name="19.18"></a>
<a name="19.19"></a>
<a name="whitespace--no-trailing-spaces"></a>
- [19.18](#whitespace--no-trailing-spaces) 行末不要空格。 eslint: [`no-trailing-spaces`](https://eslint.org/docs/rules/no-trailing-spaces)
- [19.19](#whitespace--no-trailing-spaces) 行末不要空格。 eslint: [`no-trailing-spaces`](https://eslint.org/docs/rules/no-trailing-spaces)

<a name="19.19"></a>
<a name="19.20"></a>
<a name="whitespace--no-multiple-empty-lines"></a>
- [19.19](#whitespace--no-multiple-empty-lines) 避免出现多个空行。 在文件末尾只允许空一行。 eslint: [`no-multiple-empty-lines`](https://eslint.org/docs/rules/no-multiple-empty-lines)
- [19.20](#whitespace--no-multiple-empty-lines) 避免出现多个空行。 在文件末尾只允许空一行。 eslint: [`no-multiple-empty-lines`](https://eslint.org/docs/rules/no-multiple-empty-lines)

<!-- markdownlint-disable MD012 -->
```javascript
Expand Down

0 comments on commit 808324c

Please sign in to comment.