JS-769 Restrict nested node_modules lookups and remove ruling node_modules cleanup#6636
JS-769 Restrict nested node_modules lookups and remove ruling node_modules cleanup#6636
Conversation
SummaryReplace global node_modules cleanup with surgical compiler-host filtering. Instead of deleting the project's root node_modules in test setup (which is a CI workaround), the compiler host now intelligently guards lookups: it skips node_modules reads outside the analyzed baseDir, while allowing them inside baseDir and for TypeScript's default libraries. This eliminates the crude CI cleanup and makes module resolution behavior explicit and testable. What reviewers should knowStart with the
|
Ruling Report✅ No changes to ruling expected issues in this PR |
| expect(cache.get(normalizeToAbsolutePath('/project/src/index.ts'))).toBe(content); | ||
| }); | ||
|
|
||
| it('should not skip node_modules reads nested under baseDir', () => { |
There was a problem hiding this comment.
The skip behaviour introduced by this PR is only verified positively for fileExists (the "should skip node_modules lookups outside baseDir" test at line 234). readFile and getSourceFile each have a "should not skip" test but no complementary "should skip" test. If the shouldSkipNodeModulesOutsideBaseDir guard were accidentally removed from either method, nothing here would catch it. Add one test per method asserting that calling readFile/getSourceFile with /external/node_modules/pkg/index.d.ts triggers the skip op and returns undefined.
- Mark as noise
|
vdiez
left a comment
There was a problem hiding this comment.
can we get rid of the symlink creation for jsts ruling?




Summary
normalizeToAbsolutePath(..., baseDir)readDirectoryfornode_modulespaths outside the analyzedbaseDirnode_moduleslookups underbaseDirallowedcleanRootNodeModules()from ruling IT setup (RulingTest)readDirectoryonlyValidation
npx tsx --tsconfig packages/tsconfig.test.json --test packages/jsts/tests/program/compilerHost.test.tsnpx tsx --tsconfig packages/tsconfig.test.json --test packages/jsts/tests/program/*.test.ts