-
Notifications
You must be signed in to change notification settings - Fork 1.7k
JavaScript: Ignore outDir
s that would exclude everything
#20030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
JavaScript: Ignore outDir
s that would exclude everything
#20030
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
outDir
is properly contained within the source root before excluding files - Enhanced test coverage with two new test cases for edge cases with
outDir
configuration - 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be silly but would it make sense to also add a test case where outDir
would be someDir/../../
or similar?
Assuming the DCA
looks good and you don't think we need such test case
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.) |
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 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
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.