| 66 | } |
| 67 | |
| 68 | function reportIfMissingCheck() { |
| 69 | if (hasSkipCall) { |
| 70 | // There is a skip, which is good, but verify that the require() calls |
| 71 | // in question come after at least one check. |
| 72 | if (missingCheckNodes.length > 0) { |
| 73 | requireNodes.forEach((requireNode) => { |
| 74 | const beforeAllChecks = missingCheckNodes.every((checkNode) => { |
| 75 | return requireNode.range[0] < checkNode.range[0]; |
| 76 | }); |
| 77 | |
| 78 | if (beforeAllChecks) { |
| 79 | context.report({ |
| 80 | node: requireNode, |
| 81 | message: msg, |
| 82 | }); |
| 83 | } |
| 84 | }); |
| 85 | } |
| 86 | return; |
| 87 | } |
| 88 | |
| 89 | if (requireNodes.length > 0) { |
| 90 | if (missingCheckNodes.length > 0) { |
| 91 | report(missingCheckNodes); |
| 92 | } else { |
| 93 | report(requireNodes); |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | function report(nodes) { |
| 99 | nodes.forEach((node) => { |