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

Offen Anfängerfreundlich
#100 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

@mafujahmedridoy22-commits arbeitet bereits daran.

Seit 14.11.2026.

  • #137 von @mafujahmedridoy22-commits — offen
  • #138 von @vortsghost2025 — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
88/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
tooling

Rechercherichtung

Beginne mit src/lint/rules/missing-onready.ts und untersuche hasOnready sowie die Logik für Meldungen und Korrekturen; lies anschließend die zugehörigen Fälle in test/fixes.test.ts und test/rules.test.ts. Führe npm run build && npm test wie im Issue aufgeführt aus. Fertig ist die Aufgabe, wenn Kommentare zwischen @onready und var verarbeitet werden, exportierte Deklarationen keine Korrektur erhalten und byte-identisch bleiben und einfache Deklarationen weiterhin korrigiert werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
TypeScript
Sterne
0
Forks
6
Ø Merge
1 T. 21 Std.
Gemergte PRs (30 T.)
8

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus TMHSDigital/godot-correctness-mcp

Alle Issues in TMHSDigital/godot-correctness-mcp

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.