mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
JS: Implement babel-plugin-root-import as a PathMapping
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import javascript
|
||||
private import semmle.javascript.internal.paths.PathMapping
|
||||
|
||||
module Babel {
|
||||
/**
|
||||
@@ -202,4 +203,12 @@ module Babel {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private class BabelPathMapping extends PathMapping, RootImportConfig {
|
||||
override File getAnAffectedFile() { result = this.getConfig().getAContainerInScope() }
|
||||
|
||||
override predicate hasPrefixPathMapping(string pattern, Container newContext, string newPath) {
|
||||
newPath = this.getRoot(pattern) and newContext = this.getFolder()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
import f from '~/a'; // $ MISSING: importTarget=BabelRootImport/tst1/a.js
|
||||
import f from '~/a'; // $ importTarget=BabelRootImport/tst1/a.js
|
||||
|
||||
@@ -1 +1 @@
|
||||
import f from '~/a'; // $ MISSING: importTarget=BabelRootImport/tst1/a.js
|
||||
import f from '~/a'; // $ importTarget=BabelRootImport/tst1/a.js
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
import g from '~/b.js'; // $ MISSING: importTarget=BabelRootImport/tst2/src/js/b.js
|
||||
import f from '#/a'; // $ MISSING: importTarget=BabelRootImport/tst1/a.js
|
||||
import g from '~/b.js'; // $ importTarget=BabelRootImport/tst2/src/js/b.js
|
||||
import f from '#/a'; // $ importTarget=BabelRootImport/tst1/a.js
|
||||
|
||||
@@ -1 +1 @@
|
||||
import greeting from '~/b.js'; // $ MISSING: importTarget=BabelRootImport/tst3/src/b.js
|
||||
import greeting from '~/b.js'; // $ importTarget=BabelRootImport/tst3/src/b.js
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
import g from '~/b.js'; // $ MISSING: importTarget=BabelRootImport/tst4/src/js/b.js
|
||||
import f from '#/a'; // $ MISSING: importTarget=BabelRootImport/tst1/a.js
|
||||
import g from '~/b.js'; // $ importTarget=BabelRootImport/tst4/src/js/b.js
|
||||
import f from '#/a'; // $ importTarget=BabelRootImport/tst1/a.js
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
| BabelRootImport/tst1/index.js:1:1:1:20 | import f from '~/a'; | BabelRootImport/tst1/a.js |
|
||||
| BabelRootImport/tst1/nested/tst.js:1:1:1:20 | import f from '~/a'; | BabelRootImport/tst1/a.js |
|
||||
| BabelRootImport/tst2/index.js:1:1:1:23 | import ... /b.js'; | BabelRootImport/tst2/src/js/b.js |
|
||||
| BabelRootImport/tst2/index.js:2:1:2:20 | import f from '#/a'; | BabelRootImport/tst1/a.js |
|
||||
| BabelRootImport/tst3/index.js:1:1:1:30 | import ... /b.js'; | BabelRootImport/tst3/src/b.js |
|
||||
| BabelRootImport/tst4/index.js:1:1:1:23 | import ... /b.js'; | BabelRootImport/tst4/src/js/b.js |
|
||||
| BabelRootImport/tst4/index.js:2:1:2:20 | import f from '#/a'; | BabelRootImport/tst1/a.js |
|
||||
| BaseUrl/src/main.ts:2:1:2:26 | import ... /file"; | BaseUrl/base/lib/file.ts |
|
||||
| BaseUrl/src/main.ts:3:1:3:29 | import ... le.ts"; | BaseUrl/base/lib/file.ts |
|
||||
| BaseUrl/src/main.ts:4:1:4:29 | import ... le.js"; | BaseUrl/base/lib/file.ts |
|
||||
|
||||
Reference in New Issue
Block a user