fix: lint comments after shebangs#3199
Merged
elijah-potter merged 1 commit intoAutomattic:masterfrom Apr 20, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes #962 by ensuring CommentMasker no longer drops an entire merged comment span when it begins with a shebang; instead it strips only the first-line shebang at the start of the file and continues linting subsequent comments.
Changes:
- Update
CommentMasker::create_maskto trim a leading first-line shebang (only whenspan.start == 0) rather than ignoring the entire merged span. - Add a regression fixture (
issue_962.sh) and corresponding test expectation to ensure comments after a shebang are linted.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| harper-comments/src/masker.rs | Adjusts masking logic to trim only the initial shebang line (if present at file start) while preserving linting of subsequent merged comment content. |
| harper-comments/tests/language_support_sources/issue_962.sh | Adds a shell script fixture reproducing the shebang+comment scenario from #962. |
| harper-comments/tests/language_support.rs | Registers the new fixture in the language support test suite with the expected lint count. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
elijah-potter
approved these changes
Apr 20, 2026
Collaborator
elijah-potter
left a comment
There was a problem hiding this comment.
This looks like a simple enough change to me. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclaimer: This PR was authored by an agent and reviewed against the reproduced issue and local test results.
Fixes #962.
Before this change,
CommentMaskerignored any merged comment span that started with a shebang. When tree-sitter merged the first-line shebang with the following comment block, the later comments were skipped too.This change only strips the first line of a real shebang at the start of the file, then keeps linting the rest of the merged comment span.
How I tested this:
cargo test -p harper-commentscargo run -q -p harper-cli -- lint /tmp/harper-962-with-shebang.sh --count --no-colorcargo run -q -p harper-cli -- lint /tmp/harper-962-no-shebang.sh --count --no-colorcargo run -q -p harper-cli -- lint /tmp/harper-962-fake-shebang.sh --count --no-color