Skip to content

feat(extensions): support pathGroupOverrides and fix options #327

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 6 commits into from
May 17, 2025

Conversation

JounQin
Copy link
Member

@JounQin JounQin commented May 17, 2025

close #318
close #326


Important

Enhances extensions rule with pathGroupOverrides and fix options, updates documentation, and expands tests.

  • Behavior:
    • Adds pathGroupOverrides and fix options to extensions rule in extensions.ts.
    • Supports selective enforcement based on import path patterns.
    • Introduces automatic fixing and suggestions for import path extensions.
  • Utilities:
    • Adds parsePath and stringifyPath functions in parse-path.ts for handling path strings.
  • Documentation:
    • Updates extensions.md and README.md to document new rule options and fixability.
  • Tests:
    • Expands tests in extensions.spec.ts for new options and TypeScript scenarios.
    • Adds parse-path.spec.ts to test new utility functions.

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


Summary by CodeRabbit

  • New Features

    • Enhanced the import extensions rule with support for path group overrides, allowing selective enforcement based on import path patterns.
    • Introduced automatic fixing and suggestions for missing or unwanted import path extensions.
    • Added new utility functions for parsing and stringifying path strings.
  • Documentation

    • Updated rule documentation and README to reflect new fixability and override features.
    • Added detailed notes on automatic and manual fixing options.
  • Tests

    • Expanded test coverage for the extensions rule, including autofix, override patterns, and TypeScript scenarios.
    • Added tests for the new path parsing utility.

@JounQin JounQin self-assigned this May 17, 2025
@JounQin JounQin added the enhancement New feature or request label May 17, 2025
Copy link

changeset-bot bot commented May 17, 2025

🦋 Changeset detected

