| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
export default ({ types: t }) => { |
| 8 |
const isArrowParent = p => |
| 9 |
p.parentKey === "params" && |
| 10 |
p.parentPath && |
| 11 |
t.isArrowFunctionExpression(p.parentPath); |
| 12 |
|
| 13 |
return { |
| 14 |
name: "transform-edge-default-parameters", |
| 15 |
visitor: { |
| 16 |
AssignmentPattern(path) { |
| 17 |
const arrowArgParent = path.find(isArrowParent); |
| 18 |
if (arrowArgParent && path.parent.shorthand) { |
| 19 |
|
| 20 |
path.parent.shorthand = false; |
| 21 |
(path.parent.extra || {}).shorthand = false; |
| 22 |
|
| 23 |
|
| 24 |
path.scope.rename(path.parent.key.name); |
| 25 |
} |
| 26 |
}, |
| 27 |
}, |
| 28 |
}; |
| 29 |
}; |