Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Blank line preservation

オープン
#7 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript, typescript
領域
tooling

調査の方向性

ファイル、テスト、エントリーポイントは指定されていないため、まずノードの文字列化とコード移動の API を見つけてください。spaceBefore と spaceAfter が空行、コメント、行頭の改行、インデントをどのように表現するかを定義してテストし、toString(true) がそれらを含むかどうかを判断してください。

索引モデルが issue の本文から書いたものです。

説明

enhancement

When moving a block of code, you can use toString on each node and "paste" the result by using the appropriate method. There needs to be a way to preserve blank lines between nodes, so we can preserve the author's style.

The first idea that comes to mind is a method that returns a string containing only newlines (and maybe indentation?) corresponding to the number of blank lines before or after the node (so two variants). This string can then be "pasted" just like the toString result.

As an example:

foo()

// comment 1
bar()

// comment 2
foo()

Assume the bar() expression is represented by node:

node.spaceBefore() // => "\n\n// comment 1\n"
node.toString()    // => "bar()"
node.spaceAfter()  // => "\n\n\n// comment 2\n"

In the above example, the \n that begins bar()'s line is included in the spaceBefore result. And the \n that begins the line after that is included in the spaceAfter result. I'm not certain, but I think that's the expected behavior.

I'm also undecided if indentation should be included or not. I'm leaning towards no, because toString currently strips indentation and we should match that behavior.

Another thing: maybe toString(true) can include the result of spaceAfter (and even the result of spaceBefore if we're the first sibling of a BlockStatement) to make things easier?

These decisions could easily be a source of many bugs if we aren't careful.

主要言語
TypeScript
スター
16
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

alloc/nebu のほかの issue

alloc/nebu の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。