summaryrefslogtreecommitdiff
path: root/lib/.eslintrc.yaml
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 /lib/.eslintrc.yaml
parent9c6e23d10ff4cfefd9d12fbf4c8614049b9a0a0f (diff)
downloadnode-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 'lib/.eslintrc.yaml')
-rw-r--r--lib/.eslintrc.yaml4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml
index e7cab0ad93..a1a0b9490a 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]"