ArnaudBarre / eslint-plugin-react-refresh

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

Throwing error for typescript type exports. #21

Closed sadik-malik closed 1 year ago

sadik-malik commented 1 year ago

I export all of the components, including the types, using the index.tsx file that is located in that folder.

When I export the component in the following way eslint-plugin-react-refresh is giving me warning Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components.

export { default } from './Applications'
export type { ApplicationsProps } from './Applications'

There is no warning, though, when I write it in a different way like I do below.

import Applications, { type ApplicationsProps } from './Applications'

export default Applications
export type { ApplicationsProps }

In my opinion, the plugin shouldn't issue any alerts if the types are exported.

ArnaudBarre commented 1 year ago

If the file is only used to re-exports variables (not recommended when using Vite) it should be named index.ts

sadik-malik commented 1 year ago

When types are not exported, there is no warning, and changing the file to index.ts is like turning off the plugin.

Since re-exports are not advised with Vite, it appears that I have to remove all of them.