(node)
| 36 | traverse(ast, { |
| 37 | enter() {}, |
| 38 | leave(node) { |
| 39 | if (node.type !== 'CallExpression') { |
| 40 | return; |
| 41 | } |
| 42 | const callee = node.callee; |
| 43 | if ( |
| 44 | callee.type === 'MemberExpression' && |
| 45 | callee.object.type === 'Identifier' && |
| 46 | callee.object.name === 'console' && |
| 47 | callee.property.type === 'Identifier' && |
| 48 | (callee.property.name === 'warn' || callee.property.name === 'error') |
| 49 | ) { |
| 50 | // warning messages can be concatenated (`+`) at runtime, so here's |
| 51 | // a trivial partial evaluator that interprets the literal value |
| 52 | try { |
| 53 | const warningMsgLiteral = evalStringConcat(node.arguments[0]); |
| 54 | warnings.add(warningMsgLiteral); |
| 55 | } catch { |
| 56 | // Silently skip over this call. We have a lint rule to enforce |
| 57 | // that all calls are extractable, so if this one fails, assume |
| 58 | // it's intentional. |
| 59 | } |
| 60 | } |
| 61 | }, |
| 62 | }); |
| 63 | |
| 64 | cb(null); |
nothing calls this directly
no test coverage detected