[eslint-plugin] Allow type exports in enforce-extension rule#1743
Open
henryqdineen wants to merge 1 commit into
Open
[eslint-plugin] Allow type exports in enforce-extension rule#1743henryqdineen wants to merge 1 commit into
henryqdineen wants to merge 1 commit into
Conversation
Type exports (export type, export interface, export type { ... },
export { type ... }) are erased at compile time and don't violate
the intent of the rule. Skip them so they don't trigger false
positives for the mixed-export check.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
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.
What changed / motivation ?
We ran into this adopting the
@stylexjs/enforce-extensionrule in our own codebase. The rule currently treats TypeScript type exports (export type,export interface,export type { ... },export { type ... }) as "other exports," causing false positives for the mixed-export check. A.stylexfile that exports a type alongsidedefineVars/defineConsts/defineMarkeris flagged as invalid.Type exports are erased at compile time and have no runtime impact, so they don't violate the intent of the rule — which is to keep
.stylexfiles focused on style definitions without side-effect-producing value exports. You could work around this by putting the type in a separate file, but there's no reason to force that when the type is derived from the definitions in the same file.The fix skips export nodes with
exportKind === 'type', making them invisible to the rule.Linked PR/Issues
Additional Context
Tests cover
export type Colors = ...,export type { Colors }, andexport { type Colors }using@typescript-eslint/parser. An invalid test confirms that type exports don't suppress errors from actual value-level mixed exports.Pre-flight checklist
Contribution Guidelines