Skip to content

Comments

fix: propagate linter exit code in rtk lint#207

Merged
pszymkowiak merged 1 commit intortk-ai:masterfrom
polaminggkub-debug:fix/lint-exit-code-propagation
Feb 18, 2026
Merged

fix: propagate linter exit code in rtk lint#207
pszymkowiak merged 1 commit intortk-ai:masterfrom
polaminggkub-debug:fix/lint-exit-code-propagation

Conversation

@polaminggkub-debug
Copy link
Contributor

Summary

  • rtk lint was always returning exit code 0 regardless of the underlying linter's exit status
  • Now propagates the linter's actual exit code using !output.status.success() pattern
  • Handles both non-zero exit codes (ESLint 1/2, ruff, pylint, mypy) and signal termination (SIGINT/SIGTERM)

Root Cause

The run() function in lint_cmd.rs captured the exit code for tee output but never used it to set the process exit status — it always returned Ok(()) (exit 0).

Fix

Added 3 lines after tracking, matching the exact pattern used by every other RTK module (git, cargo, playwright, vitest, etc.):

if !output.status.success() {
    std::process::exit(output.status.code().unwrap_or(1));
}

Why !status.success() instead of exit_code != 0

Per Rust stdlib docs, ExitStatus::code() returns None when a process is terminated by signal. !success() correctly detects failure in all cases (non-zero exit AND signal termination), while != 0 depends on the unwrap_or fallback value.

Test plan

  • All 7 existing lint_cmd tests pass (cargo test lint_cmd)
  • Manual test: rtk lint npx eslint <file> --max-warnings=0 returns non-zero exit code
  • Verify: rtk lint npx eslint <clean-file> still returns exit code 0

Fixes #185

🤖 Generated with Claude Code

@polaminggkub-debug polaminggkub-debug force-pushed the fix/lint-exit-code-propagation branch 2 times, most recently from b0ff25c to cc0d6b0 Compare February 18, 2026 20:18
rtk lint was always returning exit code 0 regardless of the underlying
linter's exit status, causing false-green CI behavior when lint should fail.

Uses !output.status.success() pattern consistent with all other RTK modules,
which correctly handles both non-zero exit codes and signal termination.

Fixes rtk-ai#185

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@polaminggkub-debug polaminggkub-debug force-pushed the fix/lint-exit-code-propagation branch from cc0d6b0 to 513b7ef Compare February 18, 2026 20:21
@polaminggkub-debug
Copy link
Contributor Author

Note on CI validate failure: This is a pre-existing issue on master, not related to this PR.

The scripts/validate-docs.sh check fails because Cargo.toml is at version 0.22.0 but README.md, CLAUDE.md, and ARCHITECTURE.md still reference 0.20.1. This affects all PRs against master currently.

This PR only touches src/lint_cmd.rs (4 lines added).

@pszymkowiak pszymkowiak merged commit 8e826fc into rtk-ai:master Feb 18, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: rtk lint does not propagate ESLint non-zero exit code

2 participants