Skip to content

fix(lint): revamp the noGlobalDirnameFilename rule to catch many false negatives#8922

Merged
siketyan merged 1 commit intobiomejs:mainfrom
siketyan:fix/GH-8829
Jan 31, 2026
Merged

fix(lint): revamp the noGlobalDirnameFilename rule to catch many false negatives#8922
siketyan merged 1 commit intobiomejs:mainfrom
siketyan:fix/GH-8829

Conversation

@siketyan
Copy link
Member

@siketyan siketyan commented Jan 31, 2026

Summary

Fixes #8829

The rule will now use JsReferenceIdentifier node to query all usages of __dirname and __filename in many locations.

Test Plan

Added snapshot tests from the issue.

Docs

N/A

@siketyan siketyan requested review from a team and unvalley January 31, 2026 07:03
@siketyan siketyan self-assigned this Jan 31, 2026
@changeset-bot
Copy link

changeset-bot bot commented Jan 31, 2026

🦋 Changeset detected

Latest commit: 5270d7a

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 Jan 31, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 31, 2026

Walkthrough

Refactors the noGlobalDirnameFilename lint rule to reduce false negatives. The implementation shifts from multi-variant node analysis to a single-path approach querying JsReferenceIdentifier directly. The rule now delegates identifier replacement logic to parent-struct checks (JsIdentifierExpression and JsShorthandPropertyObjectMember) and simplifies binding detection. A new test file verifies the rule behaves correctly across diverse usage patterns including concatenation, templates, operators, and JSX contexts.

Possibly related PRs

Suggested labels

A-Linter, L-JavaScript

Suggested reviewers

  • ematipico
  • dyc3
  • arendjr
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: revamping the noGlobalDirnameFilename rule to catch false negatives by querying JsReferenceIdentifier nodes.
Description check ✅ Passed The description clearly relates to the changeset, explaining the rule change to use JsReferenceIdentifier and referencing the issue being fixed with added test coverage.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 31, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing siketyan:fix/GH-8829 (5270d7a) with main (7c96517)

Summary

✅ 58 untouched benchmarks
⏩ 95 skipped benchmarks1

Footnotes

  1. 95 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Great glow up

@siketyan siketyan merged commit 871b45e into biomejs:main Jan 31, 2026
19 checks passed
@github-actions github-actions bot mentioned this pull request Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 noGlobalDirnameFilename doesn't work in most scenarios (false negatives)

2 participants