summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-01-08 13:02:15 -0500
committerDaniel Bevenius <daniel.bevenius@gmail.com>2019-01-11 10:56:56 +0100
commit4c9ea8f3fb5fb1d26777905f442282ce85896a4b (patch)
treeeb7c04bbf0d92c74c1254fb52ab85e3703de5f77 /tools
parent6cc74b038fa0d2e64e8060415487706117b4a77c (diff)
downloadandroid-node-v8-4c9ea8f3fb5fb1d26777905f442282ce85896a4b.tar.gz
android-node-v8-4c9ea8f3fb5fb1d26777905f442282ce85896a4b.tar.bz2
android-node-v8-4c9ea8f3fb5fb1d26777905f442282ce85896a4b.zip
tools: update crypo check rule
This commit updates the custom crypto-check ESLint rule to detect require() calls that come before any hasCrypto checks. PR-URL: https://github.com/nodejs/node/pull/25399 Refs: https://github.com/nodejs/node/pull/25388 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/eslint-rules/crypto-check.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/eslint-rules/crypto-check.js b/tools/eslint-rules/crypto-check.js
index 42b17b0c80..fbc319f964 100644
--- a/tools/eslint-rules/crypto-check.js
+++ b/tools/eslint-rules/crypto-check.js
@@ -66,6 +66,22 @@ module.exports = function(context) {
function reportIfMissingCheck() {
if (hasSkipCall) {
+ // There is a skip, which is good, but verify that the require() calls
+ // in question come after at least one check.
+ if (missingCheckNodes.length > 0) {
+ requireNodes.forEach((requireNode) => {
+ const beforeAllChecks = missingCheckNodes.every((checkNode) => {
+ return requireNode.start < checkNode.start;
+ });
+
+ if (beforeAllChecks) {
+ context.report({
+ node: requireNode,
+ message: msg
+ });
+ }
+ });
+ }
return;
}