eslint config: Fix modern module resolution #9562
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Eslint's plugin behavior is to load the plugin relative to the current project. This means that if you have a shared config that depends on plugins, like we do, then each project using the shared config has to have the plugins defined as part of their own dependencies. The issue tracking this on the Eslint side is eslint/eslint#3458.
It's more convenient if the plugins are loaded relative to the shared config itself, rather than the project being linted. The Rush team provides a module that works around this behavior by patching eslint.
When I originally added the workaround package, I didn't understand how to use it properly. Now I do. Each inheriting config needs to have the following line at the beginning of their
.eslintrc.js
file:That will load the patch module from the shared eslint config, which will make eslint load the plugins from the shared eslint config package. These changes will be in a future PR. This PR just updates the shared config itself.
Updating the config and publishing a new version is necessary to address this error that arises when adding the workaround:
The error happens because the minimal config inherits from two configs that both use @typescript-eslint. This change stops extending the rushstack config, and instead depends directly on the plugins that the rushstack config itself uses.