Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

error-four-o-four
Copy link
Contributor

@error-four-o-four error-four-o-four commented Jun 8, 2025

Hey there,

this is just a minor fix which updates the metadata of imports-first according to DeprecatedInfo in @eslint/core or rather @typescript-eslint/utils


Important

Updates imports-first rule to use DeprecatedInfo, marking it as deprecated and specifying replacement by import-x/first.

  • Behavior:
    • Updates imports-first rule in src/rules/imports-first.ts to use DeprecatedInfo.
    • Marks imports-first as deprecated with message, URL, and version.
    • Specifies replacement by import-x/first with URL using docsUrl.
  • Imports:
    • Adds docsUrl import from ../utils/index.js.

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

Summary by CodeRabbit

  • Chores
    • Updated deprecation information for the "imports-first" rule to provide more detailed guidance and reference links for users.

Copy link

changeset-bot bot commented Jun 8, 2025

🦋 Changeset detected

Latest commit: c19b39f

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 Jun 8, 2025

Walkthrough

The metadata for the imports-first rule was updated to use a detailed deprecation object instead of a boolean flag. This includes a deprecation message, related URLs, the deprecation version, and information about the replacement rule. The docsUrl utility function was also imported and used. Corresponding tests were enhanced to validate the structure and content of this detailed deprecation metadata. Additionally, a changeset file was added documenting this update as a chore.

Changes

File(s) Change Summary
src/rules/imports-first.ts Replaced deprecated: true with a detailed deprecation object in rule metadata; imported docsUrl utility function.
test/package.spec.ts Updated tests to check that deprecated is an object with detailed keys and verify the structure of the replacedBy array.
.changeset/grumpy-ligers-destroy.md Added a changeset documenting the adoption of the new deprecated: DeprecatedInfo meta rule option as a chore.

Suggested labels

internal

Poem

In the warren of code, a rule takes a bow,
Deprecated with care, and a message for now.
A link to the future, a version in sight,
"First" is the rule, shining bright in the light.
🐇✨


📜 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 820064f and c19b39f.

📒 Files selected for processing (1)
  • .changeset/grumpy-ligers-destroy.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/grumpy-ligers-destroy.md
⏰ Context from checks skipped due to timeout of 90000ms (15)
  • 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 24 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
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 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 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 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 20 and ESLint 9 on macos-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on macos-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on macos-latest
  • GitHub Check: Codacy Static Code Analysis

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

codesandbox-ci bot commented Jun 8, 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 8126b27 in 32 seconds. Click for details.
  • Reviewed 28 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 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/rules/imports-first.ts:10
  • Draft comment:
    Ensure DeprecatedInfo keys meet spec. The deprecation message indicates 'import-x/first' but replacedBy rule name is just 'first'. Consider aligning them.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
2. src/rules/imports-first.ts:16
  • Draft comment:
    Verify that docsUrl('first') returns the correct URL for the replacement rule.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None

Workflow ID: wflow_Tv17AsIuUlDO7SX8

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: 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 924b14f and 8126b27.

📒 Files selected for processing (1)
  • src/rules/imports-first.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/rules/imports-first.ts (1)
src/utils/docs-url.ts (1)
  • docsUrl (5-6)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (2)
src/rules/imports-first.ts (2)

1-1: Verify docsUrl export
Ensure that the docsUrl function is re-exported from src/utils/index.js so this import resolves correctly at runtime.


20-23: Confirm docs metadata URL
If createRule does not auto-populate meta.docs.url, explicitly add:

url: docsUrl('imports-first'),

Otherwise the documentation link may be missing.

Copy link

pkg-pr-new bot commented Jun 8, 2025

Open in StackBlitz

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

commit: c19b39f

@JounQin
Copy link
Member

JounQin commented Jun 8, 2025

@error-four-o-four CI is broken

@error-four-o-four
Copy link
Contributor Author

