diff options
author | cjihrig <cjihrig@gmail.com> | 2019-01-08 10:36:28 -0500 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2019-01-11 16:17:33 -0500 |
commit | cf9bcdeabe1cac2c19785183e9f34e1a01cb9047 (patch) | |
tree | af0462a36f0eaeb777d6d8c5c2ec58c56b601af1 /test | |
parent | c69ea3b1d5e258cd8234b9d5f771e132f0c4a23c (diff) | |
download | android-node-v8-cf9bcdeabe1cac2c19785183e9f34e1a01cb9047.tar.gz android-node-v8-cf9bcdeabe1cac2c19785183e9f34e1a01cb9047.tar.bz2 android-node-v8-cf9bcdeabe1cac2c19785183e9f34e1a01cb9047.zip |
tools: lint for use of internalBinding()
Use of process.binding() has largely been replaced by
internalBinding(). This commit updates the custom crypto
check ESLint rule to check for both process.binding() and
internalBinding().
Refs: https://github.com/nodejs/node/pull/24952
PR-URL: https://github.com/nodejs/node/pull/25395
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-eslint-crypto-check.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/parallel/test-eslint-crypto-check.js b/test/parallel/test-eslint-crypto-check.js index 1829e86b02..2325a04354 100644 --- a/test/parallel/test-eslint-crypto-check.js +++ b/test/parallel/test-eslint-crypto-check.js @@ -19,6 +19,12 @@ new RuleTester().run('crypto-check', rule, { common.skip("missing crypto"); } require("crypto"); + `, + ` + if (!common.hasCrypto) { + common.skip("missing crypto"); + } + internalBinding("crypto"); ` ], invalid: [ @@ -51,6 +57,18 @@ new RuleTester().run('crypto-check', rule, { '}\n' + 'if (common.foo) {}\n' + 'require("crypto")' + }, + { + code: 'require("common")\n' + + 'if (common.foo) {}\n' + + 'internalBinding("crypto")', + errors: [{ message }], + output: 'require("common")\n' + + 'if (!common.hasCrypto) {' + + ' common.skip("missing crypto");' + + '}\n' + + 'if (common.foo) {}\n' + + 'internalBinding("crypto")' } ] }); |