# 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, causing a ReferenceError before the fix. The rewrite to import.meta.dirname is the documented ES-module replacement, so the behavior change stems from the module system environment, not a flaw in the fix itself.
- Program: minimized from 3 to 1 lines

## Reproducer

```js
__dirname; // this comment must stay
```

## 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:18.407844716 -0400
+++ fixed.js	2026-10-22 13:27:18.543846976 -0400
@@ -1 +1 @@
-__dirname; // this comment must stay
+import.meta.dirname; // this comment must stay
```

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

The original code uses `__dirname`, which is undefined in ES modules, causing a ReferenceError. The replacement `import.meta.dirname` provides the directory name of the current module file in ES module scope, resolving the error. Since the behavior changes from throwing an exception to executing successfully, the rewrite alters program semantics despite preserving the comment. This change is not semantics-preserving because it modifies the program’s execution outcome.

## Upstream search

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

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

<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] 💅 New rule for `noDeprecatedImports` not working with declarations · Issue #7635 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7635
- [tavily] 💅 false positive of `noUndeclaredDependencies` with `@types/ ... — https://github.com/biomejs/biome/issues/11012
- [tavily] 💅 `noUnknownAttribute` doesn't support SVG opacity · Issue #7967 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7967
- [tavily] 🐛 Unexpected override behavior · Issue #691 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/691
- [tavily] 🐛 Override behavior with multiple matches · Issue #3176 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/3176
- [tavily] fix(linter): `useExhaustiveDependencies` revert object method call behavior change, fixes #8958 by mdevils · Pull Request #9017 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/9017
- [tavily] 💅 `2.3.14` introduces incorrect behavior to `useExhaustiveDeps` · Issue #8958 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8958

</details>
