Skip to content

Conversation

Zamiell
Copy link
Contributor

@Zamiell Zamiell commented Sep 10, 2024

This PR fixes the false positive with the package "typescript-eslint" and "eslint-plugin-jsdoc".

Summary by CodeRabbit

  • Bug Fixes

    • Fixed false positives in the no-rename-default lint rule so legitimate re-aliasing of default exports (including names that normalize to “default” or “index”) is no longer flagged, reducing lint noise and improving compatibility with third-party modules.
  • Chores

    • Added a changeset entry to publish a patch release for this fix.

Copy link

changeset-bot bot commented Sep 10, 2024

🦋 Changeset detected

Latest commit: c6d13c4

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

codesandbox-ci bot commented Sep 10, 2024

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 Sep 10, 2024

Codecov Report

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

Project coverage is 96.00%. Comparing base (8b53954) to head (70fe36a).
Report is 42 commits behind head on master.

Files with missing lines Patch % Lines
src/rules/no-rename-default.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #157      +/-   ##
==========================================
- Coverage   96.22%   96.00%   -0.22%     
==========================================
  Files          91      101      +10     
  Lines        4399     4661     +262     
  Branches     1497     1595      +98     
==========================================
+ Hits         4233     4475     +242     
- Misses        160      180      +20     
  Partials        6        6              

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

Copy link
Collaborator

@SukkaW SukkaW left a comment

Choose a reason for hiding this comment

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

Ideally I want to put this change on hold. The problem is more than _default or index. There is also mangled exports. See also #136

Copy link

sonarqubecloud bot commented Apr 1, 2025

@Zamiell
Copy link
Contributor Author

Zamiell commented Oct 5, 2025

@SukkaW It looks like the discussion has died down on #136. Can we merge this for now in order to make this rule slightly more sane?

If not:

  1. Please close this PR.
  2. Tell me if you will be willing to merge a new PR for a new option that allows a user to supply a whitelist. If so, I will work on that PR instead. (With this functionality, I could supply "default" and "_index" to the whitelist myself.)

Copy link

coderabbitai bot commented Oct 5, 2025

Walkthrough

Adds a changeset for a patch release and updates the no-rename-default ESLint rule to early-return when a default export’s name (after trimming leading underscores) equals "default" or "index", preventing reporting in these cases.

Changes

Cohort / File(s) Summary
Release metadata
.changeset/young-pants-warn.md
Adds a changeset entry for a patch release of eslint-plugin-import-x with note: fix false positive for no-rename-default.
Rule logic update
src/rules/no-rename-default.ts
Introduces early-return guard: trims leading underscores from default export name; skips reporting if name is "default" or "index" before existing import handling logic.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as ESLint Runner
  participant Rule as no-rename-default Rule
  participant AST as AST Node

  Dev->>Rule: Evaluate ExportDefaultDeclaration
  Rule->>AST: Read default export name
  Rule->>Rule: Trim leading underscores
  alt Name is "default" or "index"
    Note over Rule: New early-return guard
    Rule-->>Dev: No report
  else Other names
    Rule->>Rule: Proceed with existing import handling
    alt Violation detected
      Rule-->>Dev: Report problem
    else No issue
      Rule-->>Dev: No report
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

bug

Poem

A whisker-twitch, a hop, a fix in sight,
I nibbled underscores down to light—
When “default” hides, or “index” too,
I thump: “No error! Let it through.”
Patch out, carrots cheer—hip hop hooray! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title concisely and accurately describes the primary change in the pull request—fixing a false positive in the no-rename-default rule—without extraneous details or ambiguity. It directly reflects the code modifications and aligns with the PR’s objective of correcting the rule’s behavior.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 8fe2996 and c6d13c4.

📒 Files selected for processing (1)
  • src/rules/no-rename-default.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/rules/no-rename-default.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
  • GitHub Check: Lint and Test with Node.js 24.5 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 lts/* and ESLint 9 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 24.5 and ESLint 8 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 24.5 and ESLint 8 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.5 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 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 ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 24.5 and ESLint 8 on macos-latest
  • GitHub Check: Lint and Test with Node.js 24.5 and ESLint 8.56 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 18 and ESLint 9 on macos-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on macos-latest

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

pkg-pr-new bot commented Oct 5, 2025

Open in StackBlitz

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

commit: c6d13c4

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 27b175f and 8fe2996.

📒 Files selected for processing (2)
  • .changeset/young-pants-warn.md (1 hunks)
  • src/rules/no-rename-default.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/rules/no-rename-default.ts (1)
src/export-map.ts (4)
  • n (443-625)
  • hasDefault (674-676)
  • hasDeep (727-778)
  • specifier (339-357)
.changeset/young-pants-warn.md (1)
test/cli.spec.ts (1)
  • eslint (13-28)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Codacy Static Code Analysis
  • 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 9 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 on windows-latest
  • GitHub Check: Lint and Test with Node.js 24.5 and ESLint 9 on ubuntu-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.5 and ESLint 8.56 on ubuntu-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 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 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 18 and ESLint 8 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on macos-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on macos-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 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
🔇 Additional comments (1)
.changeset/young-pants-warn.md (1)

1-5: LGTM!

The changeset correctly documents a patch release for the false positive fix.

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.

2 participants