feat(linter/plugins): implement context.getSourceCode API#15599
feat(linter/plugins): implement context.getSourceCode API#15599
context.getSourceCode API#15599Conversation
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 PR implements the deprecated context.getSourceCode() API to support backward compatibility with ESLint plugins. The implementation returns the same SourceCode object as context.sourceCode, with a guard against calling it when no file is being linted.
Key changes:
- Implements
getSourceCode()to returnSOURCE_CODEinstead of throwing an error - Adds validation to prevent calling
getSourceCode()whenfilePathis null - Adds test assertions to verify
getSourceCode()returns the same value assourceCodeproperty
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/oxlint/src-js/plugins/context.ts | Implements getSourceCode() method to return SOURCE_CODE with null check for filePath |
| apps/oxlint/test/fixtures/sourceCode/plugin.ts | Adds test assertions verifying getSourceCode() returns same value as sourceCode in both create and createOnce contexts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
883a089 to
6f99e6e
Compare
|
Oh sorry, I didn't see your PR before I did mine. #15606 |

fixes #15567