refactor: mark super as external
This commit is contained in:
parent
c1d03764c1
commit
87e2f1b9ca
|
@ -74,7 +74,6 @@ export function hasExternalDependency(ast) {
|
||||||
const locals = flattenParams(ast);
|
const locals = flattenParams(ast);
|
||||||
locals.push(
|
locals.push(
|
||||||
'global',
|
'global',
|
||||||
'super',
|
|
||||||
'window',
|
'window',
|
||||||
'Math',
|
'Math',
|
||||||
// ... @todo
|
// ... @todo
|
||||||
|
@ -98,6 +97,9 @@ export function hasExternalDependency(ast) {
|
||||||
hasExternal ||= -1 === locals.indexOf(name);
|
hasExternal ||= -1 === locals.indexOf(name);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Super: () => {
|
||||||
|
hasExternal = true;
|
||||||
|
},
|
||||||
})(ast.body);
|
})(ast.body);
|
||||||
return hasExternal;
|
return hasExternal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,11 @@ it('can identify external dependencies', () => {
|
||||||
))
|
))
|
||||||
.to.be.false;
|
.to.be.false;
|
||||||
|
|
||||||
|
expect(hasExternalDependency(
|
||||||
|
extractFunction(parse('function test(a, b) { super.whatever; }', {allowSuperOutsideMethod: true})),
|
||||||
|
))
|
||||||
|
.to.be.true;
|
||||||
|
|
||||||
expect(hasExternalDependency(
|
expect(hasExternalDependency(
|
||||||
extractFunction(parse('function test(a, b) { this.whatever; }')),
|
extractFunction(parse('function test(a, b) { this.whatever; }')),
|
||||||
))
|
))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user