facebook / stylex

StyleX is the styling system for ambitious user interfaces.
https://stylexjs.com
MIT License
8.21k stars 304 forks source link

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

Open javascripter opened 1 month ago

javascripter commented 1 month ago

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

Screenshot 2024-05-11 at 15 51 55

Pre-flight checklist