Resolve export * as ns re-exports under modern parsers#3250
Open
rasmi wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3250 +/- ##
==========================================
+ Coverage 95.50% 95.66% +0.16%
==========================================
Files 83 83
Lines 3693 3692 -1
Branches 1336 1334 -2
==========================================
+ Hits 3527 3532 +5
+ Misses 166 160 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two pre-existing
ExportAllDeclarationbugs that affect modern parsers (espree ES2020+,@babel/eslint-parser) but notbabel-eslint. Extracted from #3230 (eslint v10 support) to make that PR cleaner.Root cause
babel-eslintrepresentsexport * as ns from './mod'asExportNamedDeclaration+ExportNamespaceSpecifier(a working code path), so the bug was latent. Modern parsers emitExportAllDeclarationwithexported, which hit two broken spots:specifier.js: passed a string (specifier.source.value) tonamespace.add(), which expects an AST node — so the namespace getter was never set up andnsdidn't resolve. Fixed by defining the lazy getter directly, matching the existingExportNamespaceSpecifiercase.visitor.js:export * as nswas unconditionally added to the star-exportdependenciesset, incorrectly flattening the target module's exports into the current one. Fixed by only adding todependenciesfor plainexport *(noas).Tests
The included regression test covers the false negative: the
namespacerule now correctly flags invalid deep references throughexport * asre-exports that were previously silently missed (fails onmain, passes with the fix).The false-positive symptoms #1834, #1883, #1845, #2002, #2289 ("errors after upgrading Babel") are resolved by the same change, but only reproduce with
@babel/eslint-parser, which is introduced in #3230.Fixes #2002, #1883, #1834, #1845, #2289.