mirror of https://github.com/lukechilds/rollup.git
Rich Harris
8 years ago
committed by
GitHub
10 changed files with 38 additions and 37 deletions
@ -1,28 +0,0 @@ |
|||||
export default function isReference ( node, parent ) { |
|
||||
if ( node.type === 'MemberExpression' ) { |
|
||||
return !node.computed && isReference( node.object, node ); |
|
||||
} |
|
||||
|
|
||||
if ( node.type === 'Identifier' ) { |
|
||||
// the only time we could have an identifier node without a parent is
|
|
||||
// if it's the entire body of a function without a block statement –
|
|
||||
// i.e. an arrow function expression like `a => a`
|
|
||||
if ( !parent ) return true; |
|
||||
|
|
||||
// TODO is this right?
|
|
||||
if ( parent.type === 'MemberExpression' || parent.type === 'MethodDefinition' ) { |
|
||||
return parent.computed || node === parent.object; |
|
||||
} |
|
||||
|
|
||||
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
||||
if ( parent.type === 'Property' ) return parent.computed || node === parent.value; |
|
||||
|
|
||||
// disregard the `bar` in `class Foo { bar () {...} }`
|
|
||||
if ( parent.type === 'MethodDefinition' ) return false; |
|
||||
|
|
||||
// disregard the `bar` in `export { foo as bar }`
|
|
||||
if ( parent.type === 'ExportSpecifier' && node !== parent.local ) return; |
|
||||
|
|
||||
return true; |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,4 @@ |
|||||
|
module.exports = { |
||||
|
description: 'correctly deshadows destructured function parameters (#1008)', |
||||
|
buble: true |
||||
|
}; |
@ -0,0 +1,10 @@ |
|||||
|
import { x } from './x.js'; |
||||
|
|
||||
|
let y; |
||||
|
|
||||
|
function foo ({ x = 42 }) { |
||||
|
y = x; |
||||
|
} |
||||
|
|
||||
|
foo({}); |
||||
|
assert.equal( y, 42 ); |
@ -0,0 +1 @@ |
|||||
|
export var x = 'whatever'; |
Loading…
Reference in new issue