Skip to content

Commit ea6ca7f

Browse files
committed
Add descriptions of enforced rules
This commit adds brief descriptions and examples of rules enforced by the guide that were not previously mentioned in the README.
1 parent 2d97799 commit ea6ca7f

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

README.md

+105
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,24 @@ Other Style Guides
10531053
};
10541054
```
10551055
1056+
- [8.6](#whitespace--implicit-arrow-linebreak) Enforce the location of arrow function bodies with implicit returns. eslint: [`implicit-arrow-linebreak`](https://eslint.org/docs/rules/implicit-arrow-linebreak)
1057+
1058+
```javascript
1059+
// bad
1060+
(foo) =>
1061+
bar;
1062+
1063+
(foo) =>
1064+
(bar);
1065+
1066+
// good
1067+
(foo) => bar;
1068+
(foo) => (bar);
1069+
(foo) => (
1070+
bar
1071+
)
1072+
```
1073+
10561074
**[⬆ back to top](#table-of-contents)**
10571075
10581076
## Classes & Constructors
@@ -2664,6 +2682,93 @@ Other Style Guides
26642682
.fail(() => console.log('You have failed this city.'));
26652683
```
26662684

2685+
- [19.13](#whitespace--block-spacing) Require consistent spacing inside an open block token and the next token on the same line. This rule also enforces consistent spacing inside a close block token and previous token on the same line. eslint: [`block-spacing`](https://eslint.org/docs/rules/block-spacing)
2686+
2687+
```javascript
2688+
// bad
2689+
function foo() {return true;}
2690+
if (foo) { bar = 0;}
2691+
2692+
// good
2693+
function foo() { return true; }
2694+
if (foo) { bar = 0; }
2695+
```
2696+
2697+
- [19.14](#whitespace--comma-spacing) Avoid spaces before commas and require a space after commas. eslint: [`comma-spacing`](https://eslint.org/docs/rules/comma-spacing)
2698+
2699+
```javascript
2700+
// bad
2701+
var foo = 1,bar = 2;
2702+
var arr = [1 , 2];
2703+
2704+
// good
2705+
var foo = 1, bar = 2;
2706+
var arr = [1, 2];
2707+
```
2708+
2709+
- [19.15](#whitespace--computed-property-spacing) Avoid spaces before commas and require a space after commas. eslint: [`computed-property-spacing`](https://eslint.org/docs/rules/computed-property-spacing)
2710+
2711+
```javascript
2712+
// bad
2713+
obj[foo ]
2714+
obj[ 'foo']
2715+
var x = {[ b ]: a}
2716+
obj[foo[ bar ]]
2717+
2718+
// good
2719+
obj[foo]
2720+
obj['foo']
2721+
var x = { [b]: a }
2722+
obj[foo[bar]]
2723+
```
2724+
2725+
- [19.16](#whitespace--func-call-spacing) Enforce spacing between functions and their invocations. eslint: [`func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing)
2726+
2727+
```javascript
2728+
// bad
2729+
func ();
2730+
2731+
func
2732+
();
2733+
2734+
// good
2735+
func();
2736+
```
2737+
2738+
<a name="whitespace--key-spacing"></a><a name="18.17"></a>
2739+
- [19.17](#whitespace--key-spacing) Enforce spacing between keys and values in object literal properties. eslint: [`key-spacing`](https://eslint.org/docs/rules/key-spacing)
2740+
2741+
```javascript
2742+
// bad
2743+
var obj = { "foo" : 42 };
2744+
var obj2 = { "foo":42 };
2745+
2746+
// good
2747+
var obj = { "foo": 42 };
2748+
```
2749+
2750+
<a name="whitespace--no-trailing-spaces"></a><a name="18.18"></a>
2751+
- [19.18](#whitespace--no-trailing-spaces) Avoid trailing spaces at the end of lines. eslint: [`no-trailing-spaces`](https://eslint.org/docs/rules/no-trailing-spaces)
2752+
2753+
<a name="whitespace--no-multiple-empty-lines"></a><a name="18.19"></a>
2754+
- [19.19](#whitespace--no-multiple-empty-lines) Avoid multiple empty lines and only allow one newline at the end of files. eslint: [`no-multiple-empty-lines`](https://eslint.org/docs/rules/no-multiple-empty-lines)
2755+
2756+
<!-- markdownlint-disable MD012 -->
2757+
```javascript
2758+
// bad
2759+
var x = 1;
2760+
2761+
2762+
2763+
var y = 2;
2764+
2765+
// good
2766+
var x = 1;
2767+
2768+
var y = 2;
2769+
```
2770+
<!-- markdownlint-enable MD012 -->
2771+
26672772
**[⬆ back to top](#table-of-contents)**
26682773

26692774
## Commas

0 commit comments

Comments
 (0)