ui icon indicating copy to clipboard operation
ui copied to clipboard

Export pattern causes warning from `eslint-plugin-react-refresh`

Open lunelson opened this issue 2 years ago • 3 comments

After initializing in a new React Vite TS Storybook starter, that happened to have this eslint plugin installed, I get warnings on a number of files that export functions in addition to a component.

Also, although documentation about "Fast Refresh" is a bit scant unfortunately, some resources on it also say that each export requires its own export statement...

https://github.com/ArnaudBarre/eslint-plugin-react-refresh

...from my eslint config:

{
  plugins: ['react-refresh'],
  rules: {
    'react-refresh/only-export-components': [
      'warn',
      { allowConstantExport: true },
    ],
  },
}

lunelson avatar Sep 16 '23 14:09 lunelson

same issue here, any updates?

enix79 avatar Oct 13 '23 09:10 enix79

I would also prefer that there were no warnings.

DocMoebiuz avatar Feb 20 '24 10:02 DocMoebiuz

It was surprising that this hasn't been a major issue, but it seems that most of the components provided by shadcn/ui are following the only-export-components rule. The only example of rule violation I found was with the button. Additionally, I don't think the button needs to export the buttonVariants function. I have removed the buttonVariants function from the export object in the installed button.tsx.

koutaro-masaki avatar Apr 24 '24 05:04 koutaro-masaki

I found out that button is required to export buttonVariants due to dependencies from components such as alert-dialog. To adhere to the only-export-components rule, I decided to define buttonVariables in a file other than button.tsx and import them into button.tsx.

koutaro-masaki avatar Jun 03 '24 08:06 koutaro-masaki

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

shadcn avatar Jun 25 '24 23:06 shadcn

Just came across this myself, maybe its worth considering re-opening?

philbates35 avatar Jul 19 '24 18:07 philbates35

Same issue here in form when exporting useFormField

GuillemPM avatar Jul 22 '24 15:07 GuillemPM

Same issue here in form when exporting useFormField

@GuillemPM For my use, I removed the useFormField as an export from the file. It is only being used internally by the other Form components. So unless you are using the useFormField hook somewhere in your code, removing it from the export list should solve the issue.

jay-batavia avatar Aug 05 '24 06:08 jay-batavia

Would be great if this was looked at again.

dmccoy-NL avatar Aug 06 '24 17:08 dmccoy-NL