Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin not found in Rush monorepo #1040

Closed
paulius-valiunas opened this issue Aug 5, 2020 · 4 comments
Closed

Plugin not found in Rush monorepo #1040

paulius-valiunas opened this issue Aug 5, 2020 · 4 comments
Labels
info-needed Issue requires more information from poster

Comments

@paulius-valiunas
Copy link

Here's a repo that reproduces the problem:
https://github.com/pauliunas/rush-example

When I change a file, triggering vscode-eslint, it fails to load any eslint plugins. Here's what I see in the output window:

2020-08-05T08:06:08.619Z eslint:config-array-factory Loading JSON config file: d:\test_projects\rush-example\apps\my-app\package.json
2020-08-05T08:06:08.619Z eslint:config-array-factory Loading package.json config file: d:\test_projects\rush-example\apps\my-app\package.json
2020-08-05T08:06:08.619Z eslint:config-array-factory Loading JSON config file: d:\test_projects\rush-example\apps\my-app\package.json
2020-08-05T08:06:08.619Z eslint:config-array-factory Loading {extends:"./node_modules/my-toolchain/.eslintrc.js"} relative to d:\test_projects\rush-example\apps\my-app\package.json
2020-08-05T08:06:08.620Z eslint:config-array-factory package.json was not found: Cannot find module './node_modules/my-toolchain/.eslintrc.js/package.json'
Require stack:
- d:\test_projects\rush-example\apps\my-app\package.json
2020-08-05T08:06:08.620Z eslint:config-array-factory Loaded: ./node_modules/my-toolchain/.eslintrc.js (D:\test_projects\rush-example\tools\my-toolchain\.eslintrc.js)
2020-08-05T08:06:08.620Z eslint:config-array-factory Loading JS config file: D:\test_projects\rush-example\tools\my-toolchain\.eslintrc.js
2020-08-05T08:06:08.621Z eslint:config-array-factory Loading {extends:"plugin:@typescript-eslint/recommended"} relative to D:\test_projects\rush-example\tools\my-toolchain\.eslintrc.js
2020-08-05T08:06:08.621Z eslint:config-array-factory Loading plugin "@typescript-eslint" from D:\test_projects\rush-example\tools\my-toolchain\.eslintrc.js
2020-08-05T08:06:08.622Z eslint:config-array-factory Failed to load plugin '@typescript-eslint' declared in '--config » ./node_modules/my-toolchain/.eslintrc.js'.

Going to D:\test_projects\rush-example\apps\my-app and running npm run lint works just fine.

I've tried following advice from other similar issues, Stack Overflow etc., and I just don't see what I'm still missing. Am I doing something wrong, or have I run into a bug?

@dbaeumer
Copy link
Member

dbaeumer commented Aug 5, 2020

The reason for this is that some tooling (I don't know which one) patches the ESLint script (./apps/my-app/node_modules/.bin/eslint) that runs eslint and adds this to it

export NODE_PATH="/home/codespace/workspace/rush-example/common/temp/node_modules/.pnpm/registry.npmjs.org/eslint/6.8.0/node_modules/eslint/bin/eslint.js/node_modules:/home/codespace/workspace/rush-example/common/temp/node_modules/.pnpm/registry.npmjs.org/eslint/6.8.0/node_modules/eslint/bin/node_modules:/home/codespace/workspace/rush-example/common/temp/node_modules/.pnpm/registry.npmjs.org/eslint/6.8.0/node_modules/eslint/node_modules:/home/codespace/workspace/rush-example/common/temp/node_modules/.pnpm/registry.npmjs.org/eslint/6.8.0/node_modules:/home/codespace/workspace/rush-example/common/temp/node_modules/.pnpm/registry.npmjs.org/eslint/node_modules:/home/codespace/workspace/rush-example/common/temp/node_modules/.pnpm/registry.npmjs.org/node_modules:/home/codespace/workspace/rush-example/common/temp/node_modules/.pnpm/node_modules:/home/codespace/workspace/rush-example/common/temp/node_modules:/home/codespace/workspace/rush-example/common/node_modules:/home/codespace/workspace/rush-example/node_modules:/home/codespace/workspace/node_modules:/home/codespace/node_modules:/home/node_modules:/node_modules:/home/codespace/workspace/rush-example/apps/my-app/node_modules/eslint/bin/eslint.js/node_modules:/home/codespace/workspace/rush-example/apps/my-app/node_modules/eslint/bin/node_modules:/home/codespace/workspace/rush-example/apps/my-app/node_modules/eslint/node_modules:/home/codespace/workspace/rush-example/apps/my-app/node_modules:/home/codespace/workspace/rush-example/apps/node_modules"

The ESLint extension doesn't use the script since it loads ESLint directly. But the extension offers a setting to tweak the NODE_PATH as well. It is eslint.nodePath. You might want to talk to the rush people that they weak the vscode settings as well.

@dbaeumer
Copy link
Member

dbaeumer commented Aug 5, 2020

Let me know if you hear back something from the rush people.

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Aug 5, 2020
@paulius-valiunas
Copy link
Author

Thanks for looking into this. I didn't know it patched eslint (that's weird and ugly). Now I took a better look at Rush issues and documentation and found this:
You can use the resolvePluginsRelativeTo option to point it to the package that contains the config. In my case, I ended up with a config like this:

  "eslint.options": {
    "configFile": "./package.json",
    "useEslintrc": false,
    "resolvePluginsRelativeTo": "./node_modules/my-toolchain"
  }

Their alternative recommendation is to add require("@rushstack/eslint-patch/modern-module-resolution"); to the top of .eslintrc.js in each package to make it work with other IDEs/plugins too without relying on CLI arguments.
So apparently the fix is rather simple, I just wouldn't have found it without knowing about the patch. Thanks for getting me on the right track!

@dbaeumer
Copy link
Member

dbaeumer commented Aug 6, 2020

Good to hear you got it working.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants