Repository navigation
fix(paths): report a deleted working directory as a user error #621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rhuanbarreto
merged 3 commits into
main
from
claude/bridge-cse_01TkEdtieU3zuDXcahTMcMGe
Sep 29, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright 2026 Archgate | ||
|
|
||
| // Custom oxlint JS plugin: production code resolves the working directory | ||
| // through `currentDir()` / `tryCurrentDir()` (src/helpers/paths.ts), never | ||
| // `process.cwd()`, which throws a raw `ENOENT` in a deleted directory and so | ||
| // reaches the ARCH-012 boundary as an internal bug (exit 2, Sentry report). | ||
| // The helpers turn it into a `UserError` or a `null`. | ||
|
|
||
| /** Minimal ESTree-ish node shape. The oxlint AST is ESLint-compatible. */ | ||
| type AstNode = { type: string } & Record<string, unknown>; | ||
|
|
||
| function isAstNode(value: unknown): value is AstNode { | ||
| return ( | ||
| typeof value === "object" && | ||
| value !== null && | ||
| "type" in value && | ||
| typeof value.type === "string" | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * The statically known name of a member property: an identifier | ||
| * (`process.cwd`) or a string literal in brackets (`process["cwd"]`). | ||
| */ | ||
| function staticPropertyName(node: AstNode): string | undefined { | ||
| const property = node.property; | ||
| if (!isAstNode(property)) return undefined; | ||
| if (node.computed === true) { | ||
| return property.type === "Literal" && typeof property.value === "string" | ||
| ? property.value | ||
| : undefined; | ||
| } | ||
| return property.type === "Identifier" && typeof property.name === "string" | ||
| ? property.name | ||
| : undefined; | ||
| } | ||
|
|
||
| /** True for the `process.cwd` member expression itself. */ | ||
| function isProcessCwd(node: AstNode): boolean { | ||
| if (node.type !== "MemberExpression") return false; | ||
| if (staticPropertyName(node) !== "cwd") return false; | ||
| const object = node.object; | ||
| return ( | ||
| isAstNode(object) && | ||
| object.type === "Identifier" && | ||
| object.name === "process" | ||
| ); | ||
| } | ||
|
|
||
| interface RuleContext { | ||
| report(descriptor: { node: AstNode; message: string }): void; | ||
| } | ||
|
|
||
| const MESSAGE = | ||
| "Resolve the working directory with `currentDir()` (or `tryCurrentDir()` in telemetry and diagnostics) from src/helpers/paths.ts instead of `process.cwd()`: it throws a raw ENOENT when the launch directory was deleted, which surfaces as an internal error (exit 2) and a Sentry report."; | ||
|
|
||
| const noProcessCwd = { | ||
| create(context: RuleContext) { | ||
| return { | ||
| MemberExpression(node: AstNode) { | ||
| if (isProcessCwd(node)) context.report({ node, message: MESSAGE }); | ||
| }, | ||
| }; | ||
| }, | ||
| }; | ||
|
|
||
| const plugin = { | ||
| meta: { name: "cwd" }, | ||
| rules: { "no-process-cwd": noProcessCwd }, | ||
| }; | ||
|
|
||
| export default plugin; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.