microsoft / microsoft/TypeScript
Formatter: indent second operand of intersection operator on next line one indent more
オープン
まだ誰も着手していません。
Awaiting More Feedback
Domain: Formatter
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
I use "vscode.typescript-language-features" as my default JS/TS formatter, and when formatting long lines, the indentation could be improved.
As an example, this is the resulting code after "vscode.typescript-language-features":
const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants> // <= This line isn't sufficiently indented.
>(({ className, ...props }, ref) => (
<LabelPrimitive.Root
className={cn(labelVariants(), className)}
ref={ref}
{...props}
/>
));
Please note that the 4th line isn't indented deeper.
What would be visually clearer would be:
const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants> // <= This line indented deeper.
>(({ className, ...props }, ref) => (
<LabelPrimitive.Root
className={cn(labelVariants(), className)}
ref={ref}
{...props}
/>
));
Is there a way to wrap them in a way that the result looks like the second snippet?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue の TypeScript/JavaScript 例を使って formatter の出力を再現し、その後、複数行の型の intersection がどのようにフォーマットされるかを追跡します。現在のインデントと要求されたインデントを比較し、示されているケースのカバレッジを追加します。完了の条件は、関係のないフォーマットを変更せずに、2 番目のオペランドが 1 レベル深くインデントされることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100