Skip to content

[eslint-plugin] Allow type exports in enforce-extension rule#1743

Open
henryqdineen wants to merge 1 commit into
facebook:mainfrom
henryqdineen:hqd-allow-type-exports-enforce-extension
Open

[eslint-plugin] Allow type exports in enforce-extension rule#1743
henryqdineen wants to merge 1 commit into
facebook:mainfrom
henryqdineen:hqd-allow-type-exports-enforce-extension

Conversation

@henryqdineen

Copy link
Copy Markdown
Collaborator

What changed / motivation ?

We ran into this adopting the @stylexjs/enforce-extension rule 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 .stylex file that exports a type alongside defineVars/defineConsts/defineMarker is 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 .stylex files 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 }, and export { 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

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>
@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
stylex Skipped Skipped Jun 27, 2026 3:54am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 27, 2026
@henryqdineen henryqdineen changed the title [eslint] Allow type exports in enforce-extension rule [eslint-plugin] Allow type exports in enforce-extension rule Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant