fix: resolve tsconfig paths correctly when baseUrl is absent / baseUrl未指定時のtsconfig pathsの解決を修正 - #198
Open
kota-shidara wants to merge 1 commit into
Conversation
TypeScript 7 removes baseUrl, so `paths` values become relative to tsconfig.json's directory instead (e.g. `"src/*": ["./src/*"]`). Previously the alias was used as-is in that case, leaving a leading `./` that broke matching against eslintrc module patterns. Now baseUrl defaults to "." and is always passed through path.join.
kota-shidara
commented
Aug 5, 2026
Comment on lines
35
to
39
| describe('should resolve tsconfig paths', () => { | ||
| [ | ||
| ['@/components/', 'components/', 'components/aaa/bbb'], | ||
| ['@/components', 'components', 'components/aaa/bbb'], | ||
| ['@/components/*', 'components/*', 'components/aaa/bbb'], |
Author
There was a problem hiding this comment.
[相談]
このテストに関して、消すべきかを迷いました。存在しても害ではないのですが、TypeScriptの仕様としてありえないものとなっているため、削除したほうがテストケースとしてはよさそうに思います。
pathに関するドキュメントで、baseUrlが存在しない場合は、tsconfigを起点とする相対pathを指すと書かれています。
また、baseUrlが存在しない状態で、このテストのように相対pathではない形で書くと、error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?のエラーが発生します。
よってこのテストの状態は現実的に起こり得ないと思っており、削除した方がよいのではないかと考えています。
このPRの中で行うのでもよいですし、別の方が良ければ(既存のテストが全て壊れていない安心感等もあったりすると思うので)、このままにしておこうと思います。
kota-shidara
marked this pull request as ready for review
August 5, 2026 06:07
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.
TypeScript 7以降に対応するための提案になります。よろしくお願いします!
背景
baseUrlが非推奨化され、TypeScript 7.0 では完全に廃止されるため、pathsはbaseUrlなしで書く必要があります。resolveImportPath.jsの現状の実装では、解決後のエイリアスに./が残ります。例:@/domains/foo→./src/domains/foo.eslintrcのmodule設定では./無しで書くため、./で解決されたものとマッチせず、該当エイリアスを使うimportに対してルールが機能しなくなっていました。具体的な再現例:
pathsの値に付いた./のせいで、このimportは./src/domains/payment/chargeCardと解決されます。moduleのisMatchはstartsWithで判定しますが、"./src/..."は"src/domains/payment"で始まらないためfalseとなり、違反として報告されませんでした。対応
./ は path.join が落とすため、解決結果が module 設定と同じ形式に揃います。./ のない既存の設定は結果が変わりません。
テスト
baseUrlなしでpathsの値に./が付くケースを追加しました。相談
コメントとして相談を記載しております!ご確認よろしくお願いします。
#198 (comment)