GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tools: update crypo check rule · nodejs/node@2a85cc7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-eslint-crypto-check.js
  • tools/eslint-rules
    • crypto-check.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-eslint-crypto-check.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eslint-crypto-check.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ new RuleTester().run('crypto-check', rule, {
2222
`
2323
],
2424
invalid: [
25+
{
26+
code: 'require("common")\n' +
27+
'require("crypto")\n' +
28+
'if (!common.hasCrypto) {\n' +
29+
' common.skip("missing crypto");\n' +
30+
'}',
31+
errors: [{ message }]
32+
},
2533
{
2634
code: 'require("common")\n' +
2735
'require("crypto")',
Collapse file

‎tools/eslint-rules/crypto-check.js‎

Copy file name to clipboardExpand all lines: tools/eslint-rules/crypto-check.js
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,22 @@ module.exports = function(context) {
6666

6767
function reportIfMissingCheck() {
6868
if (hasSkipCall) {
69+
// There is a skip, which is good, but verify that the require() calls
70+
// in question come after at least one check.
71+
if (missingCheckNodes.length > 0) {
72+
requireNodes.forEach((requireNode) => {
73+
const beforeAllChecks = missingCheckNodes.every((checkNode) => {
74+
return requireNode.start < checkNode.start;
75+
});
76+
77+
if (beforeAllChecks) {
78+
context.report({
79+
node: requireNode,
80+
message: msg
81+
});
82+
}
83+
});
84+
}
6985
return;
7086
}
7187

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.