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); 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;
} }

View File

@ -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; }')),
)) ))