Skip to content

Comments

feat(linter/plugins): implement context.getSourceCode API#15599

Closed
camc314 wants to merge 1 commit intomainfrom
c/11-11-feat_linter_plugins_implement_context.getsourcecode_api
Closed

feat(linter/plugins): implement context.getSourceCode API#15599
camc314 wants to merge 1 commit intomainfrom
c/11-11-feat_linter_plugins_implement_context.getsourcecode_api

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Nov 11, 2025

fixes #15567

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI C-enhancement Category - New feature or request labels Nov 11, 2025
Copy link
Contributor Author

camc314 commented Nov 11, 2025


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.

@camc314 camc314 marked this pull request as ready for review November 11, 2025 15:35
Copilot AI review requested due to automatic review settings November 11, 2025 15:35
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 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 return SOURCE_CODE instead of throwing an error
  • Adds validation to prevent calling getSourceCode() when filePath is null
  • Adds test assertions to verify getSourceCode() returns the same value as sourceCode property

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.

@camc314 camc314 force-pushed the c/11-11-feat_linter_plugins_implement_context.getsourcecode_api branch from 883a089 to 6f99e6e Compare November 11, 2025 15:53
@overlookmotel
Copy link
Member

Oh sorry, I didn't see your PR before I did mine. #15606

@overlookmotel overlookmotel deleted the c/11-11-feat_linter_plugins_implement_context.getsourcecode_api branch November 14, 2025 16:37
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 C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: context.getSourceCode() should be implemented or removed

2 participants