oh dear
sorry, I absolutely didn't expect tests for a deprecated rule.

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)
test/package.spec.ts (1)

69-89: Comprehensive test for DeprecatedInfo structure is well-implemented.

This test thoroughly validates the ESLint core DeprecatedInfo structure and ensures proper migration from boolean deprecation flags. The validation covers all required properties and structure.

Consider these optional improvements for enhanced type safety and validation:

  it('provides information about deprecated rules', () => {
    expect(module.rules!['imports-first'].meta).not.toHaveProperty('replacedBy')

    expect(typeof module.rules!['imports-first'].meta.deprecated).toBe('object')
-   const deprecated = module.rules!['imports-first'].meta.deprecated as Record<
-     string,
-     unknown
-   >
+   const deprecated = module.rules!['imports-first'].meta.deprecated as {
+     message: string
+     url: string
+     deprecatedSince: string
+     replacedBy: Array<{ message: string; rule: string }>
+   }

    expect(deprecated).toHaveProperty('message')
+   expect(typeof deprecated.message).toBe('string')
    expect(deprecated).toHaveProperty('url')
+   expect(typeof deprecated.url).toBe('string')
    expect(deprecated).toHaveProperty('deprecatedSince')
+   expect(typeof deprecated.deprecatedSince).toBe('string')
    expect(deprecated).toHaveProperty('replacedBy')

    expect(Array.isArray(deprecated.replacedBy)).toBe(true)
-   const replacedBy = deprecated.replacedBy as unknown[]
+   expect(deprecated.replacedBy.length).toBeGreaterThan(0)

-   expect(typeof replacedBy[0]).toBe('object')
-   expect(replacedBy[0]).toHaveProperty('message')
-   expect(replacedBy[0]).toHaveProperty('rule')
+   expect(typeof deprecated.replacedBy[0]).toBe('object')
+   expect(deprecated.replacedBy[0]).toHaveProperty('message')
+   expect(typeof deprecated.replacedBy[0].message).toBe('string')
+   expect(deprecated.replacedBy[0]).toHaveProperty('rule')
+   expect(typeof deprecated.replacedBy[0].rule).toBe('string')
  })
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8126b27 and 8a05b93.

📒 Files selected for processing (2)
  • src/rules/imports-first.ts (2 hunks)
  • test/package.spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/rules/imports-first.ts
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: JounQin
PR: un-ts/eslint-plugin-import-x#378
File: src/rules/imports-first.ts:10-19
Timestamp: 2025-06-08T12:09:38.535Z
Learning: The current implementation in eslint-plugin-import-x uses the correct ESLint core DeprecatedInfo structure: deprecatedSince field and replacedBy array with objects containing rule properties that match the ExternalSpecifier type with name and url fields.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
test/package.spec.ts (1)

65-65: LGTM: Test correctly adapted for DeprecatedInfo structure.

The change from checking deprecated is true to checking it's defined properly accommodates the new structured deprecation metadata format.

@error-four-o-four
Copy link
Contributor Author

I'm still a bit insecure because the added test seems quite exhaustive. Aside from that the test is hardcoded and therefore it's not future-proof in case other rules will be deprecated too. But I'd argue that this could be better handled by @typescript-eslint/utils

The reported messages seem a bit uncaring but on the other hand they're sufficient enough

@error-four-o-four
Copy link
Contributor Author

Just in case: I finally found the related RFC, PR for DeprecatedInfo github comment

@JounQin JounQin changed the title docs: adopt DeprecatedInfo chore: adopt new deprecated: DeprecatedInfo meta rule option Jun 8, 2025
Copy link
Member

@JounQin JounQin left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this, I didn't know about this change at all.

@JounQin JounQin enabled auto-merge (squash) June 8, 2025 16:50
@JounQin JounQin merged commit cdb95ba into un-ts:master Jun 8, 2025
46 checks passed
@error-four-o-four error-four-o-four deleted the docs/adopt-deprecated-info branch June 8, 2025 17:21
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