# 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 as an ES module where __dirname is not defined, so it already fails before the fix with a ReferenceError. The fix replaces __dirname with import.meta.dirname, which is the correct ES module equivalent, but the resulting path '/w//w/data.json' suggests the module resolution environment differs from what the original CommonJS-style code expected. The behavior change stems from the module system environment, not from an incorrect rewrite.
- Program: minimized from 3 to 1 lines

## Reproducer

```js
const mod = await import(`./${__dirname}/data.json`);
```

## 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: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/w//w/data.json' imported from /w/prog.js
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:26:45.016290324 -0400
+++ fixed.js	2026-10-22 13:26:47.002323272 -0400
@@ -1 +1 @@
-const mod = await import(`./${__dirname}/data.json`);
+const mod = await import(`./${import.meta.dirname}/data.json`);
```

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

The original code uses `__dirname`, which resolves to the directory of the current file (e.g., `/w`). After rewriting with `import.meta.dirname`, it attempts to use that value directly as part of a path string (`./${import.meta.dirname}`). However, when concatenated into `"../w/w"` or similar due to incorrect relative resolution logic—especially if `import.meta.dirname` already includes an absolute path—the resulting module specifier becomes malformed (e.g., `'/w//w/data.json'`), leading to a failed lookup. This occurs because `import.meta.dirname` returns an absolute path, making `./${import.meta.dirname}` resolve incorrectly compared to the intended relative path based on `__dirname`. Thus, the semantic intent of resolving a module relative to the current file’s directory is broken.

## Upstream search

Queries: "noGlobalDirnameFilename fix", "__dirname usage with dynamic import", "top-level await with __dirname error", "import.meta.dirname replacement pattern"

- no duplicate or related report found among 30 hits

<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] 🐛 Does not support `resolution-mode` for `typeof import` · Issue #2115 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/2115
- [tavily] feat(lint): add nursery rule `useImportsFirst` by terror · Pull Request #9272 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/9272
- [tavily] 🐛 Import fix leave an empty line · Issue #653 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/653
- [tavily] incorrect detection of unused imports · Issue #4449 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/4449
- [tavily] 🐛 Import sorting breaks with a particular import line when saving in VSCode · Issue #1570 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/1570
- [tavily] 💅 Improve functionality of import type · Issue #3615 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/3615
- [tavily] 🐛 GritQL pattern doesn't match different kinds of `import` statements · Issue #5801 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/5801
- [tavily] React hooks aren't linted if not matching very strict import pattern · Issue #1791 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/1791
- [tavily] 🐛 GritQL pattern `export { $foo } from $source` fails to match while `export * from $source` works · Issue #8828 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8828
- [tavily] 🐛 Ignore pattern in `linter` feature wrongly applies to `formatter` · Issue #2131 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/2131
- [tavily] fix(grit): support positional arguments in pattern, function, and node calls by Zelys-DFKH · Pull Request #10281 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/10281
- [tavily] 🐛 Some ignore pattern generate `ignored file` error · Issue #1471 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/1471
- [tavily] 🐛 GritQL pattern with 2+ metavariables fails to match empty call expression without capturing function parameters · Issue #10242 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/10242

</details>
