# 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 undefined, so it crashes before the fix; after the fix it uses import.meta.dirname which exists in ES modules. The behavior change is caused by the module system, not by a semantic difference in the rewrite itself.
- Program: minimized from 6 to 1 lines

## Reproducer

```js
const dir = __dirname;
```

## 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:51.733398916 -0400
+++ fixed.js	2026-10-22 13:27:51.880401363 -0400
@@ -1 +1 @@
-const dir = __dirname;
+const dir = import.meta.dirname;
```

## 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 when executed. The replacement `import.meta.dirname` provides the directory name of the current module file in ES module scope, resolving the error. Since the original code fails to run due to the missing `__dirname`, while the fixed version executes successfully, the behavior changes from throwing an error to running without error—this difference in observable outcome means the rewrite is not semantics-preserving, even though it makes the code functional in ES modules. The fix alters the program’s execution path by eliminating a runtime exception.

## Upstream search

Queries: "noGlobalDirnameFilename fix", "__dirname usage", "ES module global variable", "import.meta.dirname replacement"

- related: https://github.com/biomejs/biome/issues/4331
  same rule (noGlobalDirnameFilename) but tracking initial implementation not the fix-changes-behavior defect
- duplicate: https://github.com/biomejs/biome/issues/11028
  same rule (noGlobalDirnameFilename) and same defect (fix replaces __dirname with import.meta.dirname in contexts where it changes behavior)

<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] 🐛 Migrate dont work · Issue #4740 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/4740
- [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] 💅 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
- [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

</details>
