Skip to content

Commit 13aa884

Browse files
committed
Ignore console/debug logging and require from remove function call arguments mutator
1 parent 9cbd21a commit 13aa884

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/mutators/removeFuncCallArgsMutator.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,24 @@ const lineDiff = require('../util/lineDiff')
1212
module.exports = async function removeFuncCallArgsMutator ({mutodeInstance, filePath, lines, queue, ast}) {
1313
debug('Running remove function call arguments mutator on %s', filePath)
1414

15-
walk.simple(ast, {
16-
CallExpression (functionNode) {
15+
walk.ancestor(ast, {
16+
CallExpression (functionNode, state, ancestors) {
17+
if (ancestors.length >= 2) {
18+
const ancestor = ancestors[ancestors.length - 2]
19+
if (ancestor.type && ancestor.type === 'CallExpression' && ancestor.callee) {
20+
if (ancestor.callee.type === 'MemberExpression' && ancestor.callee.object.name === 'console') return
21+
if (ancestor.callee.name) {
22+
switch (ancestor.callee.name) {
23+
case 'require':
24+
case 'debug':
25+
return
26+
default:
27+
break
28+
}
29+
}
30+
}
31+
}
32+
1733
for (const node of functionNode.arguments) {
1834
const line = node.loc.start.line
1935
const lineContent = lines[line - 1]

0 commit comments

Comments
 (0)