-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(@stylexjs/eslint-plugin): Accept { from: string, as: string } syntax in validImports option for RSD #569
base: main
Are you sure you want to change the base?
Conversation
specifier.type === 'ImportNamespaceSpecifier' | ||
) { | ||
styleXDefaultImports.add(specifier.local.name); | ||
const foundImportSource = importsToLookFor.find((importSource) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foundImportSource
will be either a string or the object containing "as" and "from".
) { | ||
styleXCreateImports.add(specifier.local.name); | ||
} | ||
if (typeof foundImportSource === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, if foundImportSource
is a string,styleXDefaultImports
and the other variables will be updated exactly the same as before.
}); | ||
} | ||
|
||
if (typeof foundImportSource === 'object') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If using the new as
and from
syntax, we will treat the value of the as
option as the default import name. This is because the resolution mechanism is the same as import stylex from 'xxx'
, where the property names of stylex are fixed to create
, props
, etc, and the same constraints apply to the css
object as well.
import { css } from 'a'
What changed / motivation ?
React Strict DOM recently removed their eslint plugin and I'm considering migrating to
@stylexjs/eslint-plugin
.However, react-strict-dom exports
stylex
undercss
object, and it is it incompatible with currentvalidImports
option in the eslint plugin.e.g. This doesn't work:
I have added
{ from: string, as: string }
syntax similar toimportSources
option in the babel plugin for compatibility with RSD, for both@stylexjs/sort-keys
and@stylexjs/valid-styles
rules.e.g. now the option accepts this format:
Additional Context
apps/nextjs-example
dir by replacing imports with react-strict-dom and configuring with the new options as in the screenshot.Pre-flight checklist
Contribution Guidelines