stylex icon indicating copy to clipboard operation
stylex copied to clipboard

feat(@stylexjs/eslint-plugin): Accept { from: string, as: string } syntax in validImports option for RSD

Open javascripter opened this issue 1 month ago • 0 comments

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 under css object, and it is it incompatible with current validImports option in the eslint plugin.

e.g. This doesn't work:

module.exports = {
  plugins: ['@stylexjs'],
  rules: {
    '@stylexjs/sort-keys': [
      'error',
      {
        validImports: ['react-strict-dom']
      },
    ],
  },
};

I have added { from: string, as: string } syntax similar to importSources 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:

{
  validImports: [
    {
      from: 'react-strict-dom',
      as: 'css',
    },
  ],
},

Additional Context

  • Added unit tests
  • Updated the api docs
  • I also checked the behavior locally in apps/nextjs-example dir by replacing imports with react-strict-dom and configuring with the new options as in the screenshot.
Screenshot 2024-05-11 at 15 51 55

Pre-flight checklist

javascripter avatar May 11 '24 06:05 javascripter