Skip to content

feat: map legacy node resolver to the new one with fallback support #272

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

Merged
merged 4 commits into from
May 30, 2025

Conversation

SukkaW
Copy link
Collaborator

@SukkaW SukkaW commented Mar 30, 2025

Migrate the legacy import-x/resolve options and import-x/resolver+ node resolver to use our new built-in node resolver.

The import-x/resolve is a legacy option that is not even documented anymore (neither in the eslint-plugin-import nor eslint-plugin-import-x).

Summary by CodeRabbit

  • New Features

    • Improved support for legacy node resolver settings, automatically mapping them to a new resolver with fallback to the legacy resolver when needed.
    • Added a utility to convert single values or arrays into a consistent array format.
  • Bug Fixes

    • Prevented errors when legacy node resolvers are missing, allowing smoother migration to new resolver mechanisms.
  • Chores

    • Updated and reorganized dependencies, including making the legacy node resolver an optional peer dependency.
    • Enhanced CI workflow to test scenarios with and without the legacy node resolver installed.
  • Documentation

    • Added a changeset entry describing the new legacy resolver mapping feature.

Important

Migrate legacy node resolver configurations to a new built-in resolver with fallback support, updating utilities, CI, and dependencies.

  • Behavior:
    • Migrate legacy import-x/resolve and import-x/resolver to new built-in node resolver with fallback in resolve.ts.
    • Add legacyNodeResolve() in resolve.ts for handling legacy resolver options.
    • Update normalizeConfigResolvers() in legacy-resolver-settings.ts to support new resolver mapping.
  • Utilities:
    • Add arraify() in arraify.ts for array normalization.
    • Export arraify() in index.ts.
  • CI/CD:
    • Update ci.yml to include noLegacyNodeResolver matrix option.
    • Add step to uninstall legacy resolver in CI if noLegacyNodeResolver is true.
  • Dependencies:
    • Re-add eslint-import-resolver-node as optional peer dependency in package.json.

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

Copy link

changeset-bot bot commented Mar 30, 2025

🦋 Changeset detected

Latest commit: e0eb9a2

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 Minor

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

@SukkaW SukkaW requested review from JounQin and Copilot March 30, 2025 07:39
Copy link

coderabbitai bot commented Mar 30, 2025

"""

Walkthrough

This update introduces a new utility for array conversion, refactors legacy resolver handling to prefer a new node resolver with fallback, and modifies error handling for missing legacy node resolvers. Dependency declarations are reorganized, and CI is updated to test with and without the legacy node resolver.

Changes

File(s) Change Summary
src/utils/legacy-resolver-settings.ts Adds LEGACY_NODE_RESOLVERS constant, caches resolver instances, and updates error handling for missing resolvers.
src/utils/resolve.ts Introduces legacyNodeResolve, updates legacy resolver logic, imports new utilities, and improves cache key logic.
src/utils/arraify.ts, src/utils/index.ts Adds and exports a generic arraify utility function.
package.json Moves eslint-import-resolver-node to peer dependencies as optional, updates package versions, and adjusts dependency metadata.
.github/workflows/ci.yml Expands CI matrix, adds job to conditionally install legacy node resolver for specific test runs.
.changeset/khaki-sites-teach.md Documents the feature update mapping legacy node resolver to new resolver with fallback.
src/rules/no-named-as-default.ts Adds a single blank line for code clarity without affecting logic.
test/rules/no-unresolved.spec.ts Wraps "case sensitivity strict" tests in a non-Windows platform check to avoid unsupported path issues on Windows.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ESLint
    participant Plugin
    participant NewNodeResolver
    participant LegacyNodeResolver

    User->>ESLint: Run lint with import resolver
    ESLint->>Plugin: Request module resolution
    Plugin->>NewNodeResolver: Try resolve (legacy options)
    alt NewNodeResolver succeeds
        NewNodeResolver->>Plugin: Return resolved path
    else Needs legacy package options
        Plugin->>LegacyNodeResolver: Dynamically load and resolve
        LegacyNodeResolver->>Plugin: Return resolved path or error
    end
    Plugin->>ESLint: Return resolution result
Loading

Possibly related PRs

Suggested labels

enhancement, feature

Suggested reviewers

  • SukkaW

Poem

A hop and a skip, the code takes a leap,
New resolvers awake while the old ones sleep.
Arrays now wrap with a gentle embrace,
Peer dependencies find their proper place.
CI hops on, with tests that are new—
This bunny is proud of the work you all do! 🐇✨
"""

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.

