diff --git a/.eslintrc.js b/.eslintrc.js index 9c3a78d81cd27a..e4192c3539925c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -156,6 +156,7 @@ module.exports = { ], /* eslint-disable max-len */ // If this list is modified, please copy the change to lib/.eslintrc.yaml + // and test/.eslintrc.yaml. 'no-restricted-syntax': [ 'error', { @@ -166,6 +167,10 @@ module.exports = { selector: "CallExpression[callee.object.name='assert'][callee.property.name='rejects'][arguments.length<2]", message: 'assert.rejects() must be invoked with at least two arguments.', }, + { + selector: "CallExpression[callee.object.name='assert'][callee.property.name='strictEqual'][arguments.2.type='Literal']", + message: 'Do not use a literal for the third argument of assert.strictEqual()' + }, { selector: "CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.1.type='Literal']:not([arguments.1.regex])", message: 'Use an object as second argument of assert.throws()', diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index e7cab0ad931b4d..a1a0b9490a9177 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -2,10 +2,14 @@ rules: no-restricted-syntax: # Config copied from .eslintrc.js - error + - selector: "CallExpression[callee.object.name='assert'][callee.property.name='deepStrictEqual'][arguments.2.type='Literal']" + message: "Do not use a literal for the third argument of assert.deepStrictEqual()" - selector: "CallExpression[callee.object.name='assert'][callee.property.name='doesNotThrow']" message: "Please replace `assert.doesNotThrow()` and add a comment next to the code instead." - selector: "CallExpression[callee.object.name='assert'][callee.property.name='rejects'][arguments.length<2]" message: "assert.rejects() must be invoked with at least two arguments." + - selector: "CallExpression[callee.object.name='assert'][callee.property.name='strictEqual'][arguments.2.type='Literal']" + message: "Do not use a literal for the third argument of assert.strictEqual()" - selector: "CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.1.type='Literal']:not([arguments.1.regex])" message: "Use an object as second argument of assert.throws()" - selector: "CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.length<2]" diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index 25026fec5a103a..63d2127d738597 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -23,10 +23,14 @@ rules: no-restricted-syntax: # Config copied from .eslintrc.js - error + - selector: "CallExpression[callee.object.name='assert'][callee.property.name='deepStrictEqual'][arguments.2.type='Literal']" + message: "Do not use a literal for the third argument of assert.deepStrictEqual()" - selector: "CallExpression[callee.object.name='assert'][callee.property.name='doesNotThrow']" message: "Please replace `assert.doesNotThrow()` and add a comment next to the code instead." - selector: "CallExpression[callee.object.name='assert'][callee.property.name='rejects'][arguments.length<2]" message: "assert.rejects() must be invoked with at least two arguments." + - selector: "CallExpression[callee.object.name='assert'][callee.property.name='strictEqual'][arguments.2.type='Literal']" + message: "Do not use a literal for the third argument of assert.strictEqual()" - selector: "CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.1.type='Literal']:not([arguments.1.regex])" message: "Use an object as second argument of assert.throws()" - selector: "CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.length<2]"