ITADN

fix: only cache filename lookup, not options

#466Pull Requestanomiex 创建于 2025-06-25
A
anomiexcommented
Presumably to avoid excessive stat calls, the return value of `normalizeOptions()` is cached for each input tsconfig file. But the return value also depends on the input `options`: eslint configuration may pass different options for the same tsconfig file. Instead, cache only the result of the `tryFile()` call. Fixes #465 <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Modify `normalizeOptions()` to cache only filename lookup, ensuring correct handling of different options for the same tsconfig file, and add tests for verification. > > - **Behavior**: > - Modify `normalizeOptions()` in `normalize-options.ts` to cache only the filename lookup, not the entire options object. > - Ensures different options for the same tsconfig file are handled correctly. > - **Tests**: > - Add `filesWithDifferentOptions` test case in `e2e.spec.ts.snap` to verify behavior with different file extensions. > - New test files `eslint.config.js`, `a.bar.js`, `a.foo.js`, `x.foo.js`, `y.bar.js` added under `tests/e2e/filesWithDifferentOptions/` to support the new test case. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=import-js%2Feslint-import-resolver-typescript&utm_source=github&utm_medium=referral)<sup> for 614f3b2dfcb27dc640766d3579144ed947b51b1e. You can [customize](https://app.ellipsis.dev/import-js/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Enhanced caching to accurately differentiate option sets, improving import resolution reliability. - **Tests** - Added test files and ESLint configurations to validate import resolution for `.foo.js` and `.bar.js` extensions. - Included sample modules to support these new test scenarios. - **Chores** - Added a changeset documenting the patch update and its impact. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
合并状态:未合并 5 条评论