Skip to content

feat(biome_analyzer): support shebang together with // biome-ignore-all file-level suppressions#6712

Merged
arendjr merged 9 commits intobiomejs:mainfrom
sterliakov:bugfix/gh-6595-shebang-suppressions
Jul 7, 2025
Merged

feat(biome_analyzer): support shebang together with // biome-ignore-all file-level suppressions#6712
arendjr merged 9 commits intobiomejs:mainfrom
sterliakov:bugfix/gh-6595-shebang-suppressions

Conversation

@sterliakov
Copy link
Copy Markdown
Contributor

@sterliakov sterliakov commented Jul 4, 2025

Summary

Fixes #6595.

Instead of comparing comment token range with 0, we can check whether it is only preceded by "special" tokens. I added a trait method to represent that, for now it only includes JS_SHEBANG. If necessary, this implementation can be easily extended in future to allow other non-trivial tokens.

While this might cause some counter-intuitive behavior if some lint rules applying to shebang (are there any such rules?) are silenced by a following // biome-ignore-all comment, IMO this is the case where practicality beats purity. There is obviously no way to place a comment before shebang. File-level suppressions are defined as comments that affect the whole file, so this should be fine.

Test Plan

Added testcases adapted from #6595 example, verified that the shebang example fails on current master and passes here. Added a test with preceding comment, it already passes on master - just added it for consistency.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jul 4, 2025

🦋 Changeset detected

Latest commit: 69eeb7e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Jul 4, 2025
@sterliakov sterliakov closed this Jul 4, 2025
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jul 4, 2025

CodSpeed Performance Report

Merging #6712 will not alter performance

Comparing sterliakov:bugfix/gh-6595-shebang-suppressions (69eeb7e) with main (2649ac6)

Summary

✅ 114 untouched benchmarks

@sterliakov sterliakov reopened this Jul 4, 2025
@github-actions github-actions Bot added A-Core Area: core A-Parser Area: parser labels Jul 4, 2025
Copy link
Copy Markdown
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

IMO this is the case where practicality beats purity. There is obviously no way to place a comment before shebang.

I agree with this wholeheartedly.

I actually didn't know we parsed shebangs. The tests look good to me, and they pass. Good work!

@sterliakov
Copy link
Copy Markdown
Contributor Author

I actually didn't know we parsed shebangs.

Well, TIL as well. I didn't know that JS supports shebangs at all - sounds like a weird feature for a language that's so unfit for building CLI aplications...

Copy link
Copy Markdown
Member

@chansuke chansuke left a comment

Choose a reason for hiding this comment

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

lgtm

Comment thread .changeset/afraid-coats-post.md Outdated
@arendjr arendjr merged commit 2649ac6 into biomejs:main Jul 7, 2025
28 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Core Area: core A-Linter Area: linter A-Parser Area: parser L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 Shebangs cannot be used with biome-ignore-all

4 participants