src/utils/resolve.ts

Oops! Something went wrong! :(

ESLint: 9.27.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/lib/index.js' imported from /eslint.config.js
at finalizeResolution (node:internal/modules/esm/resolve:274:11)
at moduleResolve (node:internal/modules/esm/resolve:859:10)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:170:49)

test/rules/no-unresolved.spec.ts

Oops! Something went wrong! :(

ESLint: 9.27.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/lib/index.js' imported from /eslint.config.js
at finalizeResolution (node:internal/modules/esm/resolve:274:11)
at moduleResolve (node:internal/modules/esm/resolve:859:10)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:170:49)


📜 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 e5fff03 and e0eb9a2.

📒 Files selected for processing (2)
  • src/utils/resolve.ts (5 hunks)
  • test/rules/no-unresolved.spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/rules/no-unresolved.spec.ts
🧰 Additional context used
🧠 Learnings (1)
src/utils/resolve.ts (1)
Learnt from: SukkaW
PR: un-ts/eslint-plugin-import-x#272
File: src/utils/resolve.ts:0-0
Timestamp: 2025-03-30T14:44:11.779Z
Learning: In eslint-plugin-import-x's node resolver, the `modules` parameter of `createNodeResolver` function accepts both string and string array types, making it flexible when passing values like `moduleDirectory`.
⏰ Context from checks skipped due to timeout of 90000ms (21)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js lts/* and ESLint 9 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
  • GitHub Check: Lint and Test with Node.js 24 and ESLint 9 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 24 and ESLint 8 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8 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 20 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 18 and ESLint 8.56 on windows-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 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on ubuntu-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 18 and ESLint 8 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 20 and ESLint 8.56 on macos-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on macos-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on macos-latest
🔇 Additional comments (5)
src/utils/resolve.ts (5)

122-220: Excellent implementation of legacy node resolver with comprehensive fallback support

The legacyNodeResolve function provides a well-structured approach to handling legacy resolver options while maintaining backward compatibility. Key strengths:

  • Proper separation of concerns with destructuring of resolver options
  • Graceful fallback to legacy resolver when package-related options are detected
  • Clear error messaging when legacy resolver is not available
  • Efficient path resolution with dual attempt strategy (modules first, then paths)

The implementation correctly handles the transition from legacy to new resolver while preserving existing functionality.


248-253: Improved cache key uniqueness with null character separators

Using null characters (\0) as separators in cache keys is an excellent improvement that ensures better uniqueness compared to concatenation with regular characters that might appear in file paths.


311-334: Well-implemented legacy node resolver integration

The integration logic correctly identifies legacy node resolvers and applies the new resolution strategy with appropriate fallback handling. The conditional check for resolver existence prevents unnecessary processing when the legacy resolver is not available.


190-219: Clear and actionable error message for missing legacy resolver

The error handling provides excellent guidance to users when legacy options are used but the fallback resolver is not available. The multi-line error message clearly explains the problem and offers concrete solutions.


164-188:

✅ Verification successful

Validate paths filtering logic

The logic filters out paths that are already included in modules, but this may not align with the intended behavior where paths should only be used as a fallback when modules fails to resolve.

Based on past discussions, paths should only be applied when moduleDirectory fails to resolve. Please verify that the current filtering approach correctly implements this fallback behavior rather than just deduplicating paths.


🏁 Script executed:

#!/bin/bash
# Check how paths option is documented and used in the legacy resolver
echo "Searching for paths option usage in legacy resolver documentation and tests"
rg -C 5 "paths.*option|paths.*moduleDirectory" --type ts --type js

Length of output: 229


🏁 Script executed:

#!/bin/bash
# Locate createNodeResolver definition
echo "Searching for createNodeResolver in the codebase"
rg -C5 "createNodeResolver" 

Length of output: 8793


I need to see the code around the modules and paths resolution to confirm logic. Let's dump lines 140–220 of src/utils/resolve.ts.


🏁 Script executed:

#!/bin/bash
# Dump the surrounding logic in resolve util to verify primary and fallback resolution order
sed -n '140,240p' src/utils/resolve.ts

Length of output: 2460


Paths fallback logic is correct

The code first attempts resolution with moduleDirectory and only falls back to paths if that initial resolve fails. It also filters out any entries in paths that overlap with moduleDirectory to avoid redundant lookups. No changes required here.

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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

@Copilot 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 migrates the legacy "import-x/resolve" option to use the new built-in Node resolver, improving consistency and removing unsupported legacy options.

  • Updates the resolution logic in src/utils/resolve.ts to utilize the new node resolver for backward compatibility.
  • Renames type definitions from NodeResolverOptions to LegacyNodeResolverOptions in both src/utils/legacy-resolver-settings.ts and src/types.ts.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/utils/resolve.ts Implements new resolution logic using createNodeResolver and updates branch logic for legacy settings.
src/utils/legacy-resolver-settings.ts Updates type imports to use LegacyNodeResolverOptions for legacy resolver configurations.
src/types.ts Renames NodeResolverOptions to LegacyNodeResolverOptions and updates associated documentation.
Comments suppressed due to low confidence (2)

src/utils/resolve.ts:107

  • [nitpick] The variable name 'nodeResolverInstanceForLegacyNodeResolverSettings' is overly verbose. Consider renaming it to 'legacyNodeResolver' or a similar concise identifier.
let nodeResolverInstanceForLegacyNodeResolverSettings: NewResolver | null = null

src/utils/resolve.ts:168

  • The new branch for handling legacy 'import-x/resolve' options should be accompanied by test cases to validate its behavior. Consider adding tests that cover both successful and unsuccessful resolution scenarios.
else if ( Object.prototype.hasOwnProperty.call(settings, 'import-x/resolve') && settings['import-x/resolve'] ) {

Copy link

codesandbox-ci bot commented Mar 30, 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

pkg-pr-new bot commented Mar 30, 2025

Open in StackBlitz

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

commit: e0eb9a2

@SukkaW SukkaW force-pushed the replace-eslint-import-resolver-node branch from 7dab322 to 2a66b0a Compare March 30, 2025 13:02
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.

Actionable comments posted: 8

🧹 Nitpick comments (2)
src/utils/resolve.ts (1)

114-114: Variable initialization concern

This variable is declared but only conditionally initialized. Consider using let nodeResolverInstanceForLegacyNodeResolverSettings: NewResolver | undefined to make nullability explicit.

-let nodeResolverInstanceForLegacyNodeResolverSettings: NewResolver
+let nodeResolverInstanceForLegacyNodeResolverSettings: NewResolver | undefined
🧰 Tools
🪛 GitHub Actions: Publish Any Commit

[error] Circular dependency: src/utils/resolve.ts -> src/utils/legacy-resolver-settings.ts -> src/utils/resolve.ts

src/types.ts (1)

45-48: Document the reason for noop properties

Properties marked as "Noop now" should have a clearer explanation of why they've been deprecated or marked as noop, especially since they were previously functional as indicated by the comments.

-  /** Noop now, Previously a directory to begin resolving from */
+  /** Noop now. Previously a directory to begin resolving from. These legacy options are maintained for backward compatibility but no longer affect resolution. */
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7dab322c2fc41bbf101f249acf0549aab1c15e2b and 2a66b0a.

