Skip to content

fix: incorrect .d.cts declaration #289

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 3 commits into from
Closed

fix: incorrect .d.cts declaration #289

wants to merge 3 commits into from

Conversation

JounQin
Copy link
Member

@JounQin JounQin commented Apr 12, 2025

microsoft/TypeScript#58195


Important

Fixes incorrect type declaration in index.d.cts by using import type and declaring eslintPluginImportX with the correct type.

  • Bug Fix:
    • Corrects type declaration in index.d.cts by changing import to import type for eslintPluginImportX_.
    • Declares eslintPluginImportX as typeof eslintPluginImportX_ to ensure correct type checking.

This description was created by Ellipsis for 22ac718. It will automatically update as commits are pushed.


Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes
    • Corrected an issue with type declarations in the plugin to enhance stability and ensure consistent behavior during type checking.

@JounQin JounQin requested a review from Copilot April 12, 2025 07:15
Copy link

changeset-bot bot commented Apr 12, 2025

🦋 Changeset detected

Latest commit: 22ac718

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

@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.

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

Copy link

coderabbitai bot commented Apr 12, 2025

Walkthrough

A patch for the eslint-plugin-import-x package resolves an issue with a type declaration in a .d.cts file. The index.d.cts file now declares the eslintPluginImportX entity as a constant with a type derived from an imported module, replacing the previous import statement. The changeset file documents this fix, with no adjustments made to exported or public entity declarations.

Changes

File Change Summary
.changeset/sixty-poets-pay.md Documents the patch addressing the incorrect type declaration in the .d.cts file for the eslint-plugin-import-x package.
index.d.cts Updates the eslintPluginImportX import statement to a type declaration and introduces a new constant declaration for eslintPluginImportX.

Poem

In the code where bugs did lurk,
I, the rabbit, gave a perk.
A patch was laid with gentle might,
Turning import into type so right.
Hop along—code now shines bright!
🐰✨

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.

index.d.cts

Oops! Something went wrong! :(

ESLint: 9.24.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:12841) 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)


📜 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 d0f4141 and 22ac718.

📒 Files selected for processing (1)
  • index.d.cts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • index.d.cts
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: Codacy Static Code Analysis
  • 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 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 22 and ESLint 9 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 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 20 and ESLint 8.56 on windows-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest

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

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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

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.

👍 Looks good to me! Reviewed everything up to 37047ca in 35 seconds

More details
  • Looked at 9 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. index.d.cts:1
  • Draft comment:
    Changed declaration looks correct for a .d.cts file. Ensure that the use of 'typeof import(...)' correctly reflects the exported type from './lib/index.js'.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
2. index.d.cts:1
  • Draft comment:
    Using 'declare const' with 'typeof import' is correct for a .d.cts file. Confirm that the module's export shape (default vs. named) matches your intent.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None

Workflow ID: wflow_rRCromwsFOz81OhG


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

codesandbox-ci bot commented Apr 12, 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 Apr 12, 2025

Open in StackBlitz

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

commit: 22ac718

Copy link

codecov bot commented Apr 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.99%. Comparing base (877bbbb) to head (22ac718).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #289   +/-   ##
=======================================
  Coverage   95.99%   95.99%           
=======================================
  Files          91       91           
  Lines        4745     4745           
  Branches     1784     1763   -21     
=======================================
  Hits         4555     4555           
  Misses        189      189           
  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 JounQin marked this pull request as draft April 12, 2025 07:51
@JounQin JounQin marked this pull request as ready for review April 12, 2025 08:33
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.

👍 Looks good to me! Reviewed everything up to 22ac718 in 58 seconds

More details
  • Looked at 22 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. .changeset/sixty-poets-pay.md:2
  • Draft comment:
    Ensure consistency in changeset YAML formatting; quoted package names are acceptable but verify consistency across changesets.
  • Reason this comment was not posted:
    Confidence changes required: 10% <= threshold 50%
    None
2. index.d.cts:1
  • Draft comment:
    Using 'import type' correctly restricts to type-only import for declaration files. Verify that runtime behavior isn’t affected.
  • Reason this comment was not posted:
    Confidence changes required: 10% <= threshold 50%
    None
3. .changeset/sixty-poets-pay.md:1
  • Draft comment:
    Changeset file is correctly formatted. The version bump and fix description are clear.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
4. index.d.cts:1
  • Draft comment:
    Using 'import type' and the alias with 'declare const' correctly avoids runtime imports. Consider adding a brief comment linking to TS#58195 for future maintainers.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None

Workflow ID: wflow_eAU3pyb6Yg9pCeFp


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@JounQin JounQin closed this Apr 12, 2025
@JounQin JounQin deleted the JounQin-patch-1 branch April 12, 2025 10:21
@JounQin
Copy link
Member Author

JounQin commented Apr 12, 2025

It seems moduleResolution must be set NodeNext to work as expected.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant