storybookjs / eslint-plugin-storybook

🎗Official ESLint plugin for Storybook
MIT License
238 stars 42 forks source link

Disable rule of hooks in stories files #149

Closed ndelangen closed 4 months ago

ndelangen commented 4 months ago

Closes: https://github.com/storybookjs/storybook/issues/21115

What Changed

I chatted with @valentinpalkovic and we concluded that instead of writing an automigration adding code that in neither case looks "quite right", we considered maybe adding an exception to the config exposed by the plugin, which turns off the problems reported from react-hooks eslint plugin.

Checklist

Check the ones applicable to your change:

Change Type

Indicate the type of change your pull request is:

📦 Published PR as canary version: 0.7.0--canary.149.b9dd4e1.0
:sparkles: Test out this PR locally via: ```bash npm install eslint-plugin-storybook@0.7.0--canary.149.b9dd4e1.0 # or yarn add eslint-plugin-storybook@0.7.0--canary.149.b9dd4e1.0 ```
valentinpalkovic commented 4 months ago

LGTM, I am curious what @yannbf thinks about this!

kasperpeulen commented 4 months ago

Can one plugin turn off a rule from another plugin? And are we sure hooks always keep working? Or only if they use storybook hooks?

ndelangen commented 4 months ago

Can one plugin turn off a rule from another plugin?

@kasperpeulen I think this answers your question: https://github.com/storybookjs/eslint-plugin-storybook/pull/149/files#diff-ded734a061dba2176af9593a93a97d7e478a8aa10774724c78ade7977e783832R13

This very plugin is already doing that.

And are we sure hooks always keep working?

This does not impact runtime of hooks. There's no difference in react's hooks vs custom hooks for the eslint plugin, you can't disable 1, and not the other.

github-actions[bot] commented 4 months ago

:rocket: PR was released in v0.7.0 :rocket:

ndelangen commented 4 months ago

To resolve this issue, please use the official storybook eslint plugin. the latest version should resolve this issue, see: https://github.com/storybookjs/eslint-plugin-storybook/releases/tag/v0.7.0