storybookjs / eslint-plugin-storybook

🎗Official ESLint plugin for Storybook
MIT License
249 stars 53 forks source link

Support for new context syntax in `rules/context-in-play-function` not working as expected #162

Open Hiroshiba opened 2 months ago

Hiroshiba commented 2 months ago

Describe the bug The rules/context-in-play-function rule does not support the new context argument syntax introduced in Storybook v8.2.0, which allows self-referencing context within play functions. When trying to pass a context when invoking the play function of another story, an error is thrown.

To Reproduce Steps to reproduce the behavior:

  1. Upgrade to Storybook v8.2.0.
  2. Implement the new context passing syntax in a story's play function as shown below:
    play: async ({ context, canvasElement, parameters }) => {
     await Default.play?.(context);
    }
  3. Observe the error: Pass a context when invoking play function of another story.

Expected behavior Expected no errors when passing the context as an argument in the play function of another story. The implementation should recognize and validate the new syntax as per the changes introduced in Storybook v8.2.0.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Reference to the pull request that introduced the change in Storybook v8.2.0: PR #28353

The previous syntax was:

play: async ({ canvasElement }) => {
  await FirstStory.play({ canvasElement });
}

It has been updated to:

play: async ({ context, canvasElement }) => {
  await FirstStory.play(context);
}

This update seems not to be fully supported by eslint-plugin-storybook, specifically the rule rules/context-in-play-function.

Jazzmanpw commented 1 month ago

the same issue. any progress here?