Skip to content

refactor: first step toward ESLint 10 support#454

Draft
SukkaW wants to merge 5 commits intoun-ts:masterfrom
SukkaW:eslint-10
Draft

refactor: first step toward ESLint 10 support#454
SukkaW wants to merge 5 commits intoun-ts:masterfrom
SukkaW:eslint-10

Conversation

@SukkaW
Copy link
Collaborator

@SukkaW SukkaW commented Feb 15, 2026

Fixes #452 and #455 , and a step toward #438.


Important

Refactor for ESLint 10 support by updating sourceType preference and merging parser functions in parse.ts.

  • Behavior:
    • sourceType in source-type.ts now prefers context.languageOptions over context.parserOptions.
    • Access to context.parserOptions in sourceType is now guarded to prevent errors.
  • Functions:
    • Merges getParser and getParserPath into getParserOrPath in parse.ts.
  • Misc:
    • Renames path to nodePath in parse.ts.

This description was created by Ellipsis for a58501c. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • Chores

    • Preparation for ESLint 10 compatibility.
  • Refactor

    • Improved parser selection logic to better support custom parsers and alternate configurations.
    • Enhanced source type resolution to prioritize modern configuration settings with backward compatibility fallbacks.

@SukkaW SukkaW requested review from JounQin and Copilot February 15, 2026 05:23
@changeset-bot
Copy link

changeset-bot bot commented Feb 15, 2026

🦋 Changeset detected

Latest commit: 932a8b5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-import-x Patch

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

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to a58501c in 6 seconds. Click for details.
  • Reviewed 101 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft 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 Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@coderabbitai
Copy link

coderabbitai bot commented Feb 15, 2026

📝 Walkthrough

Walkthrough

A changeset is added for ESLint 10 support. Parser selection logic is refactored in parse.ts by introducing getParserOrPath to check custom parser configurations. SourceType resolution is refactored in source-type.ts to prioritize languageOptions with fallback handling, addressing an undefined reference crash.

Changes

Cohort / File(s) Summary
Changeset
.changeset/some-moments-trade.md
Added patch release note documenting first step toward ESLint 10 support.
Parser Utilities Refactoring
src/utils/parse.ts, src/utils/source-type.ts
Renamed parser resolution function to getParserOrPath with updated logic to check context.settings['import-x/parsers'] for custom parsers with fallback chains. Refactored sourceType resolution to prioritize languageOptions with backward-compatible fallback to parserOptions when undefined.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

refactor, bug

Poem

🐰 A parser's path now clearly shown,
With settings checked and fallbacks known,
SourceType finds its rightful place,
No more undefined in cyberspace!
ESLint ten, we're on our way,
With cleaner code each coding day! 🌟

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main objective—adding ESLint 10 support—and aligns with the PR's primary focus of refactoring sourceType resolution and parser handling for ESLint 10 compatibility.
Linked Issues check ✅ Passed Changes directly address issue #452 by making sourceType access resilient to undefined parserOptions and refactoring parser utilities, preventing the TypeError that crashed the linter.
Out of Scope Changes check ✅ Passed All modifications remain focused on ESLint 10 support: sourceType resolution updates, parser utility consolidation, and changeset entry—all aligned with stated PR objectives.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into master
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 15, 2026

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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-import-x@454

commit: 932a8b5

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🔴 Critical

Bug: typeof parse references the module-level export, not parser.parse.

On line 191, typeof parse === 'function' resolves to the parse function exported at line 71 of this file — it's always true. The intended check is typeof parser.parse === 'function', consistent with the parseForESLint check on line 193.

This means any object with a parse property (regardless of type) passes validation, which could lead to a runtime error later if parser.parse isn'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'))
   ) {

Copy link

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 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.parserOptions is undefined by adding proper existence guards and prioritizing languageOptions (flat config) over legacy parserOptions
  • Consolidated getParser and getParserPath into a single getParserOrPath function with proper guards for context.parserPath access
  • Renamed path import to nodePath to 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.

@SukkaW SukkaW marked this pull request as draft February 15, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError in @import/unambiguous crashes linter

1 participant

Comments