feat(@stylexjs/eslint-plugin): Accept { from: string, as: string } syntax in validImports option for RSD#569
Conversation
| specifier.type === 'ImportNamespaceSpecifier' | ||
| ) { | ||
| styleXDefaultImports.add(specifier.local.name); | ||
| const foundImportSource = importsToLookFor.find((importSource) => { |
There was a problem hiding this comment.
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.
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.
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'
|
@nmn You approved this PR but it wasn't merged. Is there something else that needed work? |
|
See #1039 for this PR rebased on |
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
stylexundercssobject, and it is it incompatible with currentvalidImportsoption in the eslint plugin.e.g. This doesn't work:
I have added
{ from: string, as: string }syntax similar toimportSourcesoption in the babel plugin for compatibility with RSD, for both@stylexjs/sort-keysand@stylexjs/valid-stylesrules.e.g. now the option accepts this format:
Additional Context
apps/nextjs-exampledir by replacing imports with react-strict-dom and configuring with the new options as in the screenshot.Pre-flight checklist
Contribution Guidelines