Skip to content

fix: handle re-export alias false positives in no-undef rule#573

Merged
chenjiahan merged 1 commit intomainfrom
fix/no-undef-reexport-alias-20260327
Mar 27, 2026
Merged

fix: handle re-export alias false positives in no-undef rule#573
chenjiahan merged 1 commit intomainfrom
fix/no-undef-reexport-alias-20260327

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

Summary

Fix false positives in no-undef rule for re-export aliases:

  • export { X as Y } from 'module' — the original name X is the source module's export name, not a local reference, but was incorrectly reported as "not defined"
  • export type { X as Y } from 'module' — same issue with type-only re-exports

The fix skips ExportSpecifier.propertyName when the parent ExportDeclaration has a moduleSpecifier (i.e., a from clause). Local export aliases (export { X as Y } without from) are unaffected — X is correctly checked as a local reference.

Related Links

  • Previous PR: feat: port rule no-undef

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the no_undef rule to correctly handle re-export aliases, ensuring that the original name in export { Original as Alias } from 'module' statements is skipped. It introduces an isReExport helper function and adds test cases for both valid re-exports and invalid local exports. A suggestion was provided to refactor the isReExport function to improve conciseness and readability by combining parent node nil-checks.

@chenjiahan chenjiahan merged commit 098afb0 into main Mar 27, 2026
11 checks passed
@chenjiahan chenjiahan deleted the fix/no-undef-reexport-alias-20260327 branch March 27, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants