eslint-react icon indicating copy to clipboard operation
eslint-react copied to clipboard

[feat] detect react version in monorepo

Open yidingww opened this issue 7 months ago • 1 comments

Describe the problem

Currently, the "detect" logic of react version is using module.createRequire(import.meta.url) or module.createRequire(process.cwd() + path.sep ) at packages/shared/src/_require.ts. And in a monorepo enviroment, when linting a file in a sub project from the project root directory, it will try to resolve react version in the from the project root:

# in ./ (project root)
npx eslint apps/xyz/App.tsx # this will create a `_require` that tries to resolve `./node_modules/react`

However, the actual react version it should resolve to is apps/node_modules/react...

Describe the solution you'd like

No response

Alternatives considered

No response

Additional context

No response

yidingww avatar May 21 '25 03:05 yidingww

Until we find a better way to implement it that doesn't affect performance and increase code complexity much, I recommend the suggestion in https://github.com/antfu/eslint-config/issues/640#issuecomment-2546360635.

Rel1cx avatar May 22 '25 06:05 Rel1cx