35 lines
1.6 KiB
YAML
35 lines
1.6 KiB
YAML
|
|
apiVersion: conventions/v1
|
||
|
|
version: 0.1.0
|
||
|
|
updated: "2026-06-29"
|
||
|
|
name: code_standards
|
||
|
|
title: GDScript code standards
|
||
|
|
scope: gd
|
||
|
|
status: active
|
||
|
|
summary: Explicit static types everywhere, specific node types, EventBus for cross-system signals, scenes as skeletons, SRP scripts, observable errors. From v2 magic-civilization.
|
||
|
|
appliesTo: ["**/*.gd"]
|
||
|
|
rules:
|
||
|
|
- id: explicit_types
|
||
|
|
level: must
|
||
|
|
text: "Explicit type on every var (`var x: Type`); no bare `var x = v`, no inferred `:=`, no `Variant` escapes (except a typed EventBus payload)."
|
||
|
|
- id: specific_types
|
||
|
|
level: must
|
||
|
|
text: Use the specific type (`Node3D`, `AudioStreamPlayer`), never the general (`Node`). Typed arrays always (`Array[String]`, never bare `Array`).
|
||
|
|
- id: typed_signatures
|
||
|
|
level: must
|
||
|
|
text: Every function has typed params and a return type (`-> void` when none).
|
||
|
|
- id: refcounted_for_logic
|
||
|
|
level: should
|
||
|
|
text: "`RefCounted` for pure logic; `Node` only for scene-tree lifecycle. One script = one responsibility (no God Nodes)."
|
||
|
|
- id: signals
|
||
|
|
level: must
|
||
|
|
text: Cross-system communication goes through the EventBus autoload only; intra-tree parent↔child direct signals are fine.
|
||
|
|
- id: scenes_skeleton
|
||
|
|
level: should
|
||
|
|
text: ".tscn is structure/skeleton only; behavior is attached/wired at runtime in _ready()."
|
||
|
|
- id: observable_errors
|
||
|
|
level: must
|
||
|
|
text: "push_error()/push_warning() on failure paths; never silent returns or empty error handlers. Safe-cast with null check + log on mismatch."
|
||
|
|
- id: no_dead_code
|
||
|
|
level: must
|
||
|
|
text: "No `# TODO`, no `# gdlint:ignore`, no unused vars."
|