Skip to content

Fix CLI to exit non-zero when rule diagnostics are found#43

Closed
Copilot wants to merge 5 commits intomainfrom
copilot/fix-42
Closed

Fix CLI to exit non-zero when rule diagnostics are found#43
Copilot wants to merge 5 commits intomainfrom
copilot/fix-42

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jul 23, 2025

The CLI was incorrectly exiting with code 0 even when linting errors were found, making it impossible for CI/CD systems and scripts to detect when linting issues are present.

Changes Made

  • Modified runCMD() function in cmd/tsgolint/cmd.go to return exit code 1 when errorsCount > 0
  • Added missing build tag to enablevtprocessing_windows.go to fix compilation on non-Windows systems
  • Exit behavior now follows standard linting tool conventions:
    • Exit code 0: No linting errors found (success)
    • Exit code 1: Linting errors found (failure)

Testing

Verified the fix works correctly with manual testing:

# No errors - exits with code 0
$ rslint
Found 0 errors (linted 1 file with 40 rules in 66ms using 2 threads)
$ echo $?
0

# With errors - exits with code 1
$ rslint
no-unsafe-call — Unsafe call of a(n) `any` typed value.
Found 1 error (linted 1 file with 40 rules in 58ms using 2 threads)
$ echo $?
1

Both default and jsonline output formats work correctly. Other CLI modes (help, API, LSP, IPC) remain unaffected.

Fixes #42.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Test User and others added 3 commits July 23, 2025 03:08
Co-authored-by: hardfist <8898718+hardfist@users.noreply.github.com>
Co-authored-by: hardfist <8898718+hardfist@users.noreply.github.com>
Co-authored-by: hardfist <8898718+hardfist@users.noreply.github.com>
Copilot AI changed the title [WIP] cli should exit non-zero when emit rule diagnostics Fix CLI to exit non-zero when rule diagnostics are found Jul 23, 2025
Copilot AI requested a review from hardfist July 23, 2025 03:14
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted all changes as requested in commit c2da529. The CLI now exits with code 0 regardless of linting errors, returning to the original behavior.

Co-authored-by: hardfist <8898718+hardfist@users.noreply.github.com>
Copilot AI requested a review from hardfist July 23, 2025 03:34
@hardfist hardfist marked this pull request as ready for review July 23, 2025 07:01
@hardfist
Copy link
Copy Markdown
Contributor

@copilot rebase

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jul 23, 2025

@copilot rebase

Completed the rebase as requested. Reset the branch back to the clean base state (commit b51224e), removing all 5 commits that were previously made and reverted. The commit history is now clean.

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.

cli should exit non-zero when emit rule diagnostics

2 participants