prettier / prettier/plugin-php

Prettier duplicates a comment and inserts it somewhere else

Đang mở
#2,495 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
PHP
Star
1.9k
Fork
139
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

@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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện vấn đề từ các liên kết Playground được cung cấp và so sánh đầu ra của formatter với đầu vào, đặc biệt là các comment PHP gần else và endif. Theo dõi đường đi xử lý comment của plugin-php; được xem là hoàn tất khi các comment không bị nhân đôi hoặc di chuyển, dù khối PHP bao quanh đang hiện diện hay bị loại bỏ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
php
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.