missing-onready --fix writes @onready @export, and misses @onready above a comment

Đang mở Phù hợp với người mới
#100 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@mafujahmedridoy22-commits đang làm issue này rồi.

Từ ngày 14/11/2026.

  • #137 của @mafujahmedridoy22-commits — đang mở
  • #138 của @vortsghost2025 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu với src/lint/rules/missing-onready.ts và kiểm tra hasOnready cùng logic phát hiện và sửa lỗi; sau đó đọc các trường hợp liên quan trong test/fixes.test.ts và test/rules.test.ts. Chạy npm run build && npm test như được liệt kê trong issue. Công việc hoàn tất khi các chú thích giữa @onready và var được xử lý, các khai báo được export không nhận bản sửa và vẫn giống hệt từng byte, còn các khai báo thông thường vẫn được sửa.

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

Mô tả

bug good first issue severity: medium

Summary

The machine-applicable fix for missing-onready writes wrong code in two cases. gdcorrect lint --fix writes it to user files.

  1. On an exported member, @export var x: Node = $X becomes @onready @export var x: Node = $X. Godot warns on @onready combined with @export (ONREADY_WITH_EXPORT). The initializer then runs after the inspector value is applied and overwrites it, so the designer's assignment is silently lost. A test currently asserts this rewrite as correct.
  2. When a comment sits between a standalone @onready line and the var, the rule does not see the annotation. It reports a false positive, and --fix adds a second @onready.

Where

  • src/lint/rules/missing-onready.ts:29 (hasOnready: the previousNamedSibling walk stops at the first comment node)
  • src/lint/rules/missing-onready.ts:42-55 (finding and fix are emitted regardless of @export* annotations)
  • test/fixes.test.ts:24-29 (expects @onready @export var other: Node = $Other)

Details

@onready
# the player sprite
var a: Node = $A          # flagged; --fix -> "@onready var a ..." (second @onready)

@export var c: Node = $C  # --fix -> "@onready @export var c ..."

Tree-sitter comments are named nodes, so s.type === "annotation" || s.type === "annotations" ends the loop at the comment.

Impact

--fix is described as applying only machine-applicable fixes. Here it changes runtime behaviour (exported values overwritten at _ready) or produces a redundant annotation, in files the user did not review.

Steps to reproduce

  1. Put either snippet above in a project script.
  2. Run gdcorrect lint <project> --fix, then inspect the file.

Suggested fix

  • In hasOnready, skip comment siblings while walking backwards.
  • When the declaration carries any @export* annotation, attach no fix. Either keep the finding with a message suggesting an exported NodePath or no initializer, or skip it.
  • Update test/fixes.test.ts to expect no fix for exported members.

Acceptance criteria

  • @onready / comment / var a = $A is not flagged.
  • @export var n: Node = $N and @export_* variants have no fix, and --fix leaves those lines byte-identical.
  • Plain var n: Node = $N is still fixed.

Getting started

  • Relevant files: src/lint/rules/missing-onready.ts, test/fixes.test.ts, test/rules.test.ts
  • How to run tests: npm run build && npm test

Filed by repo-audit/full-audit at e836036. Severity: medium. Effort: S. audit-key: bug|src/lint/rules/missing-onready.ts|missingOnready.fix

Ngôn ngữ chính
TypeScript
Star
0
Fork
6
Merge trung bình
1 ngày 21 giờ
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

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.

Issue khác của TMHSDigital/godot-correctness-mcp

Tất cả issue của TMHSDigital/godot-correctness-mcp

Issue tương tự

Thêm issue về TypeScript

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.