Skip to content

Commit f7bddae

Browse files
committed
JS: Implement babel path mappings with PathMapping
1 parent 6206258 commit f7bddae

File tree

1 file changed

+11
-2
lines changed
  • javascript/ql/lib/semmle/javascript/frameworks

1 file changed

+11
-2
lines changed

javascript/ql/lib/semmle/javascript/frameworks/Babel.qll

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
import javascript
6+
private import semmle.javascript.internal.paths.PathMapping
67

78
module Babel {
89
/**
@@ -138,7 +139,7 @@ module Babel {
138139
/**
139140
* An import path expression that may be transformed by `babel-plugin-root-import`.
140141
*/
141-
private class BabelRootTransformedPathExpr extends PathExpr, Expr {
142+
deprecated private class BabelRootTransformedPathExpr extends PathExpr, Expr {
142143
RootImportConfig plugin;
143144
string prefix;
144145
string mappedPrefix;
@@ -166,7 +167,7 @@ module Babel {
166167
/**
167168
* An import path transformed by `babel-plugin-root-import`.
168169
*/
169-
private class BabelRootTransformedPath extends PathString {
170+
deprecated private class BabelRootTransformedPath extends PathString {
170171
BabelRootTransformedPathExpr pathExpr;
171172

172173
BabelRootTransformedPath() { this = pathExpr.getValue() }
@@ -202,4 +203,12 @@ module Babel {
202203
)
203204
}
204205
}
206+
207+
private class BabelPathMapping extends PathMapping, RootImportConfig {
208+
override File getAnAffectedFile() { result = this.getConfig().getAContainerInScope() }
209+
210+
override predicate hasPrefixPathMapping(string pattern, Container newContext, string newPath) {
211+
newPath = this.getRoot(pattern) and newContext = this.getFolder()
212+
}
213+
}
205214
}

0 commit comments

Comments
 (0)