# 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 rewrite 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 fix itself.
- Program: minimized from 5 to 3 lines

## Reproducer

```js
function f(dir = __dirname) {
}
console.log(f());
```

## Commands

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

## Observed

```
stdout before:

stdout after:
undefined
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:03.755601334 -0400
+++ fixed.js	2026-10-22 13:27:03.900603741 -0400
@@ -1,3 +1,3 @@
-function f(dir = __dirname) {
+function f(dir = import.meta.dirname) {
 }
 console.log(f());
```

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

The original program uses `__dirname`, which is undefined in ES modules, causing a ReferenceError that exits with code 1; the rewritten version substitutes `import.meta.dirname`, which resolves to the directory of the current module file, allowing the function to return a string instead of throwing, so the program prints that path and exits successfully. This changes both output and exit status, altering observable behavior.

## Upstream search

Queries: "noGlobalDirnameFilename fix", "correctness noGlobalDirnameFilename default parameter", "import meta dirname replacement function argument", "ES module __dirname undefined error fix"

- related: https://github.com/biomejs/biome/issues/5778
  same rule category (correctness/no*Global) but different construct (process global vs __dirname/__filename)
- related: https://github.com/biomejs/biome/issues/9061
  same rule category (correctness/no*Global) but different construct (process.env vs __dirname/__filename)

<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
- [github, closed] 💅 False positive: import reported as "only used as types" when used in Svelte template — https://github.com/biomejs/biome/issues/9358
- [tavily] 💅 useNamingConvention is a bit too aggressive · Issue #7575 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7575
- [tavily] noImportCycles doesn't ignore types · Issue #6799 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6799
- [tavily] 💅 New rule for `noDeprecatedImports` not working with declarations · Issue #7635 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7635
- [tavily] 💅 `noLeakedRender` many false positives · Issue #8288 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8288
- [tavily] 💅 `useDestructuring` doesn't work with type annotations · Issue #8478 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8478
- [tavily] 💅 `noLeakedRender` doesn't handle boolean case · Issue #8491 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8491
- [tavily] 💅 gql formatter crashing · Issue #9131 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/9131
- [tavily] 💅 Using object literal shorthand syntax causes useErrorCause false positive · Issue #10664 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/10664
- [tavily] 💅 `useAwaitThenable` many false positives with drizzle · Issue #8476 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8476
- [tavily] 💅 `noProcessEnv` only works with the global `process` object (false negative) · Issue #9061 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/9061

</details>
