microsoft / microsoft/TypeScript
Allow to specify import sorting.
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
Typescript has this long running issue full of complaints about how there's no way to prefer certain import paths over others, and in any non-trivially sized application, path aliasing is bound to clash with the various library imports available (hence the practice of having a path alias @/ to get at all first-party application imports).
https://github.com/microsoft/TypeScript/issues/51155
A plugin was suggested multiple times in the above issue, which has a very simple interface to configure around this: https://github.com/tidalhq/ts-plugin-sort-import-suggestions
I think this is something that should be included in tsgo itself, for two reasons:
- It's not just some fringe preference, everyone at some point will want to prefer certain import path prefixes over others
- It's an extremely simple thing to implement
I propose being able to add to tsconfig.json a configuration item like this:
{
"compilerOptions": {
"importSorting": {
// Matches `@/`, `../` and `./`, move them up in the suggestions (This is the default config if you leave it empty)
"moveUpPatterns": ["@/", "\\.{1,2}/"],
// Move `dist` down in the suggestions, by default it's `[]`
"moveDownPatterns": ["dist"],
]
},
}
This is a flexible and performant approach that will handle pretty much everyone's needs. I don't know why this was left to be a plugin when it's such a critical piece of an ergonomic Typescript-based development environment.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている TypeScript issue と ts-plugin-sort-import-suggestions インターフェースから始め、続いて tsgo の import suggestion の処理と tsconfig.json のオプション解析を見つけます。コンパイラーオプションが moveUpPatterns と moveDownPatterns を受け付け、import suggestion がそれらのパターンを反映し、提案された例を対象とするカバレッジがあれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- go, typescript
- 領域
- developer-experience, tooling
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100