#!/usr/bin/env bash # Lint + typecheck subcommands. # # Split out of dev.sh (previously 546L). Each per-language lint is # independently callable (`./run lint:gd`, `lint:rust`, `lint:ts`) or via # the umbrella `./run lint` which runs all three and aggregates exit codes. # Apply project-local gdlintrc — load-bearing before every gdlint call. # lilith-gdtoolkit-sync keeps resetting gdlintrc to defaults; this restores # the project carveouts (GDExtension wrapper method counts, signal handler # signatures, etc.). Also ensures the config-drift check is run first. _gd_prep_lint() { lilith-gdtoolkit-sync --check || { echo -e "${YELLOW}Config drift detected — syncing...${NC}" lilith-gdtoolkit-sync } cp "$REPO_ROOT/.project/gdlintrc.local" "$REPO_ROOT/gdlintrc" 2>/dev/null || true } cmd_lint_gd() { local exit_code=0 echo -e "${BLUE}GDScript lint (gdlint + gdformat --check)...${NC}" _gd_prep_lint gdlint "$GAME_DIR/engine/src/" || exit_code=$? gdformat --check "$GAME_DIR/engine/src/" || exit_code=$? return $exit_code } cmd_lint_rust() { local exit_code=0 echo -e "${BLUE}Rust lint (fmt --check + clippy + machete)...${NC}" (cd "$SIMULATOR_DIR" && cargo fmt --check --all) || exit_code=$? (cd "$SIMULATOR_DIR" && cargo clippy --workspace --all-targets -- -D warnings) || exit_code=$? if _have_tool cargo-machete "cargo install cargo-machete"; then (cd "$SIMULATOR_DIR" && cargo machete) || exit_code=$? fi return $exit_code } cmd_lint_ts() { local exit_code=0 echo -e "${BLUE}TypeScript lint (ESLint + tsc typecheck)...${NC}" pnpm --prefix "$GUIDE_DIR" lint || exit_code=$? pnpm -r typecheck || exit_code=$? return $exit_code } cmd_lint() { local exit_code=0 echo -e "${BLUE}[1/3] GDScript lint${NC}" cmd_lint_gd || exit_code=$? echo "" echo -e "${BLUE}[2/3] Rust lint${NC}" cmd_lint_rust || exit_code=$? echo "" echo -e "${BLUE}[3/3] TypeScript lint${NC}" cmd_lint_ts || exit_code=$? return $exit_code } cmd_typecheck() { echo -e "${BLUE}TypeScript typecheck (pnpm -r typecheck)...${NC}" pnpm -r typecheck }