fix(linter/plugins)!: prevent access to cwd in createOnce#18081
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
There was a problem hiding this comment.
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
cwdandgetCwd()to throw errors when accessed increateOncecontext instead of returning the current working directory - Updated tests to verify that accessing
cwd/getCwd()increateOncenow throws appropriate error messages - Removed the cached
cwdvariable from the ESLint compatibility layer since it's no longer accessible increateOnce
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.
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.
9923c68 to
3a0a190
Compare

Supporting JS plugins in LSP requires that different workspaces have a different value for
Context#cwd.As a first step, prevent accessing
cwdproperty, or callinggetCwdmethod increateOnce. Later on, we can makecwda dynamic property.