Skip to content

fix: propagate linter exit code in rtk lint - #207

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

pszymkowiak merged 1 commit into
rtk-ai:masterfrom
polaminggkub-debug:fix/lint-exit-code-propagation

Conversation

@polaminggkub-debug

Copy link
Copy Markdown
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 <noreply@anthropic.com>
@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
Copy Markdown
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
heAdz0r added a commit to heAdz0r/rtk that referenced this pull request Feb 28, 2026
Upstream 0.22.2 sync (all previously missing fixes verified applied):
- fix(lint): propagate linter exit code (rtk-ai#207) — CI false-green fix
- feat: add rtk wc command for compact word/line/byte counts (rtk-ai#175)
- fix(playwright): JSON parser (specs layer) + binary resolution (rtk-ai#215)
- fix(grep): propagate rg exit codes 1/2 (rtk-ai#227)
- fix(git): branch creation not swallowed by list mode (rtk-ai#194)
- fix(git): support multiple -m flags in git commit (rtk-ai#202)
- fix(grep): BRE \| translation + strip -r flag (rtk-ai#206)
- fix(gh): smart markdown body filter for issue/pr view (rtk-ai#214)
- fix(gh): gh run view --log-failed flag passthrough (rtk-ai#159)
- feat(docker): docker compose support (rtk-ai#110)
- feat: hook audit mode (rtk-ai#151)
- feat: tee raw output to file (rtk-ai#134)

Version bump: 0.21.1-fork.19 → 0.22.2-fork.1

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
thehoff pushed a commit to thehoff/contextcrawler that referenced this pull request May 14, 2026
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 #185

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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