mirror of
https://github.com/github/codeql.git
synced 2026-02-23 18:33:42 +01:00
JS: handle .mjs files correctly
This commit is contained in:
@@ -553,7 +553,7 @@ public class ASTExtractor {
|
||||
if (sourceType.hasLocalScope()) {
|
||||
Label moduleScopeKey = trapwriter.globalID("module;{" + locationManager.getFileLabel() + "}," + locationManager.getStartLine() + "," + locationManager.getStartColumn());
|
||||
scopeManager.enterScope(3, moduleScopeKey, toplevelLabel);
|
||||
scopeManager.addVariables(sourceType.getPredefinedLocals(platform));
|
||||
scopeManager.addVariables(sourceType.getPredefinedLocals(platform, locationManager.getSourceFileExtension()));
|
||||
trapwriter.addTuple("isModule", toplevelLabel);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,14 +107,14 @@ public class ExtractorConfig {
|
||||
* <p/>
|
||||
* If this source type has no local scope, the empty set is returned.
|
||||
*/
|
||||
public Set<String> getPredefinedLocals(Platform platform) {
|
||||
public Set<String> getPredefinedLocals(Platform platform, String extension) {
|
||||
switch (this) {
|
||||
case CLOSURE_MODULE:
|
||||
return closureLocals;
|
||||
case COMMONJS_MODULE:
|
||||
return commonJsLocals;
|
||||
case MODULE:
|
||||
if (platform == Platform.NODE) {
|
||||
if (platform == Platform.NODE && !extension.equals(".mjs")) {
|
||||
// An ES2015 module that is compiled to a Node.js module effectively has the locals
|
||||
// from Node.js even if they are not part of the ES2015 standard.
|
||||
return commonJsLocals;
|
||||
|
||||
Reference in New Issue
Block a user