ArnaudBarre / eslint-plugin-react-refresh

Validate that your components can safely be updated with Fast Refresh
MIT License
206 stars 13 forks source link

Question: Configuration to allow different file extensions to be checked? #4

Closed DianaSuvorova closed 1 year ago

DianaSuvorova commented 1 year ago

We are looking to apply this lint rule to our codebase. Although we follow different file extension policies for React. So we need to allow the rule to parse '.js' files as well.

Would you be open to a contribution that would introduce an option to configure this rule to override parsable file extensions? The default can still be tsx & jsx?

Thanks, Diana

ArnaudBarre commented 1 year ago

Most new bundlers (SWC, esbuild, bun) don't parse jsx inside .js files, so I always advice people to use explicit file extension, this avoid a lot of configuration in the long run IMO.

But if this is not something possible for you, this options can be added to the plugin 👍

Note: given that the plugin only use naming convention, this could generate some false positive (when exporting pure JS classes for example).

DianaSuvorova commented 1 year ago

I see, let me try to come up with test cases and see what it will look like. I am thinking adding a check that React is in scope may act as a proxy to check that code is actually jsx.

DianaSuvorova commented 1 year ago

upd: I am planning to add something similar to isReturningJSX

ArnaudBarre commented 1 year ago

Interesting. Could be useful to go behind naming convention in general but let's use it only for JS files in the first (behind an option so that the plugin don't run on JS files by default)