# 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 __dirname is not defined, causing a ReferenceError before the fix. The fix replaces it with import.meta.dirname, which is the correct ES module equivalent, so the behavioral change is due to the module system environment, not a bug in the rewrite itself.
- Program: minimized from 8 to 4 lines

## Reproducer

```js
const dir = __dirname;
try {
} catch (e) {
}
```

## 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: __dirname is not defined in ES module scope
stderr after: (none)
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:27:32.964086677 -0400
+++ fixed.js	2026-10-22 13:27:33.103088989 -0400
@@ -1,4 +1,4 @@
-const dir = __dirname;
+const dir = import.meta.dirname;
 try {
 } catch (e) {
 }
```

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

The original script uses `__dirname`, which is unavailable in ES modules, causing a `ReferenceError` that exits with code 1. The replacement uses `import.meta.dirname`, which is only available when the file is treated as an ES module. If the environment still interprets the file as CommonJS (e.g., due to file extension or lack of `"type": "module"`), `import.meta` is undefined, making `import.meta.dirname` also throw a `ReferenceError`. However, if the environment now correctly treats it as an ES module, the error disappears and execution succeeds (exit 0). The behavioral change arises because the fix alters the module system’s interpretation of the file, affecting the availability of module-specific variables—not merely substituting equivalent values within the same system. This shift in execution context changes whether the program throws or runs, so the rewrite is not semantics-preserving.

## Upstream search

Queries: "noGlobalDirnameFilename fix", "__dirname usage in ES modules", "import.meta.dirname replacement pattern", "correctness noGlobalDirnameFilename linting"

- no duplicate or related report found among 35 hits

<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] 📎 Implement noGlobalDirnameFilename rule · Issue #4331 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/4331
- [tavily] 💅 false positive of `noGlobalDirnameFilename` in CommonJS module · Issue #11028 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/11028
- [tavily] build: add minimal python config to publish project on pypi by lypwig · Pull Request #8818 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/8818
- [tavily] 🐛 GritQL pattern doesn't match different kinds of `import` statements · Issue #5801 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/5801
- [tavily] React hooks aren't linted if not matching very strict import pattern · Issue #1791 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/1791
- [tavily] 🐛 GritQL pattern `export { $foo } from $source` fails to match while `export * from $source` works · Issue #8828 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8828
- [tavily] 🐛 Ignore pattern in `linter` feature wrongly applies to `formatter` · Issue #2131 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/2131
- [tavily] fix(grit): support positional arguments in pattern, function, and node calls by Zelys-DFKH · Pull Request #10281 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/10281
- [tavily] 🐛 Some ignore pattern generate `ignored file` error · Issue #1471 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/1471
- [tavily] 🐛 GritQL pattern with 2+ metavariables fails to match empty call expression without capturing function parameters · Issue #10242 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/10242
- [github, closed] 💅 noFloatingPromises doesn't respect TypeScript overloads — https://github.com/biomejs/biome/issues/9568
- [github, closed] Biome recommends omitting else clause that is not useless — https://github.com/biomejs/biome/issues/8221
- [tavily] 💅 `noGlobalDirnameFilename` doesn't work in most scenarios (false negatives) · Issue #8829 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8829
- [tavily] 💅 Incorrectly suggest to discard redundant terms (useSimplifiedLogicExpression) · Issue #8577 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8577
- [tavily] 💅 [svelte] Linter failing on detecting use of variables and function params in svelte snippet · Issue #10103 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/10103
- [tavily] 💅 New rule for `noDeprecatedImports` not working with declarations · Issue #7635 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7635
- [tavily] 💅 `noProcessEnv` only works with the global `process` object (false negative) · Issue #9061 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/9061
- [tavily] 💅 lint/suspicious/useIterableCallbackReturn makes impossible to explicitly return undefined · Issue #9445 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/9445

</details>
