-
-
Notifications
You must be signed in to change notification settings - Fork 37
feat: patch missing context and SourceCode methods for v10 #311
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
Conversation
|
Can we also patch |
There was a problem hiding this 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 updates the @eslint/compat package to adapt ESLint v9.x rules/plugins for use in ESLint v10.x. The main changes involve rewriting the compatibility layer to restore deprecated context and sourceCode methods using a Proxy-based approach instead of wrapping visitor methods.
- Replaces the visitor-wrapping approach with a Proxy-based context wrapper
- Restores deprecated context methods (getCwd, getFilename, getPhysicalFilename, getSourceCode) and sourceCode methods (getTokenOrCommentBefore/After, isSpaceBetweenTokens, getJSDocComment)
- Updates documentation to reflect ESLint v9.x → v10.x compatibility (previously v8.x → v9.x)
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/compat/src/fixup-rules.js | Implements new Proxy-based compatibility layer for context and sourceCode objects, replacing the previous visitor-wrapping approach |
| packages/compat/tests/fixup-rules.test.js | Updates test suite to verify restoration of deprecated methods, replacing legacy schema and method compatibility tests |
| packages/compat/README.md | Updates documentation to reference ESLint v9.x → v10.x compatibility instead of v8.x → v9.x |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mdjermanovic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
The tests will really be checking the new features only when we update ESLint to v10 in this repo, but I verified manually that they are passing and that generally everything works well when the methods/properties this PR patches are removed from ESLint.
Since this is a feature, it needs a second review before merging.
nzakas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks.
Prerequisites checklist
What is the purpose of this pull request?
ESLint v10 will remove several methods from the
contextandSourceCodeobjects:From
context:parserOptions→ usecontext.languageOptions.parserOptionsgetCwd()→ usecontext.cwdgetFilename()→ usecontext.filenamegetPhysicalFilename()→ usecontext.physicalFilenamegetSourceCode()→ usecontext.sourceCodeFrom
SourceCode:getTokenOrCommentBefore()→ usegetTokenBefore({ includeComments: true })getTokenOrCommentAfter()→ usegetTokenAfter({ includeComments: true })isSpaceBetweenTokens()→ useisSpaceBetween()getJSDocComment()→ removed entirely (no direct replacement)This change patches those methods to maintain backward compatibility so existing ESLint v9 rules and plugins continue to work with
@eslint/compat.What changes did you make? (Give an overview)
fixupRule()to restore these methods when missing.fixupPluginRules()andfixupConfigRules()to wrap affected rules automatically.Related Issues
Fixes #279
Is there anything you'd like reviewers to focus on?