# biome correctness/noGlobalDirnameFilename: fix changes program behavior

Internal evidence sheet generated by fixhunt. Not an issue text. A human re-verifies, checks the duplicates
below, and writes the upstream report in their own words following the project's AI policy.

- Tool: biome 2.5.15
- Rule: correctness/noGlobalDirnameFilename (tool labels the fix: safe, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): program-bug, severity low. The program runs as an ES module where __filename is undefined, causing a ReferenceError before the fix. The rewrite to import.meta.filename is the documented equivalent for ES modules, so the behavior change stems from the module system environment, not a flaw in the fix itself.
- Program: minimized from 3 to 1 lines

## Reproducer

```js
const x = __filename /* inline note */;
```

## Commands

```sh
node prog.js
bunx @biomejs/biome lint --only=correctness/noGlobalDirnameFilename --write prog.js
node prog.js
```

## Observed

```
exit 1 → 0
stderr before: ReferenceError: __filename is not defined in ES module scope
stderr after: (none)
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:27:25.136956550 -0400
+++ fixed.js	2026-10-22 13:27:25.276958877 -0400
@@ -1 +1 @@
-const x = __filename /* inline note */;
+const x = import.meta.filename /* inline note */;
```

## Why the rewrite is not equivalent (model draft, verify before use)

The original `__filename` refers to a Node.js CommonJS variable unavailable in ES modules, causing a ReferenceError; replacing it with `import.meta.filename`, which provides the module’s file URL as a string, avoids that error but changes the value type from a filesystem path string to a URL string, altering runtime behavior for any code depending on the exact format or content of `x`. This substitution is not semantically equivalent because the two expressions produce different values despite both being defined.

## Upstream search

Queries: "noGlobalDirnameFilename fix", "__filename usage", "import.meta.filename replacement", "ES module global variable"

- related: https://github.com/biomejs/biome/issues/6670
  same rule area (global __filename/__dirname metavariables) but different construct (GritQL plugin metavariable not set)
- duplicate: https://github.com/biomejs/biome/issues/4331
  same rule (noGlobalDirnameFilename) and same construct (__filename/__dirname global replacement with import.meta)

<details><summary>All hits</summary>

- [github, open] 💅 `noUnnecessaryConditions`: false positive on an overloaded call with `undefined` as the default argument (Vue `inject`) — https://github.com/biomejs/biome/issues/12040
- [github, open] 💅 noLeakedRender false positive when using useState<boolean> — https://github.com/biomejs/biome/issues/10790
- [github, closed] 💅 `useSimplifiedLogicExpression` "safe" fix breaks code — https://github.com/biomejs/biome/issues/11351
- [github, closed] 💅 `useExplicitLengthCheck` false positive and broken fix — https://github.com/biomejs/biome/issues/11558
- [github, closed] 💅 `useExplicitLengthCheck` false positive — https://github.com/biomejs/biome/issues/11352
- [github, closed] 💅 Corrupted CLI safe fix for `useConsistentArrowReturn` — https://github.com/biomejs/biome/issues/8347
- [github, closed] 💅 lint/nursery/noUselessUndefined fix is unsafe for functions with union return types — https://github.com/biomejs/biome/issues/6906
- [github, closed] 💅 `useConsistentCurlyBraces` not working with string children — https://github.com/biomejs/biome/issues/7579
- [github, closed] 💅 `noLeakedRender` false positives — https://github.com/biomejs/biome/issues/10514
- [github, closed] 💅 2.1.2 broke SolidJS store syntax — https://github.com/biomejs/biome/issues/6998
- [tavily] biome migrate --write accesses the whole filesystem, takes minutes · Issue #7361 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7361
- [tavily] 💅 useConsistentTypeDefinitions should ignore interfaces in global declarations · Issue #8449 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8449
- [tavily] 💅 `noProcessGlobal` imports from `node::process` instead of `node:process` · Issue #5778 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/5778
- [tavily] 💅 [v2] Overrides not working when all linter category rules are on · Issue #5456 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/5456
- [tavily] 💅 noNoninteractiveElementInteractions marks `dialog` as non-interactive · Issue #7783 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7783
- [tavily] 💅 False positive by lint/nursery/noUselessUndefined · Issue #6577 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6577
- [tavily] 💅 `noUnresolvedImports`: multiple categories of false positives · Issue #9143 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/9143
- [tavily] 🐛 $filename metavariable not set in GritQL plugins · Issue #6670 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6670
- [tavily] 🐛 biome breaks characters in stdin mode · Issue #2988 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/2988
- [tavily] 🐛 Biome lint crushes PC · Issue #7206 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7206
- [tavily] 📎 Implement noGlobalDirnameFilename rule · Issue #4331 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/4331
- [tavily] 💅 nursery/noMisusedPromises causes stack overflow · Issue #6777 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6777
- [tavily] 📎 Add css modules support · Issue #2901 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/2901
- [tavily] `bun` is reported by `noUndeclaredDependencies` · Issue #2074 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/2074
- [tavily] 🐛 noUnusedImports supports custom jsxFactory · Issue #3682 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/3682

</details>
