(node)
| 60 | |
| 61 | return { |
| 62 | CallExpression(node) { |
| 63 | const cb = node.arguments.find( |
| 64 | (a) => a && (a.type === "FunctionExpression" || a.type === "ArrowFunctionExpression") |
| 65 | ); |
| 66 | if (!cb) return; |
| 67 | |
| 68 | const callee = context.getSourceCode().getText(node.callee); |
| 69 | if (!callee.startsWith("chrome.")) return; |
| 70 | |
| 71 | // Skip Promise-based API usage |
| 72 | const isPromise = node.parent?.type === "AwaitExpression"; |
| 73 | if (isPromise) return; |
| 74 | |
| 75 | // Check callback body for lastError reference |
| 76 | const cbBody = context.getSourceCode().getText(cb.body); |
| 77 | const checksLastError = cbBody.includes("chrome.runtime.lastError"); |
| 78 | |
| 79 | if (mustCheck.has(callee)) { |
| 80 | if (!checksLastError) { |
| 81 | context.report({ |
| 82 | node: cb, |
| 83 | messageId: "missing", |
| 84 | data: { api: callee }, |
| 85 | }); |
| 86 | } |
| 87 | } else if (isMaybeCheck(callee)) { |
| 88 | if (!checksLastError) { |
| 89 | context.report({ |
| 90 | node: cb, |
| 91 | messageId: "uncertain", |
| 92 | data: { api: callee }, |
| 93 | }); |
| 94 | } |
| 95 | } |
| 96 | }, |
| 97 | }; |
| 98 | }, |
| 99 | }; |
nothing calls this directly
no test coverage detected