microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.74k stars 335 forks source link

VS Code eslint using outdated error for non-existent rule configuration #1854

Closed ghost closed 4 months ago

ghost commented 4 months ago

In VS Code I'm getting this advice about a stableHooksPattern advanced configuration [1] but when I add that to my .eslintrc.cjs file and run eslint ., I am getting an error [2].

When I switch to using "additionalHooks": "(usePlatform|useWorkbench)" in .eslintrc.cjs the eslint . command works, but then VS Code doesn't work anymore.

Looking into my local package's node_modules I see only code for additionalHooks, not stableHooksPattern [3] and indeed, this is the package that vscode-eslint is drawing from according to the debug logs [4].

I searched my entire system for stableHooksPattern and I can only find my own eslint rules and comments about it in my code. There is no node_module anywhere on my system that I can find mentioning this, e.g. grep -rnws ./ --include=*.* -e 'stableHooksPattern'

A Google search reveals only one old StackOverflow post

I also commented about this issue on a related react.dev issue.

Can anyone help me debug this and find out where VS Code is getting this outdated configuration from?

[1] image NOTE: The suggestion @example shown above is actually from my own jsdoc comment. The error I'm receiving is that my React Hook is "received a function whose dependencies are unknown". but the code I'm calling is not even passing a function, e.g. usePlatform("logger", "workbench"). The fact stands though, that VS Code eslint is behaving differently than the command line for some reason.

[2]

Error: .eslintrc.cjs: Configuration for rule "react-hooks/exhaustive-deps" is invalid: Value {"stableHooksPattern":"usePlatform|useWorkbench"} should NOT have additional properties.

[3] image

[4]

024-06-06T16:33:24.410Z eslintrc:cascading-config-array-factory Load config files for /a/project/node_modules/eslint-plugin-react-hooks. 2024-06-06T16:33:24.410Z eslintrc:cascading-config-array-factory No cache found: /a/project/node_modules/eslint-plugin-react-hooks. 2024-06-06T16:33:24.410Z eslintrc:config-array-factory Loading package.json config file: /a/project/node_modules/eslint-plugin-react-hooks/package.json 2024-06-06T16:33:24.410Z eslintrc:config-array-factory Loading JSON config file: /a/project/node_modules/eslint-plugin-react-hooks/package.json 2024-06-06T16:33:24.410Z eslintrc:config-array-factory Error reading package.json file: /a/project/node_modules/eslint-plugin-react-hooks/package.json 2024-06-06T16:33:24.410Z eslintrc:config-array-factory Config file not found on /a/project/node_modules/eslint-plugin-react-hooks

ghost commented 4 months ago

OK I think I figured out this mystery. The VS Code extension was probably not reporting an error when the stableHooksPattern advanced eslint config was used because it was probably breaking eslint for VS Code the same way it was breaking eslint on the command line, because it's not a valid option.