Skip to content

Conversation

SukkaW
Copy link
Collaborator

@SukkaW SukkaW commented May 9, 2025

Fixes #320. Accept non-array resolver-next and cast to array ourselves.


Important

Allow resolver-next to accept non-array inputs by casting them to arrays in fullResolve().

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

Summary by CodeRabbit

  • Bug Fixes
    • Improved support for the 'resolver-next' setting, allowing both single resolver objects and arrays of resolvers to be used without causing errors.

Copy link

changeset-bot bot commented May 9, 2025

🦋 Changeset detected

Latest commit: d703942

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

coderabbitai bot commented May 9, 2025

"""

Walkthrough

The changes update the ImportSettings interface to allow the resolver-next property to accept either a single resolver object or an array of resolver objects. Corresponding logic in the resolver utility is modified to handle both cases, ensuring consistent processing regardless of input format.

Changes

File(s) Change Summary
src/types.ts Updated ImportSettings['resolver-next'] type from NewResolver[] to NewResolver[] | NewResolver.
src/utils/resolve.ts Modified logic in fullResolve to handle both single object and array for resolver-next.
.changeset/cyan-icons-fetch.md Added changeset documenting patch update for resolver-next to accept single resolver input.
test/utils/resolve.spec.ts Added test verifying fullResolve handles single resolver object correctly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant fullResolve
    participant Resolver(s)

    User->>fullResolve: Call with settings['resolver-next']
    fullResolve->>fullResolve: Check if resolver-next is array
    alt resolver-next is array
        fullResolve->>Resolver(s): Iterate over array
    else resolver-next is single object
        fullResolve->>Resolver(s): Wrap in array and iterate
    end
    Resolver(s)-->>fullResolve: Processed results
    fullResolve-->>User: Return result
Loading

Assessment against linked issues

Objective Addressed Explanation
Support single object for resolver-next in settings (#320)

Suggested reviewers

  • SukkaW

Poem

A single resolver or maybe a crowd,
Now both are allowed, and bunnies are proud!
Types are more nimble, the code is robust,
In arrays or alone, resolvers we trust.
🐇✨
Hop, hop, hooray—
Flexible imports are here to stay!
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

test/utils/resolve.spec.ts

Oops! Something went wrong! :(

ESLint: 9.26.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/lib/index.js' imported from /eslint.config.js
at finalizeResolution (node:internal/modules/esm/resolve:257:11)
at moduleResolve (node:internal/modules/esm/resolve:914:10)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)
(node:10886) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8894daf and d703942.

📒 Files selected for processing (1)
  • test/utils/resolve.spec.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
test/utils/resolve.spec.ts (3)
test/utils.ts (2)
  • testContext (155-160)
  • testFilePath (39-41)
src/types.ts (1)
  • NewResolver (63-68)
src/utils/resolve.ts (1)
  • resolve (230-253)
⏰ Context from checks skipped due to timeout of 90000ms (21)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 8.56 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 8.56 on windows-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on macos-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on macos-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on macos-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on macos-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on macos-latest
🔇 Additional comments (1)
test/utils/resolve.spec.ts (1)

165-172: Good addition of a test case for the non-array resolver.

This test correctly verifies that the resolver-next setting accepts a single resolver object without requiring it to be wrapped in an array, which aligns with the PR objective to fix issue #320. The test follows the existing patterns in the test suite and properly tests the new functionality.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codesandbox-ci bot commented May 9, 2025

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.

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 ae66788 in 34 seconds. Click for details.
  • Reviewed 30 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 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.
1. src/types.ts:104
  • Draft comment:
    Good change—accepting a single resolver object improves usability.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. src/utils/resolve.ts:148
  • Draft comment:
    Wrapping non-array resolvers in an array is correctly handled.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
3. src/types.ts:104
  • Draft comment:
    Updated 'resolver-next' type to accept both a single NewResolver and an array. This properly resolves #320.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
4. src/utils/resolve.ts:150
  • Draft comment:
    Properly casts non-array resolver to an array for uniform iteration. This change meets the requirements for #320.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_YqaN9bqbXDi69pAT

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link

pkg-pr-new bot commented May 9, 2025

Open in StackBlitz

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

commit: d703942

Copy link

codecov bot commented May 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.02%. Comparing base (f193e73) to head (d703942).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #321   +/-   ##
=======================================
  Coverage   96.02%   96.02%           
=======================================
  Files          92       92           
  Lines        4756     4758    +2     
  Branches     1791     1768   -23     
=======================================
+ Hits         4567     4569    +2     
  Misses        188      188           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JounQin
Copy link
Member

JounQin commented May 9, 2025

A new test case is needed.

@JounQin JounQin changed the title fix(#320): accept non-array in resolver-next fix: accept non-array resolve in resolver-next setting May 9, 2025
@JounQin JounQin changed the title fix: accept non-array resolve in resolver-next setting fix: accept non-array resolver in resolver-next setting May 9, 2025
Copy link

sonarqubecloud bot commented May 9, 2025

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.

feat: resolver-next should support single object resolver
2 participants