Skip to content

Conversation

@rjmunro
Copy link
Contributor

@rjmunro rjmunro commented Jan 8, 2026

About the Contributor

Type of Contribution

This is a CI improvement

Current Behavior

image

New Behavior

image

This would have saved me loads of time if it existed before as the exact error was very unclear to me from the initial message, especially as I had confusion over the line numbers and locally the error didn't reproduce straight away.

Testing

CI only. I've tested it by branching this PR from a broken point.

Affected areas

This affects CI.

Time Frame

  • Not urgent, but we would like to get this merged into the in-development release.

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

Summary

This pull request modifies the GitHub Actions workflow to improve lint error handling in the package matrix job. The changes introduce automatic lint error fixing with visual diff output.

Changes Made

File: .github/workflows/node.yaml

The lint-packages job's linting step has been updated to:

  1. Run yarn lint --fix to automatically apply fixable lint corrections
  2. Use git diff --exit-code . to display any remaining changes as a diff
  3. Fail the CI job with an explicit error message if lint errors persist after auto-fixing

The diff is scoped to the current package directory (.) rather than the entire repository, preventing false failures caused by unrelated changes to files like packages/.yarnrc.yml that may be modified during CI setup.

Impact

This change enables developers to see exactly which lint errors were detected and which fixes were applied, improving the debugging experience when lint checks fail. The auto-fix capability reduces friction by handling simple style corrections automatically, while still catching unfixable or semantic issues that require manual intervention.

@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

Walkthrough

The lint step in the Node.js workflow now executes yarn lint --fix and verifies via git diff whether fixes were applied, failing the job if linting corrections were necessary.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
\.github/workflows/node\.yaml
Modified lint step to run yarn lint --fix and check for uncommitted changes using git diff exit code; job fails if lint fixes are required

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A linting hop through the workflow so bright,
Where fixes are caught in the automation's light,
No sloppy code sneaks past the gate,
The rabbit ensures all code stays straight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and specifically describes the main change: showing lint errors as diffs when they are fixable, which aligns with the commit messages and workflow modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This prevents failing on packages/.yarnrc.yml which is edited on CI
for unrelated reasons.
@rjmunro rjmunro force-pushed the rjmunro/show-lint-diff branch from 63dd837 to 4f609ea Compare January 8, 2026 12:55
@rjmunro
Copy link
Contributor Author

rjmunro commented Jan 8, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/workflows/node.yaml:
- Around line 476-477: Replace the current post-lint check that only runs "git
diff --exit-code ." with a step that captures and prints the diff before
failing: run a git diff (or git --no-pager diff) to store the patch output and
echo it to the job log when non-empty, then exit with a non-zero code; update
the failing command (the line using "git diff --exit-code . || (echo ... && exit
1)") to instead run the diff, print the diff content with a clear header (e.g.,
"Lint changes:"), and then exit 1 if the diff is non-empty so developers can see
exactly what yarn lint --fix changed.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aba5ed4 and 4f609ea.

📒 Files selected for processing (1)
  • .github/workflows/node.yaml

Comment on lines +476 to +477
yarn lint --fix
git diff --exit-code . || (echo "Lint errors found in package ${{ matrix.package-name }}" && exit 1)
Copy link

@coderabbitai coderabbitai bot Jan 8, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

The diff is not actually displayed to developers.

The PR title states "Show lint errors as diff if they are fixable," but git diff --exit-code . only checks whether files changed—it doesn't display the diff to developers. When this check fails, developers will see a generic error message but won't know what changes the linter made, requiring them to run yarn lint --fix locally to discover the issues.

Consider capturing and displaying the diff in the CI output before failing:

📋 Proposed fix to display the diff
-          yarn lint --fix
-          git diff --exit-code . || (echo "Lint errors found in package ${{ matrix.package-name }}" && exit 1)
+          yarn lint --fix
+          if ! git diff --exit-code .; then
+            echo "Lint errors found in package ${{ matrix.package-name }}. The following changes would be applied:"
+            git diff .
+            exit 1
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
yarn lint --fix
git diff --exit-code . || (echo "Lint errors found in package ${{ matrix.package-name }}" && exit 1)
yarn lint --fix
if ! git diff --exit-code .; then
echo "Lint errors found in package ${{ matrix.package-name }}. The following changes would be applied:"
git diff .
exit 1
fi
🤖 Prompt for AI Agents
In @.github/workflows/node.yaml around lines 476 - 477, Replace the current
post-lint check that only runs "git diff --exit-code ." with a step that
captures and prints the diff before failing: run a git diff (or git --no-pager
diff) to store the patch output and echo it to the job log when non-empty, then
exit with a non-zero code; update the failing command (the line using "git diff
--exit-code . || (echo ... && exit 1)") to instead run the diff, print the diff
content with a clear header (e.g., "Lint changes:"), and then exit 1 if the diff
is non-empty so developers can see exactly what yarn lint --fix changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does display the diff. It's confusing git diff --exit-code which shows the diff as normal but also sets an exit code, and git diff --quiet, which sets the exit code and hides the diff. You can see it works from the screenshots.

Copy link

Choose a reason for hiding this comment

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

@rjmunro, you're absolutely right—I apologize for the confusion! git diff --exit-code does indeed display the diff output while also setting a non-zero exit code when differences exist. I mistakenly conflated it with git diff --quiet, which suppresses output.

Your implementation is correct as-is and will show developers exactly what lint changes were made before failing the CI job. Thank you for the clarification and for catching my error!

🐰💡
((
( -.-)
o_(")(")
learning moment

@rjmunro rjmunro marked this pull request as ready for review January 8, 2026 15:09
@rjmunro rjmunro requested a review from a team as a code owner January 8, 2026 15:09
Copy link
Member

@nytamin nytamin left a comment

Choose a reason for hiding this comment

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

Looks like a useful improvement! Personally, I'd like to still have the original error output to the log, but perhaps something like this achieves both?
(disclaimer; I haven't tested this)

# First run `yarn lint` to output any lint errors to console
# If there are any, run `yarn lint --fix` and `git diff` to output more helpful info to the console.
yarn lint || (yarn lint --fix; git diff --exit-code . || (echo "Lint errors found in package ${{ matrix.package
-name }}" && exit 1))

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.

2 participants