Skip to content

Comments

fix(linter/plugins)!: prevent access to cwd in createOnce#18081

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/01-16-fix_linter_plugins_prevent_access_to_cwd_in_createonce_
Jan 16, 2026
Merged

fix(linter/plugins)!: prevent access to cwd in createOnce#18081
graphite-app[bot] merged 1 commit intomainfrom
om/01-16-fix_linter_plugins_prevent_access_to_cwd_in_createonce_

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Jan 16, 2026

Supporting JS plugins in LSP requires that different workspaces have a different value for Context#cwd.

As a first step, prevent accessing cwd property, or calling getCwd method in createOnce. Later on, we can make cwd a dynamic property.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-linter-plugins Area - Linter JS plugins C-bug Category - Bug labels Jan 16, 2026
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@overlookmotel overlookmotel marked this pull request as ready for review January 16, 2026 13:32
@overlookmotel overlookmotel removed the request for review from camc314 January 16, 2026 13:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request prevents access to the cwd (current working directory) property and getCwd() method within the createOnce context of JS plugins. This is a breaking change that prepares for supporting different workspaces with different cwd values in the LSP (Language Server Protocol) implementation.

Changes:

  • Modified cwd and getCwd() to throw errors when accessed in createOnce context instead of returning the current working directory
  • Updated tests to verify that accessing cwd/getCwd() in createOnce now throws appropriate error messages
  • Removed the cached cwd variable from the ESLint compatibility layer since it's no longer accessible in createOnce

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
apps/oxlint/src-js/plugins/context.ts Added filePath === null checks to throw errors when cwd or getCwd() are accessed in createOnce
apps/oxlint/src-js/package/define.ts Removed cached cwd variable and updated FILE_CONTEXT to throw errors for cwd/getCwd() access in createOnce
apps/oxlint/test/fixtures/createOnce/plugin.ts Updated test to verify error behavior instead of successful access
apps/oxlint/test/fixtures/createOnce/output.snap.md Updated expected output to show error messages instead of cwd values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Jan 16, 2026
Copy link
Member Author

overlookmotel commented Jan 16, 2026

Merge activity

Supporting JS plugins in LSP requires that different workspaces have a different value for `Context#cwd`.

As a first step, prevent accessing `cwd` property, or calling `getCwd` method in `createOnce`. Later on, we can make `cwd` a dynamic property.
@graphite-app graphite-app bot force-pushed the om/01-16-fix_linter_plugins_prevent_access_to_cwd_in_createonce_ branch from 9923c68 to 3a0a190 Compare January 16, 2026 15:49
@graphite-app graphite-app bot merged commit 3a0a190 into main Jan 16, 2026
19 checks passed
@graphite-app graphite-app bot deleted the om/01-16-fix_linter_plugins_prevent_access_to_cwd_in_createonce_ branch January 16, 2026 15:55
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants