Skip to content

Commit 48199ef

Browse files
committed
Use valid JS in examples and disable rule for async/await
1 parent bdc2114 commit 48199ef

File tree

2 files changed

+56
-34
lines changed

2 files changed

+56
-34
lines changed

etc/eslint/rules/best_practices.js

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ var rules = {};
3737
* // Bad...
3838
* var obj = {};
3939
* Object.defineProperty( obj, 'a', {
40-
* 'set': function set(){}
40+
* 'set': function set() {}
4141
* });
4242
*
4343
* @example
4444
* // Good...
4545
* var obj = {};
4646
* Object.defineProperty( obj, 'a', {
47-
* 'set': function set(){},
48-
* 'get': function get(){}
47+
* 'set': function set() {},
48+
* 'get': function get() {}
4949
* });
5050
*/
5151
rules[ 'accessor-pairs' ] = [ 'error', {
@@ -122,7 +122,7 @@ rules[ 'block-scoped-var' ] = 'error';
122122
* @example
123123
* // Bad...
124124
* class A {
125-
* constructor(){}
125+
* constructor() {}
126126
* say() {
127127
* return 'Hello';
128128
* }
@@ -131,7 +131,7 @@ rules[ 'block-scoped-var' ] = 'error';
131131
* @example
132132
* // Good...
133133
* class A {
134-
* constructor(){}
134+
* constructor() {}
135135
* static say() {
136136
* return 'Hello';
137137
* }
@@ -381,18 +381,22 @@ rules[ 'no-div-regex' ] = 'error';
381381
*
382382
* @example
383383
* // Bad...
384-
* if ( x === y ) {
385-
* return x;
386-
* } else {
387-
* return y;
384+
* function foo( x, y ) {
385+
* if ( x === y ) {
386+
* return x;
387+
* } else {
388+
* return y;
389+
* }
388390
* }
389391
*
390392
* @example
391393
* // Good...
392-
* if ( x === y ) {
393-
* return x;
394+
* function foo( x, y ) {
395+
* if ( x === y ) {
396+
* return x;
397+
* }
398+
* return y;
394399
* }
395-
* return y;
396400
*/
397401
rules[ 'no-else-return' ] = [ 'error', {
398402
'allowElseIf': false
@@ -1035,6 +1039,8 @@ rules[ 'no-restricted-properties' ] = 'off';
10351039
*/
10361040
rules[ 'no-return-assign' ] = [ 'error', 'always' ];
10371041

1042+
/* eslint-disable stdlib/jsdoc-return-annotations-marker */
1043+
10381044
/**
10391045
* Never allow `return await`.
10401046
*
@@ -1052,6 +1058,8 @@ rules[ 'no-return-assign' ] = [ 'error', 'always' ];
10521058
*/
10531059
rules[ 'no-return-await' ] = 'error';
10541060

1061+
/* eslint-enable stdlib/jsdoc-return-annotations-marker */
1062+
10551063
/**
10561064
* Never allow using `javascript:` in urls.
10571065
*
@@ -1183,12 +1191,14 @@ rules[ 'no-unused-expressions' ] = [ 'error', {
11831191
*
11841192
* @example
11851193
* // Bad...
1186-
* var x = 0;
1187-
* A: while( true ) {
1188-
* if ( x === 10 ) {
1189-
* return;
1194+
* function foo() {
1195+
* var x = 0;
1196+
* A: while( true ) {
1197+
* if ( x === 10 ) {
1198+
* return;
1199+
* }
1200+
* x += 1;
11901201
* }
1191-
* x += 1;
11921202
* }
11931203
*/
11941204
rules[ 'no-unused-labels' ] = 'error';
@@ -1345,6 +1355,8 @@ rules[ 'no-with' ] = 'error';
13451355
*/
13461356
rules[ 'radix' ] = [ 'error', 'always' ];
13471357

1358+
/* eslint-disable stdlib/jsdoc-return-annotations-marker */
1359+
13481360
/**
13491361
* Always require `async` functions to have an `await` expression.
13501362
*
@@ -1368,6 +1380,8 @@ rules[ 'radix' ] = [ 'error', 'always' ];
13681380
*/
13691381
rules[ 'require-await' ] = 'error';
13701382

1383+
/* eslint-enable stdlib/jsdoc-return-annotations-marker */
1384+
13711385
/**
13721386
* Always declare variables at the top of their scope to represent hoisting.
13731387
*

etc/eslint/rules/programmer_errors.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,18 @@ rules[ 'no-control-regex' ] = 'error';
207207
*
208208
* @example
209209
* // Bad...
210-
* if ( bool === true ) {
211-
* debugger;
212-
* return bool;
210+
* function foo( bool ) {
211+
* if ( bool === true ) {
212+
* debugger;
213+
* return bool;
214+
* }
213215
* }
214216
*
215217
* @example
216-
* if ( bool === true ) {
217-
* return bool;
218+
* function foo( bool ) {
219+
* if ( bool === true ) {
220+
* return bool;
221+
* }
218222
* }
219223
*/
220224
rules[ 'no-debugger' ] = 'error';
@@ -714,23 +718,27 @@ rules[ 'no-unreachable' ] = 'error';
714718
*
715719
* @example
716720
* // Bad...
717-
* try {
718-
* return 1;
719-
* } catch ( err ) {
720-
* return 2;
721-
* } finally {
722-
* return 3; // 3 is returned before 1
721+
* function foo() {
722+
* try {
723+
* return 1;
724+
* } catch ( err ) {
725+
* return 2;
726+
* } finally {
727+
* return 3; // 3 is returned before 1
728+
* }
723729
* }
724730
*
725731
* @example
726732
* // Good...
727733
* var bool;
728-
* try {
729-
* return 1;
730-
* } catch ( err ) {
731-
* return 2;
732-
* } finally {
733-
* bool = true;
734+
* function foo() {
735+
* try {
736+
* return 1;
737+
* } catch ( err ) {
738+
* return 2;
739+
* } finally {
740+
* bool = true;
741+
* }
734742
* }
735743
*/
736744
rules[ 'no-unsafe-finally' ] = 'error';

0 commit comments

Comments
 (0)