[eslint-plugin] Don't flag class names in dynamic imports or re-exports (classes-constants)#8158
Open
adityasingh2400 wants to merge 1 commit into
Open
Conversation
Generate changelog in
|
The classes-constants rule skipped string literals in static imports and named
re-exports, but not in dynamic imports (import("...")) or export-all
re-exports (export * from "..."). A module specifier that happened to contain
a Blueprint-like substring (e.g. a package named "...pt-...") was wrongly
reported and auto-fixed. Extend the guard to also skip ImportExpression and
ExportAllDeclaration parents.
Fixes palantir#6209
adityasingh2400
force-pushed
the
fix-6209-eslint-dynamic-import
branch
from
June 9, 2026 10:34
c0b4ec3 to
fa6db07
Compare
Contributor
Author
|
This change is a Fix. The changelog entry is already committed in this PR at |
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 #6209
Checklist
Changes proposed in this pull request:
The
classes-constantsrule skips string literals that are part of static imports (ImportDeclaration) and named re-exports (ExportNamedDeclaration), so module specifiers are never treated as class-name strings. It did not skip:import("...")(ImportExpression)export * from "..."(ExportAllDeclaration)So a module specifier that happens to contain a Blueprint-like substring (for example a package whose name contains
pt-) was wrongly reported, and--fixwould rewrite the import path into aClasses.*constant, breaking the import.This extends the early-return guard to also skip
ImportExpressionandExportAllDeclarationparents.Reviewers should focus on:
packages/eslint-plugin/src/rules/classes-constants.ts(the guard at the top ofcreate). Two newvalidtest cases cover a dynamic import and anexport * fromwhose specifiers containpt-.