prettier / prettier/plugin-php
Prettier duplicates a comment and inserts it somewhere else
オープン
まだ誰も着手していません。
- 主要言語
- PHP
- スター
- 1.9k
- フォーク
- 139
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
@prettier/plugin-php v0.25.0
Playground link
Input:
<?php if (have_posts()): ?>
<p>Content if have posts</p>
<?php
/* My comment */
?>
<?php
// Comment in else
// Another comment
// Comment number three
else: ?>
<?php if (true): ?>
<p>This is always true</p>
<?php endif;
// end true check
?>
<?php endif;
// end have_posts() check
?>
Output:
<?php if (have_posts()): ?>
<p>Content if have posts</p>
<?php
/* My comment */
?>
<?php
// Comment in else
// Another comment
// Comment number three
// end true check
else: ?>
<?php if (true): ?>
<p>This is always true</p>
<?php endif;
// end true check
?>
<?php endif;
// end have_posts() check
?>
Notice that the //end true check comment is inserted next to the comments near the else statement.
However, a weirder things happen when I delete the entire /* My comment */ PHP block:
@prettier/plugin-php v0.25.0
Playground link
Input:
<?php if (have_posts()): ?>
<p>Content if have posts</p>
<?php
// Comment in else
// Another comment
// Comment number three
else: ?>
<?php if (true): ?>
<p>This is always true</p>
<?php endif;
// end true check
?>
<?php endif;
// end have_posts() check
?>
Output:
<?php if (have_posts()): ?>
<p>Content if have posts</p>
<?php
// Comment in else
// Another comment
// Comment number three
// end true check
// Comment in else
// Another comment
// Comment number three
// end true check
else: ?>
<?php if (true): ?>
<p>This is always true</p>
<?php endif;
// end true check
?>
<?php endif;
// end have_posts() check
?>
Multiple comments get duplicated
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された Playground リンクから問題を再現し、formatter の出力を入力と比較します。特に、else と endif 付近の PHP コメントを確認してください。plugin-php のコメント処理経路を追跡します。周囲の PHP ブロックが存在する場合でも削除された場合でも、コメントが重複も移動もしなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 55/100