File tree 5 files changed +18
-9
lines changed
5 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ module.exports = {
156
156
] ,
157
157
/* eslint-disable max-len */
158
158
// If this list is modified, please copy the change to lib/.eslintrc.yaml
159
+ // and test/.eslintrc.yaml.
159
160
'no-restricted-syntax' : [
160
161
'error' ,
161
162
{
@@ -166,6 +167,10 @@ module.exports = {
166
167
selector : "CallExpression[callee.object.name='assert'][callee.property.name='rejects'][arguments.length<2]" ,
167
168
message : 'assert.rejects() must be invoked with at least two arguments.' ,
168
169
} ,
170
+ {
171
+ selector : "CallExpression[callee.object.name='assert'][callee.property.name='strictEqual'][arguments.2.type='Literal']" ,
172
+ message : 'Do not use a literal for the third argument of assert.strictEqual()'
173
+ } ,
169
174
{
170
175
selector : "CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.1.type='Literal']:not([arguments.1.regex])" ,
171
176
message : 'Use an object as second argument of assert.throws()' ,
Original file line number Diff line number Diff line change 2
2
no-restricted-syntax :
3
3
# Config copied from .eslintrc.js
4
4
- error
5
+ - selector : " CallExpression[callee.object.name='assert'][callee.property.name='deepStrictEqual'][arguments.2.type='Literal']"
6
+ message : " Do not use a literal for the third argument of assert.deepStrictEqual()"
5
7
- selector : " CallExpression[callee.object.name='assert'][callee.property.name='doesNotThrow']"
6
8
message : " Please replace `assert.doesNotThrow()` and add a comment next to the code instead."
7
9
- selector : " CallExpression[callee.object.name='assert'][callee.property.name='rejects'][arguments.length<2]"
8
10
message : " assert.rejects() must be invoked with at least two arguments."
11
+ - selector : " CallExpression[callee.object.name='assert'][callee.property.name='strictEqual'][arguments.2.type='Literal']"
12
+ message : " Do not use a literal for the third argument of assert.strictEqual()"
9
13
- selector : " CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.1.type='Literal']:not([arguments.1.regex])"
10
14
message : " Use an object as second argument of assert.throws()"
11
15
- selector : " CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.length<2]"
Original file line number Diff line number Diff line change @@ -23,10 +23,14 @@ rules:
23
23
no-restricted-syntax :
24
24
# Config copied from .eslintrc.js
25
25
- error
26
+ - selector : " CallExpression[callee.object.name='assert'][callee.property.name='deepStrictEqual'][arguments.2.type='Literal']"
27
+ message : " Do not use a literal for the third argument of assert.deepStrictEqual()"
26
28
- selector : " CallExpression[callee.object.name='assert'][callee.property.name='doesNotThrow']"
27
29
message : " Please replace `assert.doesNotThrow()` and add a comment next to the code instead."
28
30
- selector : " CallExpression[callee.object.name='assert'][callee.property.name='rejects'][arguments.length<2]"
29
31
message : " assert.rejects() must be invoked with at least two arguments."
32
+ - selector : " CallExpression[callee.object.name='assert'][callee.property.name='strictEqual'][arguments.2.type='Literal']"
33
+ message : " Do not use a literal for the third argument of assert.strictEqual()"
30
34
- selector : " CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.1.type='Literal']:not([arguments.1.regex])"
31
35
message : " Use an object as second argument of assert.throws()"
32
36
- selector : " CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.length<2]"
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ const handle1 = setTimeout(common.mustCall(function() {
37
37
38
38
// Make sure our clearTimeout succeeded. One timer finished and
39
39
// the other was canceled, so none should be active.
40
- assert . strictEqual ( activeTimers . length , 0 , 'Timers remain.' ) ;
40
+ assert . strictEqual ( activeTimers . length , 0 ) ;
41
41
} ) ) ;
42
42
} ) ) ;
43
43
} ) , 1 ) ;
@@ -53,11 +53,9 @@ const handle1 = setTimeout(common.mustCall(function() {
53
53
54
54
// Make sure our clearTimeout succeeded. One timer finished and
55
55
// the other was canceled, so none should be active.
56
- assert . strictEqual ( activeTimers . length , 3 ,
57
- 'There should be 3 timers in the list.' ) ;
56
+ assert . strictEqual ( activeTimers . length , 3 ) ;
58
57
assert ( shortTimer instanceof Timer , 'The shorter timer is not in the list.' ) ;
59
- assert . strictEqual ( longTimers . length , 2 ,
60
- 'Both longer timers should be in the list.' ) ;
58
+ assert . strictEqual ( longTimers . length , 2 ) ;
61
59
62
60
// When this callback completes, `listOnTimeout` should now look at the
63
61
// correct list and refrain from removing the new TIMEOUT list which
Original file line number Diff line number Diff line change @@ -4,11 +4,9 @@ require('../common');
4
4
const assert = require ( 'assert' ) ;
5
5
6
6
const timer1 = setTimeout ( ( ) => { } , 1 ) . unref ( ) ;
7
- assert . strictEqual ( timer1 . _handle . _list , undefined ,
8
- 'timer1._handle._list should be undefined' ) ;
7
+ assert . strictEqual ( timer1 . _handle . _list , undefined ) ;
9
8
10
9
// Check that everything works even if the handle was not re-used.
11
10
setTimeout ( ( ) => { } , 1 ) ;
12
11
const timer2 = setTimeout ( ( ) => { } , 1 ) . unref ( ) ;
13
- assert . strictEqual ( timer2 . _handle . _list , undefined ,
14
- 'timer2._handle._list should be undefined' ) ;
12
+ assert . strictEqual ( timer2 . _handle . _list , undefined ) ;
You can’t perform that action at this time.
0 commit comments