summaryrefslogtreecommitdiff
path: root/.eslintrc.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2018-07-30 16:33:41 -0700
committerRich Trott <rtrott@gmail.com>2018-09-16 20:37:42 -0700
commitb7661a8311a0bf5703a009bf35b4333c1c6e60e0 (patch)
tree84ca2afb802ab3e255373ace56f6d729b892211a /.eslintrc.js
parent9c6e23d10ff4cfefd9d12fbf4c8614049b9a0a0f (diff)
downloadandroid-node-v8-b7661a8311a0bf5703a009bf35b4333c1c6e60e0.tar.gz
android-node-v8-b7661a8311a0bf5703a009bf35b4333c1c6e60e0.tar.bz2
android-node-v8-b7661a8311a0bf5703a009bf35b4333c1c6e60e0.zip
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.js5
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()',
},