# 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 program runs in an ES module environment where __dirname is not defined, causing a ReferenceError before the fix. The fix correctly rewrites __dirname to import.meta.dirname, which is the documented replacement for ES modules. The behavior change is due to the module system environment, not a bug in the fix itself.
- Program: minimized from 6 to 1 lines

## Reproducer

```js
async function main(){const d=await Promise.resolve(__dirname);console.log(d.length)}main();
```

## Commands

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

## Observed

```
stdout before:

stdout after:
124
exit 1 → 0
stderr before: ReferenceError: __dirname is not defined
stderr after: (none)
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:27:10.104706774 -0400
+++ fixed.js	2026-10-22 13:27:10.246709133 -0400
@@ -1 +1 @@
-async function main(){const d=await Promise.resolve(__dirname);console.log(d.length)}main();
+async function main(){const d=await Promise.resolve(import.meta.dirname);console.log(d.length)}main();
```

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

The original code uses `__dirname`, which in Node.js refers to the directory of the current module file; when executed as a script, it resolves to the actual path of `orig.js`. After rewriting, `import.meta.dirname` is used, which only exists in ES modules (`type: "module"`). Since the file is treated as CommonJS (no `"type": "module"` in package.json or `.mjs` extension), `import.meta` lacks a `dirname` property, causing a ReferenceError—though stderr shows none after fix, implying the environment may have silently ignored it or the error was caught elsewhere. However, the observed behavior change—exit code shifting from 1 to 0 and output changing from error to `124`—indicates the fix altered runtime semantics: `__dirname` was valid and produced a string whose length was logged, while the replacement either failed silently or returned a different value (e.g., `undefined`, whose `.length` throws—but stderr after is empty, suggesting the error was suppressed or the value was coerced). In any case, the substitution assumes equivalence between `__dirname` and `import.meta.dirname`, which does not hold in CommonJS contexts, breaking behavior.

## Upstream search

Queries: "noGlobalDirnameFilename fix", "__dirname usage in ES module", "Promise resolve import meta dirname", "await global dirname replacement"

- duplicate: https://github.com/biomejs/biome/issues/11028
  same rule (noGlobalDirnameFilename) and same construct (__dirname rewrite in async context) causing ReferenceError

<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] 💅 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] 📎 Implement nursery/noFloatingPromises - typescript-eslint/no-floating-promises · Issue #4956 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/4956
- [tavily] 🐛 LSP fails using biome v2 with pnpm · Issue #582 · biomejs/biome-vscode · GitHub — https://github.com/biomejs/biome-vscode/issues/582
- [tavily] 🐛 Multiple false positives reported by biome check · Issue #9478 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/9478
- [tavily] 🐛 `noConfusingVoidType`: allow `Promise<void> | void` · Issue #604 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/604
- [tavily] 💅 Imported npm modules should not require .js extensions · Issue #8245 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8245
- [tavily] fix: correctly place await after comment by arendjr · Pull Request #8169 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/8169
- [tavily] noFloatingPromises unsafe always adds await · Issue #6796 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6796
- [tavily] 💅 useAwait does not treat `await using` as an await · Issue #11250 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/11250
- [tavily] challenge(formatter): assignment with await/yield do not break by victor-teles · Pull Request #776 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/776
- [tavily] 💅 noFloatingPromise (nursery) - adding await repeatedly - regression in 2.5.6 · Issue #11144 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/11144
- [tavily] challenge(formatter): fix unnecessary indent to nested await by victor-teles · Pull Request #773 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/773

</details>
