Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESLint error: '@storybook/react' should be listed in the project's dependencies, not devDependencies

After installing Storybook into a React.js app with ESLint, the VSCode linter wasn't picking up the @storybook/react imports in the examples .stories.js files.

It is giving me the following error:

'@storybook/react' should be listed in the project's dependencies, not devDependencies.eslintimport/no-extraneous-dependencies
like image 772
Ian Avatar asked Dec 05 '25 21:12

Ian


2 Answers

I was able to get the linter warnings to go away by adding an ignore rule my .eslintrc file:

"rules": {
  "import/no-extraneous-dependencies": [
      "error",
      {
        "devDependencies": [
          "**/*.stories.*",
          "**/.storybook/**/*.*"
        ],
        "peerDependencies": true
      }
    ]
}

There is a good example here: https://github.com/storybookjs/linter-config/blob/master/eslint.config.js

like image 75
Ian Avatar answered Dec 08 '25 11:12

Ian


I recently had the same issue. I solved it by restarting the ESLint server. To do this, open the command palette by typing Ctrl+Shift+P, then search for the command ESLint: Restart ESLint Server and hit enter.

like image 36
losaliens Avatar answered Dec 08 '25 09:12

losaliens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!