Merge pull request #5586 from asgerf/js/tsconfig-file-inclusion-handling

Approved by esbena
This commit is contained in:
CodeQL CI
2021-04-09 02:50:51 -07:00
committed by GitHub
14 changed files with 44 additions and 12 deletions

View File

@@ -0,0 +1,5 @@
lgtm,codescanning
* Fixed a bug which caused some imports to be resolved incorrectly
for projects containing multiple `tsconfig.json` files.
* Fixed a bug which could cause some files in the `node_modules` folder
to be extracted even though they should be excluded.

View File

@@ -21,7 +21,7 @@ public class ParsedProject {
/** Absolute paths to the files included in this project. */
public Set<File> getOwnFiles() {
return allFiles;
return ownFiles;
}
/** Absolute paths to the files included in or referenced by this project. */

View File

@@ -0,0 +1,15 @@
/**
* @name Import graph
* @description An edge in the import graph.
* @kind problem
* @problem.severity recommendation
* @id js/meta/alerts/import-graph
* @tags meta
* @precision very-low
*/
import javascript
from Import imprt, Module target
where target = imprt.getImportedModule()
select imprt, "Import targeting $@", target, target.getFile().getRelativePath()

View File

@@ -0,0 +1 @@
import { Foo } from "../B/src/foo";

View File

@@ -0,0 +1,3 @@
{
"include": ["."]
}

View File

@@ -0,0 +1,3 @@
import { Bar } from "lib/bar";
export class Foo {}

View File

@@ -0,0 +1,3 @@
import { Foo } from "foo";
export class Bar {}

View File

@@ -0,0 +1,6 @@
{
"include": ["."],
"compilerOptions": {
"baseUrl": "./src"
}
}

View File

@@ -0,0 +1,3 @@
| A/index.ts:1:1:1:35 | import ... c/foo"; | B/src/foo.ts:1:1:4:0 | <toplevel> |
| B/src/foo.ts:1:1:1:30 | import ... b/bar"; | B/src/lib/bar.ts:1:1:4:0 | <toplevel> |
| B/src/lib/bar.ts:1:1:1:26 | import ... "foo"; | B/src/foo.ts:1:1:4:0 | <toplevel> |

View File

@@ -0,0 +1,3 @@
import javascript
query Module getImportedModule(Import imprt) { result = imprt.getImportedModule() }

View File

@@ -0,0 +1 @@
{}

View File

@@ -2,11 +2,3 @@
| bar.ts:1:10:1:10 | A | any |
| bar.ts:1:19:1:29 | "@blah/foo" | any |
| bar.ts:3:5:3:5 | x | any |
| node_modules/@blah/foo/index.d.ts:1:8:1:15 | FooArray | typeof FooArray in library-tests/TypeScript/RegressionTests/ImportSelf/node_modules/@blah/foo/index.d.ts |
| node_modules/@blah/foo/index.d.ts:1:20:1:20 | A | any |
| node_modules/@blah/foo/index.d.ts:1:20:1:20 | A | any |
| node_modules/@blah/foo/index.d.ts:1:29:1:39 | '@blah/foo' | any |
| node_modules/@blah/foo/index.d.ts:3:11:3:18 | FooArray | typeof FooArray in library-tests/TypeScript/RegressionTests/ImportSelf/node_modules/@blah/foo/index.d.ts |
| node_modules/@blah/foo/index.d.ts:4:12:4:15 | blah | () => void |
| node_modules/@blah/foo/index.d.ts:8:10:8:10 | A | any |
| node_modules/@blah/foo/index.d.ts:8:10:8:10 | A | any |

View File

@@ -1,4 +1,3 @@
| node_modules/@types/foo/index.d.ts:1:17:1:19 | foo | () => any |
| test.ts:1:10:1:12 | foo | () => any |
| test.ts:1:10:1:12 | foo | () => any |
| test.ts:1:21:1:25 | "foo" | any |

View File

@@ -15,8 +15,6 @@ browserObject
| electron.js:62:13:62:59 | new Bro ... 1500 }) |
| electron.js:63:3:63:5 | win |
| electron.js:65:18:65:20 | win |
| electronTs.d.ts:2:16:2:28 | BrowserWindow |
| electronTs.d.ts:3:16:3:26 | BrowserView |
| electronTs.ts:3:12:3:13 | bw |
| electronTs.ts:3:40:3:41 | bv |
| electronTs.ts:4:3:4:4 | bw |