How to solve "Error while loading rule 'react/display-name': `[[GeneratorState]]` is not present on `O`" error in eslint
Asked Answered
S

4

8

In my case I am using eslint on nextjs with eslint-config-next. I use bun as a package manager but I found instances of this issues on npm and yarn as well.

I didn't add any new package but after running bun update or yarn update the issues started appearing. Linting fails with the error:

Error while loading rule 'react/display-name': `[[GeneratorState]]` is not present on `O`
Occurred while linting ...
Saiff answered 11/11, 2023 at 7:0 Comment(0)
S
11

After some research, I found out similar issues reported on the eslint-plugin-react repo and on its dependencies. This issue is related with errors in dependency resolution, when multiple incompatible versions of the same package are installed by the package manager. A similar issue was reported here. The solution is to remove duplicate dependencies:

  • If you are using npm, the solution is to run npm dedupe
  • If you are using yarn, you can do the same by installing yarn-deduplicate
  • If you are using pnpm, the solution is to run pnpm dedupe
  • If you are using bun then you are in no luck because there is currently no dedupe command. In that case you should:
    • Generate yarn.lock from your bun.lock with bun install --yarn so you can inspect the dependencies
    • Use yarn-deduplicate to fix your yarn.lock file
    • Wait for this issue to be solved so you can regenarate your bun.lockb from the fixed yarn.lock

What npm dedupe does, is simplifying dependencies by aggregating duplicated dependencies so they are shared across packages.

Saiff answered 11/11, 2023 at 7:0 Comment(0)
S
4

For those using yarn I found that yarn-deduplicate resolved:
[[GeneratorState]] is not present on O
error for eslint-config-next

Shelba answered 23/11, 2023 at 16:23 Comment(0)
T
3

For me what worked is:

rm -rf node_modules yarn.lock
yarn install
Tailpipe answered 12/2 at 22:4 Comment(0)
S
0

At the time of writing this answer, the latest version of eslint-plugin-react is 7.34.1. I try to update eslint-plugin-react to 7.34.1 to solve this problem. It seems there is a problem with [email protected]

Saraisaraiya answered 19/5 at 8:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.