eslint-plugin-storybook icon indicating copy to clipboard operation
eslint-plugin-storybook copied to clipboard

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

Open Hiroshiba opened this issue 1 year ago • 1 comments

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.

Hiroshiba avatar Aug 03 '24 16:08 Hiroshiba

the same issue. any progress here?

Jazzmanpw avatar Sep 12 '24 09:09 Jazzmanpw

Hey @Jazzmanpw @Hiroshiba thanks for reporting. PRs are welcome!

yannbf avatar Jan 02 '25 08:01 yannbf