# 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 for ES modules, but the program also references an undefined variable x, which causes a different ReferenceError after the fix. The behavior change is due to the execution environment and a pre-existing undefined variable, not a bug in the fix itself.
- Program: minimized from 4 to 1 lines

## Reproducer

```js
console.log('template:', `${__dirname}${x}`);
```

## Commands

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

## Observed

```
stderr before: ReferenceError: __dirname is not defined in ES module scope
stderr after: ReferenceError: x is not defined
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:28:18.366842438 -0400
+++ fixed.js	2026-10-22 13:28:18.515844921 -0400
@@ -1 +1 @@
-console.log('template:', `${__dirname}${x}`);
+console.log('template:', `${import.meta.dirname}${x}`);
```

## 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 when evaluating the template literal; this error occurs before `x` is accessed. After rewriting to `import.meta.dirname`, that variable is defined (assuming the environment supports it), so the template literal evaluates successfully, attempting to concatenate the directory path with `x`. Since `x` remains undefined, a ReferenceError now arises from `x` instead. The change shifts the point of failure from `__dirname` to `x`, altering the observed error and thus the program’s behavior under execution. This difference in error timing and target violates semantic equivalence.

## Upstream search

Queries: "noGlobalDirnameFilename fix", "correctness noGlobalDirnameFilename template literal", "__dirname usage in ES module string interpolation", "replace __dirname with import.meta.dirname"

- related: https://github.com/biomejs/biome/issues/5778
  Same rule category (correctness/noGlobalDirnameFilename vs noProcessGlobal) and same class of defect (global replacement in ES modules), but different construct (import.meta.dirname vs node:process import).

<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] 💅 useNamingConvention is a bit too aggressive · Issue #7575 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7575
- [tavily] 💅 Incorrectly suggest to discard redundant terms (useSimplifiedLogicExpression) · Issue #8577 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8577
- [tavily] 💅 Using object literal shorthand syntax causes useErrorCause false positive · Issue #10664 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/10664
- [tavily] 💅 noParametersOnlyUsedInRecursion false positives · Issue #8004 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8004
- [tavily] 💅 `useDestructuring` doesn't work with type annotations · Issue #8478 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8478
- [tavily] 💅 `useAwaitThenable` many false positives with drizzle · Issue #8476 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8476
- [tavily] 💅 New rule for `noDeprecatedImports` not working with declarations · Issue #7635 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7635
- [tavily] 🐛 Error in webstorm plugin during formating · Issue #552 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/552
- [tavily] feat(lint/js): add `noUselessTypeConversion` by dyc3 · Pull Request #9701 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/9701
- [tavily] 💅 useExhaustiveSwitchCases does not work across module boundaries · Issue #6929 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6929
- [tavily] draft: css module level 3 parser by xin2017338 · Pull Request #1224 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/1224
- [tavily] 🐛 Providing `--config-path` changes cwd for `"extends"` module resolving · Issue #2231 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/2231
- [tavily] fix(html_formatter): format Vue interpolation snippets by puneetdixit200 · Pull Request #10391 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/10391
- [tavily] 🐛 eslint migration find/replace bug · Issue #3079 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/3079
- [tavily] 🐛 double slash removes the adjacent code line · Issue #910 · biomejs/biome-vscode · GitHub — https://github.com/biomejs/biome-vscode/issues/910
- [tavily] 🐛 LSP fails using biome v2 with pnpm · Issue #582 · biomejs/biome-vscode · GitHub — https://github.com/biomejs/biome-vscode/issues/582
- [tavily] fix(semantic): resolve Svelte $store references in semantic model by Hugo-Polloli · Pull Request #9286 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/9286
- [tavily] refactor: replace `biome_rowan::*` type into biome type by chansuke · Pull Request #3431 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/3431

</details>
