storybookjs / eslint-plugin-storybook

🎗Official ESLint plugin for Storybook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

awaited chain expression is seen as invalid

VinceMalone opened this issue · comments

Describe the bug

with the await-interaction rule enabled, if a play function is being composed from another story, but the expression has an optional chain, it's seen as invalid; even if it's correctly awaited. because the expression will be seen as false and the auto-fix doesn't fix it; instead many redundant awaits are added.

To Reproduce

  1. lint the following code with the await-interaction enabled

    export const SecondStory = {
      play: async (context) => {
        await FirstStory.play?.(context)
      }
    }
  2. run auto-fix

Expected behavior

it should be seen as valid and the auto-fix shouldn't alter the code

Screenshots

valid code is seen as invalid: image

post auto-fix: image

This was released in v0.5.9! Thanks once again for your contribution @VinceMalone !