diff options
author | Rich Trott <rtrott@gmail.com> | 2018-07-30 16:33:41 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-09-16 20:37:42 -0700 |
commit | b7661a8311a0bf5703a009bf35b4333c1c6e60e0 (patch) | |
tree | 84ca2afb802ab3e255373ace56f6d729b892211a /.eslintrc.js | |
parent | 9c6e23d10ff4cfefd9d12fbf4c8614049b9a0a0f (diff) | |
download | node-new-b7661a8311a0bf5703a009bf35b4333c1c6e60e0.tar.gz |
tools: prevent string literals in some assertions
String literals provided as the third argument to assert.strictEqual()
or assert.deepStrictEqual() will mask the values that are causing
issues. Use a lint rule to prevent such usage.
PR-URL: https://github.com/nodejs/node/pull/22849
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to '.eslintrc.js')
-rw-r--r-- | .eslintrc.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/.eslintrc.js b/.eslintrc.js index 9c3a78d81c..e4192c3539 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', { @@ -167,6 +168,10 @@ module.exports = { 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()', }, |