Latest commit: 1474a62

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

Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.03% (target: -1.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (de7bae3) 3574 3416 95.58%
Head commit (dc718b1ce19e997b21d36ad52dd7fc2b8b9c846c) 3596 (+22) 3438 (+22) 95.61% (+0.03%)

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 (#327) 30 30 100.00%

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

Copy link

coderabbitai bot commented May 17, 2025

Walkthrough

This update enhances the extensions ESLint rule by introducing fix and pathGroupOverrides options, enabling automatic fixes and path-specific override behaviors. Supporting utility functions and tests are added, and documentation is updated to reflect these new capabilities, including details on fixability and usage examples.

Changes

File(s) Change Summary
.github/workflows/ci.yml Updated Node.js matrix to include v24 and adjusted lint job config.
README.md, docs/rules/extensions.md Updated documentation to indicate the extensions rule is fixable, added notes on autofix, and removed an unrelated reference.
src/rules/extensions.ts Enhanced the extensions rule with fix and pathGroupOverrides options, added autofix logic, updated schema, and improved enforcement logic.
src/utils/parse-path.ts, src/utils/index.ts Added new utility module for parsing and stringifying path strings and exported it via the utils index.
test/rules/extensions.spec.ts Expanded test coverage for the extensions rule, including cases for autofix, path group overrides, and suggestions.
test/utils/parse-path.spec.ts Added tests for the new path parsing and stringifying utility functions.

Sequence Diagram(s)

sequenceDiagram
    participant ESLint
    participant ExtensionsRule
    participant Utils(parsePath)
    participant UserConfig

    ESLint->>ExtensionsRule: Analyze import statement
    ExtensionsRule->>UserConfig: Retrieve fix and pathGroupOverrides options
    ExtensionsRule->>Utils(parsePath): Parse import path
    ExtensionsRule->>ExtensionsRule: Compute override action
    alt Action is 'enforce'
        ExtensionsRule->>ExtensionsRule: Check for extension issues
        alt Issue found and fix enabled
            ExtensionsRule->>ESLint: Apply autofix
        else Issue found and fix disabled
            ExtensionsRule->>ESLint: Suggest fix
        end
    else Action is 'ignore'
        ExtensionsRule->>ESLint: Skip enforcement
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Add fix option to extensions rule for auto-fixing extension usage (#318, #326)
Add pathGroupOverrides option for path-specific override behavior in extensions rule (#326)
Update schema and options in extensions.ts to support new options (#326)
Modify rule logic to respect pathGroupOverrides and apply autofix (#318, #326)

Poem

🐇
A hop and a skip, extensions now mend,
With fixes that auto, and overrides to send.
Paths parsed with care, in patterns they flow,
Suggestions and tests help confidence grow.
So code on, dear friend, with rules by your side—
This bunny brings fixes, with pride open wide!

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/parse-path.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:163:49)

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

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


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 79ab3ac and 1474a62.

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

Walkthrough

This pull request introduces support for fix and pathGroupOverrides options in the extensions rule. It enhances the rule to allow automatic and manual fixes for import path extensions and provides more granular control over path group behaviors.

Changes

File Summary
.github/workflows/ci.yml Minor changes to CI workflow configuration.
README.md Updated to reflect new rule capabilities and options.
docs/rules/extensions.md Added documentation for new fix and pathGroupOverrides options.
src/rules/extensions.ts Implemented logic for fix and pathGroupOverrides options, including schema and rule adjustments.
src/utils/index.ts Exported new utility functions for path parsing.
src/utils/parse-path.ts New utility functions for parsing and stringifying paths.
test/rules/extensions.spec.ts Added tests for new options and behaviors in the extensions rule.
test/utils/snapshots/parse-path.spec.ts.snap Snapshot updates for path parsing tests.
test/utils/parse-path.spec.ts New tests for path parsing utilities.

Copy link

codesandbox-ci bot commented May 17, 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

codecov bot commented May 17, 2025

Codecov Report

Attention: Patch coverage is 98.18182% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.04%. Comparing base (de7bae3) to head (1474a62).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/rules/extensions.ts 97.36% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #327      +/-   ##
==========================================
+ Coverage   96.02%   96.04%   +0.01%     
==========================================
  Files          92       93       +1     
  Lines        4758     4802      +44     
  Branches     1789     1818      +29     
==========================================
+ Hits         4569     4612      +43     
- Misses        188      189       +1     
  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.

Copy link

pkg-pr-new bot commented May 17, 2025

Open in StackBlitz

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

commit: 1474a62

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.

Caution

Changes requested ❌

Reviewed everything up to dc718b1ce19e997b21d36ad52dd7fc2b8b9c846c in 1 minute and 43 seconds. Click for details.
  • Reviewed 725 lines of code in 9 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 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/extensions.ts:164
  • Draft comment:
    Non-intuitive behavior in buildProperties: if the defaultConfig is 'ignorePackages', it is converted to 'always' and ignorePackages is set to true. This conversion might be confusing—please ensure that the rationale is clearly documented or consider a more explicit handling of this scenario.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_vWfHGOQNP2wckNMD

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

Copy link

codacy-production bot commented May 17, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.03% (target: -1.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (de7bae3) 3574 3416 95.58%
Head commit (1474a62) 3596 (+22) 3438 (+22) 95.61% (+0.03%)

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 (#327) 30 30 100.00%

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 JounQin force-pushed the feat/extensions-fix-and-overrides branch from dc718b1 to ffe866c Compare May 17, 2025 17:04
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 2

🧹 Nitpick comments (6)
test/utils/parse-path.spec.ts (1)

1-20: Well-structured tests for new path parsing utilities

The test suite effectively validates both the parsing and stringifying functions with a good variety of path formats, including paths with query parameters and hash fragments. This ensures the utilities will correctly handle complex import paths when fixing extension issues.

A few additional test cases that might be worth considering:

  1. Paths with file extensions (e.g., 'foo.js', 'foo.js?query')
  2. Paths with multiple dots (e.g., 'foo.bar.js')
  3. Paths with special characters or URL-encoded components
     const cases = [
       'foo',
       'foo?query',
       'foo#hash',
       'foo?query#hash',
       'foo#hash?query',
+      'foo.js',
+      'foo.js?query',
+      'foo.bar.js',
+      'module/path.with.dots.js',
+      'path/with%20space.js',
     ]
src/utils/parse-path.ts (2)

7-22: Add explicit return type for stronger type-safety

parsePath currently relies on type inference. Returning ParsedPath explicitly prevents accidental shape changes and makes the intent clearer.

-export const parsePath = (path: string) => {
+export const parsePath = (path: string): ParsedPath => {

24-25: Also type stringifyPath’s return value

For symmetry with parsePath and to avoid widening to any, declare the string return type.

-export const stringifyPath = ({ pathname, query, hash }: ParsedPath) =>
-  pathname + query + hash
+export const stringifyPath = (
+  { pathname, query, hash }: ParsedPath,
+): string => pathname + query + hash
src/rules/extensions.ts (3)

155-162: Merging overrides arrays instead of overwriting

result.pathGroupOverrides is replaced by every matching option object,
so only the last array survives. Concatenating preserves all user
configuration.

-    if (Array.isArray(obj.pathGroupOverrides)) {
-      result.pathGroupOverrides = obj.pathGroupOverrides
-    }
+    if (Array.isArray(obj.pathGroupOverrides)) {
+      result.pathGroupOverrides.push(...obj.pathGroupOverrides)
+    }

180-188: Default minimatch options are dropped when user options exist

Passing patternOptions || { nocomment: true } omits the safe default
when the user supplies their own options. Consider shallow-merging
instead ({ nocomment: true, ...patternOptions }).


355-360: Autofix forces double-quotes

JSON.stringify always produces double-quoted strings and may clash
with the project’s preferred quote style. Using
context.sourceCode.getText(source) or preserving the original quotes
would avoid noisy diffs.

🛑 Comments failed to post (2)
src/rules/extensions.ts (2)

76-80: ⚠️ Potential issue

patternOptions is mis-typed

minimatch expects a single MinimatchOptions object, not a map.
Using Record<string, MinimatchOptions> both confuses intent and breaks
autocomplete.

-export interface PathGroupOverride {
-  pattern: string
-  patternOptions?: Record<string, MinimatchOptions>
-  action: 'enforce' | 'ignore'
-}
+export interface PathGroupOverride {
+  pattern: string
+  /** options forwarded to minimatch() */
+  patternOptions?: MinimatchOptions
+  action: 'enforce' | 'ignore'
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

export interface PathGroupOverride {
  pattern: string
  /** options forwarded to minimatch() */
  patternOptions?: MinimatchOptions
  action: 'enforce' | 'ignore'
}
🤖 Prompt for AI Agents
In src/rules/extensions.ts around lines 76 to 80, the patternOptions property in
the PathGroupOverride interface is incorrectly typed as a Record<string,
MinimatchOptions> when it should be a single MinimatchOptions object. Change the
type of patternOptions from Record<string, MinimatchOptions> to MinimatchOptions
to match the expected usage by minimatch and improve clarity and autocomplete
support.

131-136: 🛠️ Refactor suggestion

Old-structure detector ignores new properties

An options object that contains only fix or pathGroupOverrides
is wrongly classified as a “pattern map”, silently discarding those
fields.

-    if (
-      (!('pattern' in obj) || obj.pattern == null) &&
-      obj.ignorePackages == null &&
-      obj.checkTypeImports == null
-    ) {
+    if (
+      (!('pattern' in obj) || obj.pattern == null) &&
+      obj.ignorePackages == null &&
+      obj.checkTypeImports == null &&
+      obj.fix == null &&
+      obj.pathGroupOverrides == null
+    ) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    // If this is not the new structure, transfer all props to result.pattern
    if (
      (!('pattern' in obj) || obj.pattern == null) &&
      obj.ignorePackages == null &&
      obj.checkTypeImports == null &&
      obj.fix == null &&
      obj.pathGroupOverrides == null
    ) {
🤖 Prompt for AI Agents
In src/rules/extensions.ts around lines 131 to 136, the condition detecting the
old structure incorrectly classifies objects containing only the new properties
'fix' or 'pathGroupOverrides' as a pattern map, causing those fields to be
discarded. Update the condition to explicitly check for the presence of these
new properties and ensure that objects containing only 'fix' or
'pathGroupOverrides' are not treated as old structure, preserving those fields
correctly.

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.

Caution

Changes requested ❌

Reviewed ffe866c in 2 minutes and 2 seconds. Click for details.
  • Reviewed 726 lines of code in 9 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 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/extensions.ts:164
  • Draft comment:
    The block that converts a default config of 'ignorePackages' into 'always' and sets ignorePackages to true may not be immediately obvious. Consider adding a comment (or ensure documentation) to clarify this behavior.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. src/utils/parse-path.ts:7
  • Draft comment:
    The parsePath function correctly parses the pathname, query, and hash parts even for nonstandard orders (e.g. 'foo#hash?query'). Consider documenting that it preserves the original segment order if it doesn’t follow standard URL format.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% The code is straightforward URL parsing that splits on standard delimiters. The comment seems to be making assumptions about edge cases that aren't clearly demonstrated in the code. The behavior for non-standard formats isn't explicitly handled - it just uses basic string operations. The code might actually have special handling for non-standard formats that I'm missing. There could be important edge cases that make this documentation valuable. The code is simple string parsing using standard delimiters. Any "preservation of order" is just a natural result of the basic string operations, not a special feature worth documenting. The comment should be deleted as it suggests documenting behavior that isn't a special feature of the code, just an implementation detail of basic string parsing.
3. src/rules/extensions.ts:367
  • Draft comment:
    Good use of the suggestion mechanism: when the 'fix' option isn’t enabled, providing a suggestion (with messageId 'addMissing') ensures editors can guide the developer to apply the appropriate fix.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative, explaining the use of a suggestion mechanism without providing any actionable feedback or code suggestions. It doesn't align with the rules for good comments, which should provide specific suggestions or ask for clarifications on potential issues.
4. test/rules/extensions.spec.ts:20
  • Draft comment:
    The test suite for the 'extensions' rule is very comprehensive, covering various scenarios including type imports, query strings, and both auto-fix and suggestion cases. Great job ensuring wide coverage.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
5. test/rules/extensions.spec.ts:975
  • Draft comment:
    Typo/grammar suggestion: The comment reads "// pathGroupOverrides: an enforce pattern matches bad bespoke specifiers". Consider rephrasing it (e.g., "// pathGroupOverrides: a pattern that enforces correct matching for bespoke specifiers") for clarity.
  • 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% This is a purely stylistic suggestion about the wording of a test description comment. It doesn't affect functionality or code quality. The original comment is clear enough to understand the test case's purpose. The suggested rewording doesn't add significant clarity or value. The suggested wording might be slightly more grammatically correct. Test descriptions are important for maintainability. While test descriptions are important, the original wording is sufficiently clear and the change is too minor to warrant a comment. This falls under "do not make purely informative comments" and "do not make comments that are obvious or unimportant". Delete this comment as it's a minor stylistic suggestion that doesn't meaningfully improve code quality or clarity.

Workflow ID: wflow_f4nxuk1IZaBCMEkx

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

)
const fixedImportPath = stringifyPath({
pathname: `${
/([\\/]|[\\/]?\.?\.)$/.test(pathname)
Copy link

Choose a reason for hiding this comment

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

Consider adding an inline comment explaining the regex /([\/]|[\/]?\.?\\.)$/ used here to decide whether to append /index.<extension> (for directory-like paths) versus just .<extension>. This would improve code clarity.

Copy link
Member Author

@JounQin JounQin May 18, 2025

Choose a reason for hiding this comment

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

@stephenjason89 You also need to change your fix implementation for import-js/eslint-plugin-import#3177.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will do. Thanks!

@@ -286,6 +395,14 @@ export default createRule<Options, MessageId>({
extension,
importPath: importPathWithQueryString,
},
...(props.fix && {
Copy link
Member Author

@JounQin JounQin May 17, 2025

Choose a reason for hiding this comment

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

Let's also add suggestions here in another PR.

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

♻️ Duplicate comments (1)
src/rules/extensions.ts (1)

180-189: Properly implemented pattern matching with minimatch.

The computeOverrideAction function correctly uses the minimatch library to determine if an import path matches a pattern and returns the corresponding action.

The minimatch function is used here without specifying the nocomment option explicitly. While the default is true, it would be safer to explicitly set it to avoid unexpected behavior if the library defaults change in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between dc718b1 and ffe866c.

⛔ Files ignored due to path filters (1)
  • test/utils/__snapshots__/parse-path.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (8)
  • .github/workflows/ci.yml (1 hunks)
  • README.md (1 hunks)
  • docs/rules/extensions.md (1 hunks)
  • src/rules/extensions.ts (12 hunks)
  • src/utils/index.ts (1 hunks)
  • src/utils/parse-path.ts (1 hunks)
  • test/rules/extensions.spec.ts (6 hunks)
  • test/utils/parse-path.spec.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • docs/rules/extensions.md
  • test/utils/parse-path.spec.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • .github/workflows/ci.yml
  • src/utils/index.ts
  • README.md
  • src/utils/parse-path.ts
🧰 Additional context used
🪛 GitHub Check: codecov/patch
src/rules/extensions.ts

[warning] 370-370: src/rules/extensions.ts#L370
Added line #L370 was not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (200)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 24 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 22 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 20 and ESLint 9 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 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.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 8.56 on macos-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 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 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 20 and ESLint 9 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 24 and ESLint 8 on macos-latest
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 24 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 22 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 20 and ESLint 9 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 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.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 8.56 on macos-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 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 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 20 and ESLint 9 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 24 and ESLint 8 on macos-latest
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 24 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 22 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 20 and ESLint 9 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 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.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 8.56 on macos-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 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 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 20 and ESLint 9 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 24 and ESLint 8 on macos-latest
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 24 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 22 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 20 and ESLint 9 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 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.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 8.56 on macos-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 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 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 20 and ESLint 9 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 24 and ESLint 8 on macos-latest
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 24 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 22 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 20 and ESLint 9 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 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.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 8.56 on macos-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 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 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 20 and ESLint 9 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 24 and ESLint 8 on macos-latest
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 24 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 22 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 20 and ESLint 9 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 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.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 8.56 on macos-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 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 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 20 and ESLint 9 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 24 and ESLint 8 on macos-latest
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 24 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 22 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 20 and ESLint 9 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 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.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 8.56 on macos-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 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 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 20 and ESLint 9 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 24 and ESLint 8 on macos-latest
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 24 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 22 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 20 and ESLint 9 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 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.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 8.56 on macos-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 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 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 20 and ESLint 9 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 24 and ESLint 8 on macos-latest
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 24 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 22 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 20 and ESLint 9 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 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.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 8.56 on macos-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 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 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 20 and ESLint 9 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 24 and ESLint 8 on macos-latest
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 24 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 22 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 20 and ESLint 9 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 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.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 8.56 on macos-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 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 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 20 and ESLint 9 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 24 and ESLint 8 on macos-latest
🔇 Additional comments (7)
test/rules/extensions.spec.ts (4)

164-172: Good addition of test cases for the new fix option.

These test cases correctly verify that the rule accepts imports both with and without extensions when the fix option is enabled.


196-206: Well-structured test enhancement for suggestions.

The addition of suggestion information to the test cases is well-implemented, providing clear expectations for the error message, data, and output format when suggestions are enabled.


875-952: Comprehensive test coverage for pathGroupOverrides.

These tests thoroughly validate the pathGroupOverrides feature with different scenarios:

  1. When no patterns match imports
  2. When an enforce pattern matches imports
  3. When an ignore pattern matches imports

The test cases cover all key behaviors of the new feature.


974-1026: Good coverage of error cases and fix behavior.

These invalid test cases properly verify both the error reporting for pattern matching and the automatic fix behavior for removing extensions.

src/rules/extensions.ts (3)

42-60: Well-structured schema definition for new options.

The schema definitions for pathGroupOverrides and fix options are properly structured and typed. The pathGroupOverrides array with pattern properties and actions will allow for flexible rule configuration.


339-352: Well-implemented path handling for auto-fixes.

The code correctly parses import paths and handles special cases like directory imports by appending /index.${extension}. The previously identified issue with trailing slashes has been fixed.


398-405: Good implementation of automatic fixing for unexpected extensions.

The code correctly implements automatic removal of unexpected extensions when the fix option is enabled.

@JounQin JounQin changed the title feat(extensions): support fix and pathGroupOverrides options feat(extensions): support pathGroupOverrides and fix options May 17, 2025
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 1474a62 in 42 seconds. Click for details.
  • Reviewed 13 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/utils/parse-path.ts:7
  • Draft comment:
    Explicit return type enhances clarity for parsePath's output.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. src/utils/parse-path.ts:10
  • Draft comment:
    Logic for extracting query and hash is clear; consider adding inline comments to document behavior when both '?' and '#' exist.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None

Workflow ID: wflow_BhoH2nsGDmBT5hed

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

@JounQin JounQin merged commit 90c1cd0 into master May 17, 2025
90 checks passed
@JounQin JounQin deleted the feat/extensions-fix-and-overrides branch May 17, 2025 18:14
hash: string
}

export const parsePath = (path: string): ParsedPath => {
Copy link
Member Author

Choose a reason for hiding this comment

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

@stephenjason89 You'd better to use this pattern to support ?/# better in
original importPath for import-js/eslint-plugin-import#3177

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it.

@stephenjason89
Copy link
Contributor

Hey, I appreciate that the changes were used and improved with tests — thank you for that. That said, I would’ve really preferred if my original PR was merged and any follow-up changes were pushed to my branch or discussed first. It would’ve felt more collaborative and helped retain proper credit for the initial effort.

I hope future contributions can follow that approach. Thanks again.

@JounQin
Copy link
Member Author

JounQin commented May 19, 2025

@stephenjason89 See #326 (comment) I got no permission to push changes to your branch, and I've already added you add commit co-author: 90c1cd0

@stephenjason89
Copy link
Contributor

@JounQin Thanks for the clarification, and for adding me as a co-author — I really appreciate that!

Next time I’ll make sure to allow edits on the branch so things can move more smoothly. Looking forward to contributing more 🙌

@JounQin
Copy link
Member Author

JounQin commented May 19, 2025

Next time I’ll make sure to allow edits on the branch so things can move more smoothly. Looking forward to contributing more 🙌

I believe that's because your fork is based on https://github.com/import-js/eslint-plugin-import instead of this repo, so I got no permission to push changes to your fork.

#326 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port enhance import extension enforcement with autofix support
2 participants