[eslint-plugin] Detect aliased imports in no-deprecated-components rules - #8159
Open
adityasingh2400 wants to merge 1 commit into
Open
[eslint-plugin] Detect aliased imports in no-deprecated-components rules#8159adityasingh2400 wants to merge 1 commit into
adityasingh2400 wants to merge 1 commit into
Conversation
Generate changelog in
|
adityasingh2400
force-pushed
the
fix-6408-eslint-aliased-imports
branch
from
June 9, 2026 10:35
1eca330 to
24f6e09
Compare
Contributor
Author
|
This change is a Fix. The changelog entry is already committed in this PR at |
The deprecated-component detector keyed its config lookup on the local JSX name,
so an aliased import (import { DateInput2 as Foo }) was never flagged: the
config is keyed by the original name (DateInput2), not the alias. Resolve the
local name back to the imported name in isDeprecatedComponent and at every
report site, so aliased usages are detected and the migration message points at
the correct replacement.
Fixes palantir#6408
adityasingh2400
force-pushed
the
fix-6408-eslint-aliased-imports
branch
from
June 12, 2026 04:47
24f6e09 to
3b14d82
Compare
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 #6408
Checklist
Changes proposed in this pull request:
The
no-deprecated-componentsrule family records each deprecated import with both its original name (functionName) and its local name (localFunctionName), butisDeprecatedComponentand the report sites looked the component up indeprecatedComponentConfigby the local JSX name. The config is keyed by the original name, so an aliased import was never flagged:This change:
isDeprecatedComponentnow matches a deprecated import bylocalFunctionNameand verifies the originalfunctionNameis in the config. This keeps the existing distinction that prop-only-deprecated components (which appear only inComponent.propconfig keys) are not reported as fully-deprecated components.resolveImportedComponentNamehelper maps a local/aliased name back to the original imported name, and is used at every report site (JSX element, prop usage,class extends, andComponent.ofType()member expressions) so the config resolves and the migration message names the correct replacement.Reviewers should focus on:
createNoDeprecatedComponentsRule.ts. The squiggle still lands on the alias the user wrote, while the message references the underlying deprecated component (for exampleUsage of DateInput2 is deprecated, migrate to DateInput). A new invalid test coversimport { DateInput2 as MyDateInput }plus<MyDateInput />. All existing deprecated-component rule tests (core/popover2/select/table/datetime2) still pass.