JavaScript: Ignore outDirs that would exclude everything#20030
Merged
Conversation
In #19680 we added support for automatically ignoring files in the `outDir` directory as specified in the TSconfig compiler options (as these files were likely duplicates of `.ts` file we were already scanning). However, in some cases people put `outDir: "."` or even `outDir: ".."` in their configuration, which had the side effect of excluding _all_ files, leading to a failed extraction. With the changes in this PR, we now ignore any `outDir`s that are not properly contained within the source root of the code being scanned. This should prevent the files from being extracted, while still allowing us to not double-scan files in, say, a `.github` directory, as seen in some Actions workflows.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where the JavaScript extractor would incorrectly exclude all source files when outDir in tsconfig.json points to the source root directory (.) or parent directory (..). The fix ensures that only outDir configurations that are proper subdirectories of the source root are used for file exclusion.
- Added validation to check if
outDiris properly contained within the source root before excluding files - Enhanced test coverage with two new test cases for edge cases with
outDirconfiguration - Updated change notes to document the fix
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java | Adds logic to validate outDir is a proper subdirectory before excluding files |
| javascript/extractor/test/com/semmle/js/extractor/test/AutoBuildTests.java | Adds test cases for outDir pointing to parent and source root directories |
| javascript/ql/lib/change-notes/2025-07-11-ignore-outdirs-that-would-exclude-everything.md | Documents the fix in release notes |
Napalys
previously approved these changes
Jul 11, 2025
Contributor
Author
That's a good idea. I'll add an extra test. (And assuming it doesn't reveal a bug in the implementation, I'll refrain from rerunning DCA as I'm only changing a test.) |
Napalys
approved these changes
Jul 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In #19680 we added support for automatically ignoring files in the
outDirdirectory as specified in the TSconfig compiler options (as these files were likely duplicates of.tsfile we were already scanning).However, in some cases people put
outDir: "."or evenoutDir: ".."in their configuration, which had the side effect of excluding all files, leading to a failed extraction.With the changes in this PR, we now ignore any
outDirs that are not properly contained within the source root of the code being scanned. This should prevent the files from being extracted, while still allowing us to not double-scan files in, say, a.githubdirectory, as seen in some Actions workflows.