Enhance ESLint with better support for large scale monorepos
—
Modern Module Resolution patch solves the longstanding issue where ESLint requires plugins to be installed as peer dependencies in every project that uses a shareable config, even when the config package itself provides those plugins.
Applies runtime patches to ESLint's ConfigArrayFactory to resolve plugins relative to the config file instead of the project root.
/**
* Applies the modern module resolution patch to ESLint
* Must be required before ESLint processes any configuration
*/
require("@rushstack/eslint-patch/modern-module-resolution");Usage Example:
// .eslintrc.js
require("@rushstack/eslint-patch/modern-module-resolution");
module.exports = {
extends: ['@your-company/eslint-config'], // This config can now provide its own plugins
parserOptions: { tsconfigRootDir: __dirname }
};The patch automatically detects and handles different ESLint versions:
_loadPlugin method with importerPath parameter_loadPlugin method with context objectWhen ESLint attempts to load a plugin:
// Internal patch behavior (not directly callable)
interface ModuleResolver {
resolve(moduleName: string, relativeToPath: string): string;
}With this patch, config packages can be structured as follows:
{
"name": "@your-company/eslint-config",
"dependencies": {
"@typescript-eslint/eslint-plugin": "^5.0.0",
"eslint-plugin-react": "^7.0.0"
},
"peerDependencies": {
"eslint": "^8.0.0"
}
}Consumer projects only need:
{
"devDependencies": {
"@rushstack/eslint-patch": "^1.12.0",
"@your-company/eslint-config": "^1.0.0",
"eslint": "^8.0.0"
}
}ESLINT_USE_FLAT_CONFIG) that may reduce need for this patchThe patch handles several error scenarios:
Install with Tessl CLI
npx tessl i tessl/npm-rushstack--eslint-patch