📒 Files selected for processing (3)
  • src/types.ts (2 hunks)
  • src/utils/legacy-resolver-settings.ts (3 hunks)
  • src/utils/resolve.ts (3 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
src/utils/resolve.ts (2)
src/types.ts (1)
  • NewResolver (86-91)
src/utils/legacy-resolver-settings.ts (2)
  • normalizeConfigResolvers (103-155)
  • resolveWithLegacyResolver (75-101)
🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 8.56 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 8.56 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 8.56 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: publish
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Actions: Publish Any Commit
src/types.ts

[error] 124-124: error TS2552: Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[warning] 24-24: "import.meta" is not available in the configured target environment ("es2015") and will be empty [empty-import-meta]


[error] Circular dependency: src/utils/resolve.ts -> src/utils/legacy-resolver-settings.ts -> src/utils/resolve.ts

🪛 GitHub Actions: CI
src/types.ts

[error] 124-124: error TS2552: Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[warning] 24-24: "import.meta" is not available in the configured target environment ("es2015") and will be empty

🔇 Additional comments (3)
src/utils/resolve.ts (2)

175-181: Consider extracting settings to a variable

The settings['import-x/resolve'] is accessed multiple times. Consider extracting it to a variable for better readability and maintainability.

-  } else if (
-    // backward compatibility for very old `import-x/resolve` options that is no longer supported
-    Object.prototype.hasOwnProperty.call(settings, 'import-x/resolve') &&
-    settings['import-x/resolve']
-  ) {
-    const resolveSettings = settings['import-x/resolve']
+  } else if (
+    // backward compatibility for very old `import-x/resolve` options that is no longer supported
+    Object.prototype.hasOwnProperty.call(settings, 'import-x/resolve') &&
+    settings['import-x/resolve']
+  ) {
+    const resolveSettings = settings['import-x/resolve']

This was already suggested in a previous review and implemented in a later commit.

🧰 Tools
🪛 GitHub Actions: Publish Any Commit

[error] Circular dependency: src/utils/resolve.ts -> src/utils/legacy-resolver-settings.ts -> src/utils/resolve.ts


182-188: Verify semantic equivalence between options

There may be a semantic mismatch between includeCoreModules (legacy) and builtinModules (new API).

-      builtinModules: resolveSettings.includeCoreModules !== false,
+      builtinModules: resolveSettings.includeCoreModules !== false,

This was flagged in a previous review. If includeCoreModules: false means "exclude core modules" in the legacy API, verify that builtinModules: false has the same meaning in the new API.

What's the difference between builtinModules and includeCoreModules in Node.js module resolution?
🧰 Tools
🪛 GitHub Actions: Publish Any Commit

[error] Circular dependency: src/utils/resolve.ts -> src/utils/legacy-resolver-settings.ts -> src/utils/resolve.ts

src/types.ts (1)

42-42:

✅ Verification successful

Verify moduleDirectory type compatibility

The type of moduleDirectory has been changed from what was likely an array to a single string. Make sure this is compatible with how it's used in the resolution logic.


🏁 Script executed:

#!/bin/bash
# Check for usages of moduleDirectory in the codebase
echo "Checking how moduleDirectory is used:"
rg "moduleDirectory" --include "*.ts" .

Length of output: 566


Action Required: Verify the moduleDirectory Type Usage

The moduleDirectory field in src/types.ts has been changed from an array to a string. The initial search using --include resulted in an error, so please re-run the query with the corrected flag to check how moduleDirectory is used throughout the code. For example, you can use the following script:

Once you verify that all usages of moduleDirectory expect a string (and not an array), you can confirm that the resolution logic remains correct. If any usage still treats it as an array, additional adjustments may be required.


🏁 Script executed:

#!/bin/bash
echo "Searching for usages of moduleDirectory in .ts files:"
rg "moduleDirectory" -g "*.ts" .

Length of output: 384


Confirmed: moduleDirectory Type Compatibility is Consistent

Based on the verification:

  • In src/types.ts, moduleDirectory is defined as an optional string.
  • In src/utils/resolve.ts, moduleDirectory is used by simply passing it to the modules field without any array-specific operations.
  • No evidence was found that any part of the resolution logic still expects moduleDirectory to be an array.

The change from an array to a string appears compatible with the current usage in the resolution logic.

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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/types.ts (1)

45-48: Consider adding modules parameter support

Based on the previous review comments, there's a discussion about basedir and paths. It appears that modules is the replacement for paths in the new resolver.

Consider adding a comment about how users can migrate from paths to the modern equivalent in the new resolver, if applicable. This would help with the migration and backwards compatibility.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2a66b0a and 28189c5.

📒 Files selected for processing (2)
  • src/types.ts (2 hunks)
  • src/utils/resolve.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/utils/resolve.ts
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • 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 9 on windows-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
🔇 Additional comments (4)
src/types.ts (4)

37-64: Interface name change aligns with migration to built-in resolver

The renaming from NodeResolverOptions to LegacyNodeResolverOptions clearly indicates this is for backward compatibility while the codebase migrates to the new built-in node resolver. The addition of properties marked as "Noop now" maintains the interface signature while properly documenting which options are no longer functional.


50-63: Effective use of the never type for no-op properties

Using the never type for deprecated properties is a good practice. It ensures TypeScript will raise an error if someone tries to use these properties, while still maintaining the interface shape for backward compatibility.


124-124: Property correctly updated to use new interface name

The property type has been correctly updated to reference the renamed interface, fixing the build failures noted in the previous review comments.


41-42:

❓ Verification inconclusive

Comment and type are inconsistent for moduleDirectory

The comment mentions "directory (or directories)" but the type has been changed from string[] to string, which only allows a single directory.

-  /** directory (or directories) in which to recursively look for modules. Default "node_modules" */
-  moduleDirectory?: string
+  /** directory in which to recursively look for modules. Default "node_modules" */
+  moduleDirectory?: string

Please verify if the built-in resolver supports multiple directories. If it does, consider using string | string[] to maintain backward compatibility.


🏁 Script executed:

#!/bin/bash
# Check if unrs-resolver supports multiple directories for moduleDirectory
rg -F "moduleDirectory" --context 10 --type ts node_modules/unrs-resolver

Length of output: 73


Action Required: Confirm Multi-Directory Support

The automated search did not reveal any indication that the built-in resolver supports multiple directories for moduleDirectory. At this point, the change updating the comment to suggest only a single directory (with the type remaining as string) appears appropriate. However, if the resolver actually supports an array (i.e., multiple directories), the type should be updated to string | string[] to maintain backward compatibility.

  • Location: src/types.ts at lines 41–42
  • Next Step: Please manually verify the built-in resolver’s source or documentation to confirm whether it accepts multiple directories for moduleDirectory. If it does, update the type accordingly; otherwise, the current single-string approach is correct.

Copy link

socket-security bot commented Mar 31, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedeslint-import-context@​0.1.5 ⏵ 0.1.671 +110093 +191 +1100
Addedeslint-plugin-json@​4.0.110010010077100
Updatedunrs-resolver@​1.7.2 ⏵ 1.7.591 +110081 +194 +5100
Updatedtinyglobby@​0.2.13 ⏵ 0.2.1410010091 +191100
Addedeslint-plugin-mdx@​3.4.29910010092100
Updatedeslint-import-resolver-typescript@​4.4.0 ⏵ 4.4.19910010097 +1100
Updated@​unrs/​resolver-binding-win32-x64-msvc@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-win32-arm64-msvc@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-win32-ia32-msvc@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-linux-x64-gnu@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-linux-x64-musl@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-freebsd-x64@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-linux-arm64-gnu@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-linux-arm64-musl@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-linux-arm-gnueabihf@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-linux-arm-musleabihf@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-linux-ppc64-gnu@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-linux-riscv64-gnu@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +13100
Updated@​unrs/​resolver-binding-linux-riscv64-musl@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +17100
Updated@​unrs/​resolver-binding-linux-s390x-gnu@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-darwin-x64@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-darwin-arm64@​1.7.2 ⏵ 1.7.5100 +1100100 +64100 +12100
Updated@​unrs/​resolver-binding-wasm32-wasi@​1.7.2 ⏵ 1.7.5100 +1100100 +35100 +12100

View full report

@JounQin
Copy link
Member

JounQin commented Mar 31, 2025

@SukkaW Do you want me to wait #273 for this PR?

@SukkaW
Copy link
Collaborator Author

SukkaW commented Apr 1, 2025

@SukkaW Do you want me to wait #273 for this PR?

Let's do this in a separate release then. Feel free to drop a release now!

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.

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/types.ts (3)

47-48: Fix incomplete comment for paths property

The comment for the paths property is incomplete and doesn't fully explain its previous purpose.

-  /** Noop now. Previously for require.paths array to */
+  /** Noop now. Previously for require.paths array to use if nothing is found on the normal node_modules recursive walk */

39-44: Consider adding default values in comments

For properties like includeCoreModules, moduleDirectory, and preserveSymlinks, it would be helpful to include their default values in the comments to provide better guidance for users.

-  /** set to `false` to exclude node core modules (e.g.` fs`) from the search */
+  /** set to `false` to exclude node core modules (e.g.` fs`) from the search. Default: true */
-  /** directory (or directories) in which to recursively look for modules. Default "node_modules" */
+  /** directory in which to recursively look for modules. Default: "node_modules" */
-  /** if true, doesn't resolve basedir to real path before resolving. This is the way Node resolves dependencies when executed with the --preserve-symlinks flag. Default to true */
+  /** if true, doesn't resolve basedir to real path before resolving. This is the way Node resolves dependencies when executed with the --preserve-symlinks flag. Default: true */

45-63: Ensure consistency in comment style

There's a slight inconsistency in the comment style for the noop properties. Some use "Noop now, Previously..." while others use "Noop now. Previously..." (with a period).

Consider standardizing to one style for consistency, preferably "Noop now. Previously..." (with a period) as it's used more frequently in the code.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2b0fce1 and d21b8d8.

📒 Files selected for processing (2)
  • src/types.ts (2 hunks)
  • src/utils/resolve.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/utils/resolve.ts
🔇 Additional comments (2)
src/types.ts (2)

37-64: LGTM: Interface structure is clear with appropriate documentation

The LegacyNodeResolverOptions interface is well-organized with clear documentation of which options are now no-ops versus those that remain functional. This approach properly maintains backward compatibility while moving to the new built-in node resolver.


124-124: Properly updated type reference in ImportSettings

This properly updates the type reference to use the new LegacyNodeResolverOptions interface.

@SukkaW SukkaW requested a review from JounQin April 1, 2025 13:33
@SukkaW SukkaW closed this Apr 2, 2025
@JounQin JounQin reopened this Apr 2, 2025
Copy link

sonarqubecloud bot commented Apr 2, 2025

@JounQin JounQin marked this pull request as draft April 11, 2025 03:58
@JounQin JounQin self-assigned this Apr 11, 2025
@JounQin JounQin force-pushed the replace-eslint-import-resolver-node branch from f47e353 to dd566e1 Compare May 27, 2025 04:48
@JounQin JounQin marked this pull request as ready for review May 27, 2025 04:52
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 dd566e1 in 2 minutes and 18 seconds. Click for details.
  • Reviewed 365 lines of code in 7 files
  • Skipped 1 files when reviewing.
  • Skipped posting 12 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. .github/workflows/ci.yml:35
  • Draft comment:
    Matrix entry 'noLegacyNodeResolver' is added to test removal of the legacy resolver; configuration looks good.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative, as it only states that a matrix entry was added and that the configuration looks good. It doesn't provide any actionable feedback or suggestions for improvement.
2. .github/workflows/ci.yml:57
  • Draft comment:
    Conditional step to uninstall the legacy resolver is clear and properly gated by the matrix flag.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative, praising the clarity and gating of a conditional step. It doesn't provide any actionable feedback or suggestions for improvement.
3. package.json:67
  • Draft comment:
    Marking 'eslint-import-resolver-node' as an optional peer dependency and updating related versions is appropriate; ensure consistency between peer and direct dependency versions.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
4. src/utils/arraify.ts:1
  • Draft comment:
    The 'arraify' utility is concise and properly converts its input to an array (or undefined); the implementation is clear.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative and does not provide any actionable feedback or suggestions for improvement. It simply praises the existing code without offering any constructive criticism or questions.
5. src/utils/index.ts:13
  • Draft comment:
    Exporting 'arraify' via the index file improves convenience in importing utilities.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative, as it simply states that exporting arraify via the index file improves convenience. It does not provide any actionable feedback or suggestions for improvement.
6. src/utils/legacy-resolver-settings.ts:70
  • Draft comment:
    Caching the result of requireResolver into a local 'resolver' variable avoids duplicate calls and is a good performance improvement.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative, as it only states that caching the result of requireResolver is a performance improvement. It does not provide any actionable feedback or suggestions for improvement.
7. src/utils/legacy-resolver-settings.ts:119
  • Draft comment:
    The check for LEGACY_NODE_RESOLVERS to ignore missing resolvers (returning undefined) is intended for fallback; consider leaving a brief comment explaining why undefined is returned.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking for an explanation, which violates the rule against asking the PR author to explain their intention. It doesn't provide a specific suggestion or point out a potential issue with the code.
8. src/utils/resolve.ts:122
  • Draft comment:
    The new 'legacyNodeResolve' function cleanly implements fallback logic using various resolution strategies; verify that the filtering of normalizedPaths meets the intended behavior.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is asking the PR author to verify the behavior of a function, which is against the rules. It does not provide a specific suggestion or point out a clear issue.
9. src/utils/resolve.ts:238
  • Draft comment:
    Using '\0' as a separator for the cache key is a clever technique to minimize collisions; ensure that file paths will not contain this character.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking to ensure that file paths do not contain a specific character when used as a separator for a cache key. This is a request for verification, which violates the rule against asking the PR author to ensure behavior is intended or tested.
10. src/utils/resolve.ts:302
  • Draft comment:
    The fallback branch for legacy node resolvers (checking if name is in LEGACY_NODE_RESOLVERS and resolver is missing) correctly triggers the new node resolver logic; continue the loop if resolution isn’t found.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative and does not provide any actionable feedback or suggestions for improvement. It simply states that something is working correctly, which violates the rule against making purely informative comments.
11. src/utils/index.ts:13
  • Draft comment:
    Typo: The file name 'arraify.js' on this line might be a misspelling. Consider verifying if it should be 'arrayify.js'.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% While 'arrayify' might be a more common spelling, 'arraify' could be intentional. Without seeing the actual file or understanding the codebase's conventions, I can't be certain this is a typo. The comment is speculative and asks for verification, which violates our rules about not asking authors to verify things. If this really is a typo, it would cause a build error since the file wouldn't exist. Also, the spelling could be intentional - 'arraify' might be the intended name. Since this would cause a build error if incorrect, and we're told to not comment on things that would be caught by the build, this comment is unnecessary. Delete this comment. If the filename is wrong, it would be caught by the build system, and we can't be certain it's actually a typo without more context.
12. src/utils/resolve.ts:301
  • Draft comment:
    Typo in comment: consider adding an article so it reads 'as a fallback instead' instead of 'as fallback instead'.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50% This is a purely stylistic change to a comment that doesn't affect code functionality or clarity. The meaning is perfectly clear either way. The rules state not to make purely informative comments or unimportant changes. Grammar nitpicks in comments definitely fall into this category. The grammar suggestion is technically correct - "as a fallback" is more proper English than "as fallback". While technically correct, this kind of minor grammar fix in comments provides no real value and just creates noise in the PR review. This comment should be deleted as it's an unimportant stylistic suggestion about comment grammar that doesn't affect code quality or clarity.

Workflow ID: wflow_P9JWNtEu4O4EZqpM

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

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.

Actionable comments posted: 0

🧹 Nitpick comments (2)
.github/workflows/ci.yml (2)

32-38: Verify matrix includes for fallback testing
You've extended the matrix to explicitly test both the default and the noLegacyNodeResolver scenarios on node: lts/*, eslint: 9, and ubuntu-latest. This ensures we cover the new built-in resolver with and without the legacy package.

Optional: if you’d like linting to run under the no-legacy scenario as well, consider adding executeLint: true to that include entry.


60-63: Optimize placement of the removal step
The “Uninstall Legacy Node Resolver” step currently runs after yarn --immutable, causing a second dependency resolution when the package is removed. To leverage the cached install and avoid extra work, move this step just before installing dependencies:

-      - name: Install Dependencies
-        run: yarn --immutable
+      - name: Uninstall Legacy Node Resolver
+        if: ${{ matrix.noLegacyNodeResolver }}
+        run: yarn remove eslint-import-resolver-node
+      - name: Install Dependencies
+        run: yarn --immutable

This will build the environment without the legacy resolver in a single pass.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d21b8d8 and dd566e1.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (7)
  • .changeset/khaki-sites-teach.md (1 hunks)
  • .github/workflows/ci.yml (2 hunks)
  • package.json (2 hunks)
  • src/utils/arraify.ts (1 hunks)
  • src/utils/index.ts (1 hunks)
  • src/utils/legacy-resolver-settings.ts (3 hunks)
  • src/utils/resolve.ts (5 hunks)
✅ Files skipped from review due to trivial changes (3)
  • .changeset/khaki-sites-teach.md
  • src/utils/index.ts
  • src/utils/arraify.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • package.json
  • src/utils/legacy-resolver-settings.ts
  • src/utils/resolve.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis

@JounQin
Copy link
Member

JounQin commented May 27, 2025

It seems a bug of unrs-resolver that zod resolves to its commonjs version node_modules/zod/lib/index.js instead of node_modules/zod/lib/index.mjs, it recognize zod is commonjs as primary, but ignores our options:

extensions = ['.mjs', '.cjs', '.js', '.json', '.node'],
conditionNames = ['import', 'require', 'default'],
mainFields = ['module', 'main'],


Resolved in unrs/unrs-resolver#115

@JounQin
Copy link
Member

JounQin commented May 28, 2025

Last failing test case due to paths, ./bar vs bar, modules means different in this case, we may need to change the directory parameter in resolver.sync instead:

// ensure resolved path results in warnings
tInvalid({
code: "import { x } from './bar'; import { y } from 'bar';",
output: "import { x, y } from './bar'; ",
settings: {
'import-x/resolve': {
paths: [path.resolve('test/fixtures')],
},
},
// @ts-expect-error path ends up hardcoded
errors: 2,
}),


See nodejs/node#58487

Copy link

codacy-production bot commented May 28, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.14% (target: -1.00%) 84.44%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (3bc48fc) 3626 3474 95.81%
Head commit (115568c) 3669 (+43) 3510 (+36) 95.67% (-0.14%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#272) 45 38 84.44%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@JounQin
Copy link
Member

JounQin commented May 28, 2025

OK... Windows...

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.

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 115568c and bad02d7.

📒 Files selected for processing (1)
  • test/rules/no-unresolved.spec.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (21)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 24 and ESLint 8 on windows-latest
  • GitHub Check: Lint and Test with Node.js lts/* and ESLint 9 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 24 and ESLint 9 on windows-latest
  • GitHub Check: Lint and Test with Node.js lts/* and ESLint 9 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 24 and ESLint 8.56 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 20 and ESLint 8 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
  • GitHub Check: Lint and Test with Node.js 24 and ESLint 8.56 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on ubuntu-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 22 and ESLint 8.56 on macos-latest
  • GitHub Check: Lint and Test with Node.js 24 and ESLint 8.56 on macos-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on macos-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on macos-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on macos-latest

@JounQin JounQin enabled auto-merge (squash) May 30, 2025 13:32
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.

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/utils/resolve.ts (1)

8-9: Address the circular dependency issue.

The pipeline failures indicate a circular dependency between resolve.ts and legacy-resolver-settings.ts. This needs to be resolved to prevent build and runtime issues.

Also applies to: 20-20, 23-23

🧹 Nitpick comments (1)
src/utils/resolve.ts (1)

201-204: Improve error message readability.

The error message is quite long and could be formatted better for readability. Consider breaking it into multiple lines or providing more structured guidance.

-      throw new Error(
-        "You're using legacy resolver options which are not supported by the new resolver and `eslint-import-resolver-node` is not installed as fallback,\nplease install `eslint-import-resolver-node` manually or remove those legacy resolver options including `package`, `packageFilter`, `pathFilter` and `packageIterator`.",
-      )
+      throw new Error([
+        "You're using legacy resolver options which are not supported by the new resolver.",
+        "Please either:",
+        "1. Install `eslint-import-resolver-node` as a fallback, or",
+        "2. Remove legacy options: `package`, `packageFilter`, `pathFilter`, `packageIterator`"
+      ].join('\n'))
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bad02d7 and e5fff03.

📒 Files selected for processing (1)
  • src/utils/resolve.ts (5 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/utils/resolve.ts (1)
Learnt from: SukkaW
PR: un-ts/eslint-plugin-import-x#272
File: src/utils/resolve.ts:0-0
Timestamp: 2025-03-30T14:44:11.779Z
Learning: In eslint-plugin-import-x's node resolver, the `modules` parameter of `createNodeResolver` function accepts both string and string array types, making it flexible when passing values like `moduleDirectory`.
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js lts/* and ESLint 9 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 24 and ESLint 8 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 20 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 windows-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 24 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 24 and ESLint 8 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on ubuntu-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 24 and ESLint 8.56 on macos-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on macos-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on macos-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on macos-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on macos-latest
🔇 Additional comments (3)
src/utils/resolve.ts (3)

145-147: Clarify the symlinks logic.

The comment says "TODO: change the default behavior to align node itself" but the logic appears inverted. If preserveSymlinks is false, symlinks is set to true, which seems counterintuitive. Please verify this logic is correct or add a comment explaining the reasoning.


243-248: Good improvement to cache key uniqueness.

Using null characters ('\0') as separators instead of commas eliminates potential collisions in cache keys since null characters cannot appear in file paths or other cache key components.


304-328: Verify the fallback logic handles all cases correctly.

The logic appears sound but please verify:

  1. When legacyNodeResolve fails but resolver exists, it falls through to use the legacy resolver (lines 325-328)
  2. When legacyNodeResolve fails and no resolver exists, it continues to the next resolver
  3. This ensures proper fallback behavior while avoiding unnecessary legacy resolver calls

The implementation looks correct for the migration strategy.

@JounQin JounQin disabled auto-merge May 30, 2025 13:38
@JounQin JounQin force-pushed the replace-eslint-import-resolver-node branch from e5fff03 to e0eb9a2 Compare May 30, 2025 13:41
@JounQin JounQin enabled auto-merge (squash) May 30, 2025 13:48
@JounQin JounQin merged commit 43cdd21 into un-ts:master May 30, 2025
46 checks passed
@Zamiell
Copy link
Contributor

Zamiell commented Jun 5, 2025

just wanted to say - fantastic work on this SukkaW + all involved!

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.

3 participants