Skip to content

[eslint-plugin] Detect aliased imports in no-deprecated-components rules - #8159

Open
adityasingh2400 wants to merge 1 commit into
palantir:developfrom
adityasingh2400:fix-6408-eslint-aliased-imports
Open

[eslint-plugin] Detect aliased imports in no-deprecated-components rules#8159
adityasingh2400 wants to merge 1 commit into
palantir:developfrom
adityasingh2400:fix-6408-eslint-aliased-imports

Conversation

@adityasingh2400

@adityasingh2400 adityasingh2400 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #6408

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

The no-deprecated-components rule family records each deprecated import with both its original name (functionName) and its local name (localFunctionName), but isDeprecatedComponent and the report sites looked the component up in deprecatedComponentConfig by the local JSX name. The config is keyed by the original name, so an aliased import was never flagged:

import { DateInput2 as Foo } from "@blueprintjs/datetime2";
return <Foo />; // not flagged before this change

This change:

  • isDeprecatedComponent now matches a deprecated import by localFunctionName and verifies the original functionName is in the config. This keeps the existing distinction that prop-only-deprecated components (which appear only in Component.prop config keys) are not reported as fully-deprecated components.
  • A new resolveImportedComponentName helper maps a local/aliased name back to the original imported name, and is used at every report site (JSX element, prop usage, class extends, and Component.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 example Usage of DateInput2 is deprecated, migrate to DateInput). A new invalid test covers import { DateInput2 as MyDateInput } plus <MyDateInput />. All existing deprecated-component rule tests (core/popover2/select/table/datetime2) still pass.

@changelog-app

changelog-app Bot commented Jun 9, 2026

Copy link
Copy Markdown

Generate changelog in packages/eslint-plugin/changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

[eslint-plugin] Detect aliased imports in no-deprecated-components rules

Check the box to generate changelog(s)

  • Generate changelog entry

@adityasingh2400
adityasingh2400 force-pushed the fix-6408-eslint-aliased-imports branch from 1eca330 to 24f6e09 Compare June 9, 2026 10:35
@adityasingh2400

Copy link
Copy Markdown
Contributor Author

This change is a Fix. The changelog entry is already committed in this PR at packages/eslint-plugin/changelog/@unreleased/pr-8159.v2.yml, so the @unreleased entry is in place. If you would prefer it be generated through this bot instead, the type is Fix and the description matches the PR title.

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
adityasingh2400 force-pushed the fix-6408-eslint-aliased-imports branch from 24f6e09 to 3b14d82 Compare June 12, 2026 04:47
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.

ESLint deprecated component usage detector does not handle aliased imports

1 participant