refactor: first step toward ESLint 10 support#454
refactor: first step toward ESLint 10 support#454SukkaW wants to merge 5 commits intoun-ts:masterfrom
Conversation
🦋 Changeset detectedLatest commit: 932a8b5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to a58501c in 6 seconds. Click for details.
- Reviewed
101lines of code in3files - Skipped
0files when reviewing. - Skipped posting
0draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
Workflow ID: wflow_TVOcxA287xjliOKs
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
📝 WalkthroughWalkthroughA changeset is added for ESLint 10 support. Parser selection logic is refactored in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
commit: |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/utils/parse.ts (1)
188-196:⚠️ Potential issue | 🔴 CriticalBug:
typeof parsereferences the module-level export, notparser.parse.On line 191,
typeof parse === 'function'resolves to theparsefunction exported at line 71 of this file — it's alwaystrue. The intended check istypeof parser.parse === 'function', consistent with theparseForESLintcheck on line 193.This means any object with a
parseproperty (regardless of type) passes validation, which could lead to a runtime error later ifparser.parseisn't actually callable.🐛 Proposed fix
if ( parser && typeof parser !== 'string' && - (('parse' in parser && typeof parse === 'function') || + (('parse' in parser && typeof parser.parse === 'function') || ('parseForESLint' in parser && typeof parser.parseForESLint === 'function')) ) {
There was a problem hiding this comment.
Pull request overview
This PR takes the first step toward ESLint 10 support by refactoring how the plugin accesses parser configuration, specifically addressing a critical crash bug (#452) and preparing for the removal of context.parserPath in ESLint 10.
Changes:
- Fixed TypeError crash when
context.parserOptionsis undefined by adding proper existence guards and prioritizinglanguageOptions(flat config) over legacyparserOptions - Consolidated
getParserandgetParserPathinto a singlegetParserOrPathfunction with proper guards forcontext.parserPathaccess - Renamed
pathimport tonodePathto avoid naming conflicts with function parameters
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/utils/source-type.ts | Refactored to prioritize languageOptions over parserOptions with proper guards, fixing the crash from issue #452 |
| src/utils/parse.ts | Merged parser resolution logic into getParserOrPath, added guards for context.parserPath, and renamed path import to avoid conflicts |
| .changeset/some-moments-trade.md | Added changeset documenting this as a patch release for ESLint 10 support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Fixes #452 and #455 , and a step toward #438.
sourceTypepreferscontext.languageOptionswhen possiblecontext.parserOptionsbysourceTypeis now guarded, which fixes TypeError in @import/unambiguous crashes linter #452getParserandgetParserPathimpl into onegetParserOrPathImportant
Refactor for ESLint 10 support by updating
sourceTypepreference and merging parser functions inparse.ts.sourceTypeinsource-type.tsnow preferscontext.languageOptionsovercontext.parserOptions.context.parserOptionsinsourceTypeis now guarded to prevent errors.getParserandgetParserPathintogetParserOrPathinparse.ts.pathtonodePathinparse.ts.This description was created by
for a58501c. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit
Chores
Refactor