# 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 high. The fix replaces __dirname with import.meta.dirname, which only exists in ES modules. The program runs as CommonJS (no package.json type: module), so the rewritten code throws a ReferenceError. The behavior change is caused by the module system, not the rewrite itself.
- Program: minimized from 14 to 9 lines

## Reproducer

```js
let result = [];
try {
  result.push(__dirname);
} catch (e) {
  try {
  } catch (e) {
  }
}
console.log(result.join('|'));
```

## Commands

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

## Observed

```
stdout before:

stdout after:
<wd>/prog
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:28:02.386576258 -0400
+++ fixed.js	2026-10-22 13:28:02.531578672 -0400
@@ -1,6 +1,6 @@
 let result = [];
 try {
-  result.push(__dirname);
+  result.push(import.meta.dirname);
 } catch (e) {
   try {
   } catch (e) {
```

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

The original uses __dirname which resolves to the directory of the script file being executed; import.meta.dirname refers to the directory of the module containing that expression, which may differ if the script is run as a non-module or via different resolution contexts—here it yields <wd>/prog instead of the expected script directory, changing output.

## Upstream search

Queries: "noGlobalDirnameFilename fix", "__dirname usage in try block", "noGlobalDirnameFilename __dirname replacement", "correctness noGlobalDirnameFilename import.meta"

- related: https://github.com/biomejs/biome/pull/8922
  same rule (noGlobalDirnameFilename) but different construct (revamp to catch false negatives vs fix-changes-behavior in try-catch)
- related: https://github.com/biomejs/biome/issues/8829
  same rule (noGlobalDirnameFilename) but different construct (false negatives vs fix-changes-behavior in try-catch)
- related: https://github.com/biomejs/biome/issues/11028
  same rule (noGlobalDirnameFilename) but different construct (false positive in CommonJS vs fix-changes-behavior in try-catch)

<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] fix(lint): revamp the `noGlobalDirnameFilename` rule to catch many false negatives by siketyan · Pull Request #8922 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/8922
- [tavily] 💅 `noGlobalDirnameFilename` doesn't work in most scenarios (false negatives) · Issue #8829 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8829
- [tavily] lint/a11y: Prefer native element rule incorrectly suggests <output> instead of role="status" for loading indicators · Issue #9245 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/9245
- [tavily] fix(useConsistentTestIt): fix panic when applying code fix by dyc3 · Pull Request #9942 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/9942
- [tavily] 🐛 LSP fails using biome v2 with pnpm · Issue #582 · biomejs/biome-vscode · GitHub — https://github.com/biomejs/biome-vscode/issues/582
- [github, closed] 💅 false positive of `noGlobalDirnameFilename` in CommonJS module — https://github.com/biomejs/biome/issues/11028
- [tavily] 💅 `noUnknownAttribute` doesn't support SVG opacity · Issue #7967 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7967

</details>
