storybookjs / eslint-plugin-storybook

🎗Official ESLint plugin for Storybook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VS Code does not format files on save when using storybook in eslint

jacobgavin opened this issue · comments

commented

Describe the bug
Eslint throws error when trying to format onSave in Visual Studio Code. I have tried to delete node_modules and package-lock.json and installed all packages again but it didn't work. eslint-plugin-storybook exists in my node_modules folder.

(node:2024) UnhandledPromiseRejectionWarning: Error: Failed to load plugin 'storybook' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-storybook'

Expected behavior
I expect eslint to run --fix when saving a file in VS Code.

Additional context
If I remove "plugin:storybook/recommended" from my extends in .eslintrc.json it runs eslint onSave without errors.

    "extends": [
		"standard",
		"plugin:react/recommended",
		"plugin:@typescript-eslint/eslint-recommended",
		"plugin:@typescript-eslint/recommended",
+		"plugin:react-hooks/recommended"
-		"plugin:react-hooks/recommended",
-               "plugin:storybook/recommended"
	],

Other eslint-plugins:

"eslint": "~7.27.0",
"eslint-config-standard": "~16.0.3",
"eslint-plugin-import": "~2.22.1",
"eslint-plugin-jest-dom": "~3.9.2",
"eslint-plugin-node": "~11.1.0",
"eslint-plugin-promise": "~4.2.1",
"eslint-plugin-react": "~7.23.2",
"eslint-plugin-react-hooks": "~4.2.0",
"eslint-plugin-storybook": "~0.5.1",
"eslint-plugin-testing-library": "~5.0.0",

Hey @jacobgavin thanks for opening this issue!

Could you please do the following in VSCode: Restart ESLint server:
image

Sometimes that's all you need to make ESLint align with newly installed packages.
If that does not work, I'd love to help, but for that I'd need a reproduction repo. Could you somehow set one up?

commented

Thanks @yannbf that works! I have never experienced this issue before when adding any other eslint-plugin.

Thanks @yannbf that works! I have never experienced this issue before when adding any other eslint-plugin.

You know, sometimes VSCode derps hehe
If you come across any other issues feel free to share more feedback, it's super valuable to us! Thanks for using this plugin!