| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
function handle(declaration) { |
| 12 |
if (!declaration.isVariableDeclaration()) return; |
| 13 |
|
| 14 |
const fn = declaration.getFunctionParent(); |
| 15 |
const { name } = declaration.node.declarations[0].id; |
| 16 |
|
| 17 |
|
| 18 |
if ( |
| 19 |
fn && |
| 20 |
fn.scope.hasOwnBinding(name) && |
| 21 |
fn.scope.getOwnBinding(name).kind === "param" |
| 22 |
) { |
| 23 |
declaration.scope.rename(name); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
export default () => ({ |
| 28 |
name: "transform-safari-for-shadowing", |
| 29 |
visitor: { |
| 30 |
ForXStatement(path) { |
| 31 |
handle(path.get("left")); |
| 32 |
}, |
| 33 |
|
| 34 |
ForStatement(path) { |
| 35 |
handle(path.get("init")); |
| 36 |
}, |
| 37 |
}, |
| 38 |
}); |