Skip to content

Commit 143975a

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 143975a

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

README.md

+102
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,90 @@ 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+
- [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)
2739+
2740+
```javascript
2741+
// bad
2742+
var obj = { "foo" : 42 };
2743+
var obj2 = { "foo":42 };
2744+
2745+
// good
2746+
var obj = { "foo": 42 };
2747+
```
2748+
2749+
- [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)
2750+
2751+
- [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)
2752+
2753+
<!-- markdownlint-disable MD012 -->
2754+
```javascript
2755+
// bad
2756+
var x = 1;
2757+
2758+
2759+
2760+
var y = 2;
2761+
2762+
// good
2763+
var x = 1;
2764+
2765+
var y = 2;
2766+
```
2767+
<!-- markdownlint-enable MD012 -->
2768+
26672769
**[⬆ back to top](#table-of-contents)**
26682770

26692771
## Commas

0 commit comments

Comments
 (0)