refactor: mark super as external

This commit is contained in:
cha0s 2022-04-05 13:23:17 -05:00
parent c1d03764c1
commit 87e2f1b9ca
2 changed files with 8 additions and 1 deletions

View File

@ -74,7 +74,6 @@ export function hasExternalDependency(ast) {
const locals = flattenParams(ast);
locals.push(
'global',
'super',
'window',
'Math',
// ... @todo
@ -98,6 +97,9 @@ export function hasExternalDependency(ast) {
hasExternal ||= -1 === locals.indexOf(name);
}
},
Super: () => {
hasExternal = true;
},
})(ast.body);
return hasExternal;
}

View File

@ -58,6 +58,11 @@ it('can identify external dependencies', () => {
))
.to.be.false;
expect(hasExternalDependency(
extractFunction(parse('function test(a, b) { super.whatever; }', {allowSuperOutsideMethod: true})),
))
.to.be.true;
expect(hasExternalDependency(
extractFunction(parse('function test(a, b) { this.whatever; }')),
))