in legacy/javascript/src/refactor.js [581:605]
enter: function (node, parent) {
if (node.type === 'FunctionDeclaration' && singleReturnFunctions[node.id.name]) {
if (!engine.checkAndAddRedundantFunction(node, node.id.name, redundantFunctions)) {
this.skip();
}
} else if (node.type === 'FunctionExpression') {
if (parent.type === 'VariableDeclarator' && singleReturnFunctions[parent.id.name]) {
if (!engine.checkAndAddRedundantFunction(node, parent.id.name, redundantFunctions)) {
this.skip();
}
}
} else if (node.type === 'ArrowFunctionExpression') {
if (parent.type === 'VariableDeclarator' && singleReturnFunctions[parent.id.name] !== undefined) {
if (node.body.type !== 'BlockStatement') {
if (engine.isPiranhaLiteral(node.body) && typeof node.body.value === 'boolean') {
redundantFunctions[parent.id.name] = node.body.value;
}
} else {
if (!engine.checkAndAddRedundantFunction(node, parent.id.name, redundantFunctions)) {
this.skip();
}
}
}
}
},