Support prioritizeNamedImports option#187
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: aa53448 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
c6accbc to
b24e719
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new prioritizeNamedImports option that controls whether named imports are preferred over namespace imports for CSS modules when namedExports is enabled.
- Introduces
prioritizeNamedImportsin core config and applies it in TS plugin completion and code-fix logic - Updates language service proxy to wire through resolver and completion/details handlers
- Adds README docs, tests, and a changeset for the new option
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ts-plugin/src/util.ts | Added import conversion helper to namespace imports |
| packages/ts-plugin/src/language-service/... | Wired prioritizeNamedImports through completions and fixes |
| packages/core/src/config.ts | Extended CMKConfig with new option and parsing logic |
| packages/core/src/config.test.ts | Added test for reading new option |
| packages/ts-plugin/e2e/named-exports.test.ts | Expanded E2E tests for both namespace and named-import modes |
| README.md | Documented prioritizeNamedImports option |
| .changeset/moody-hornets-hammer.md | Bumped package versions for the feature |
Comments suppressed due to low confidence (2)
packages/core/src/config.ts:19
- This new config property lacks a JSDoc comment. Please add a description, e.g.
/** Whether to prefer named imports over namespace imports when namedExports is true. */.
prioritizeNamedImports: boolean;
README.md:174
- The example for
falseis misleading. It should illustrate a namespace import (e.g.import * as styles from '...') to match the actual behavior.
When this option is `true`, `import { button } from '...'` will be added. When this option is `false`, `import button from '...'` will be added.
b24e719 to
aa53448
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.
ref: #181
parent: #182
Many users who use named exports prefer to import CSS Modules using namespace imports (e.g.,
import * as styles from ...) (ref: https://x.com/mizdra/status/1927324264853639254). Therefore, we will prioritize namespace imports in autocompletion.Additionally, for users who prefer to import CSS Modules using named imports (e.g.,
import { foo } from ...), we have added theprioritizeNamedImportsoption.2025-06-08.1.18.34.mov