Repository navigation
[eslint-plugin] Catch export specifiers, export *, and aliased exports in enforce-extension - #1998
Open
henryqdineen wants to merge 1 commit into
Open
henryqdineen wants to merge 1 commit into
henryqdineen wants to merge 1 commit into
Conversation
…s in enforce-extension
enforce-extension only looked at exports with a declaration, so `export { helper }`, `export { helper } from './helper'`, and `export * from './helpers'` in a `.stylex` file were never reported as mixed exports. The skip dates back to the rule's first version (meta#704).
Aliases need their own error. StyleX hashes variable names from the export name, and importing files never read the `.stylex` file, so importing an alias compiles to `var(--...)` references that nothing defines. The generic "must not export anything else" message doesn't explain that, and `legacyAllowMixedExports` would hide it, so an alias of a `define*` result is now always reported with a message saying why it breaks.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
henryqdineen
marked this pull request as ready for review
October 27, 2026 20:42
This branch has not been deployed
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 caused a bug while renaming a
.stylex.tsexport: we kept the old name as an alias (export const theme = themeNested) to support an automated migration of consumers, and forgot that StyleX can't support that. Importing files hash the file name plus the imported name, so everything importingthemecompiled tovar(--…)references that nothing defines.enforce-extensionwould have caught it, except we were still on 0.19.0 and had the rule suppressed in that file waiting for #1743 🤦Looking into it, we found the rule skips every export without a declaration, so
export { themeNested as theme },export { x } from, andexport *aren't checked on any version. When the rule was added in #704, the review stated the goal as "no other exports" but only namedExportNamedDeclarationandExportDefaultDeclaration, and the implementation only looked at declarations.This PR checks those forms, and gives aliases of
define*results their own error explaining why they break, even withlegacyAllowMixedExports.Linked PR/Issues
Follows up on #1743.
Additional Context
Tests cover each export form, aliases of vars/consts/markers, and type-only exports staying valid.
Open question: the workaround is defining the tokens twice, but class names are hashed from the pre-substitution
var(--…)reference, so identical declarations get separate atomic classes (.x14xsx6j{color:red}and.xtml34x{color:red}) for as long as both names are in use. Would first-class support for aliasing be worth considering for renames like this?Pre-flight checklist
Contribution Guidelines
🤖 Generated with Claude Code