Skip to content

[eslint-bulk] Attempt to resolve eslint as a dependency of the current project before falling back to a globally-installed copy. - #4627

Merged
Ian Clanton-Thuon (iclanton) merged 1 commit into
microsoft:mainfrom
iclanton:more-robust-eslint-resolve
Apr 9, 2024
Merged

Conversation

@iclanton

Copy link
Copy Markdown
Member

Summary

Right now, eslint-bulk assumes eslint is installed globally. This may or may not be the case, and the globally installed version may or may not match the version expected to be used by the local package. If the globally installed version does not match the version installed for the local package, running eslint-bulk can produce this error:

@rushstack/eslint-bulk: Error finding patch path: Command failed: eslint --stdin --config .eslintrc.js

Oops! Something went wrong! :(

ESLint: 9.0.0

Error: Failed to patch ESLint because the calling module was not recognized.
If you are using a newer ESLint version that may be unsupported, please create a GitHub issue:
https://github.com/microsoft/rushstack/issues
    at Object.<anonymous> (<path>/@rushstack/eslint-patch/lib/_patch-base.js:167:19)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (<path>/@rushstack/eslint-patch/lib/modern-module-resolution.js:11:23)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)

Details

Before invoking the global copy of ESLint, try to find a locally-installed copy.

How it was tested

Tested with and without eslint installed globally, in projects using two different versions of eslint in the same monorepo, on both Windows and Linux.

Impacted documentation

None.

…re falling back to a globally-installed copy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants