@rushstack/eslint-patch
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -5,2 +5,14 @@ { | ||
{ | ||
"version": "1.0.8", | ||
"tag": "@rushstack/eslint-patch_v1.0.8", | ||
"date": "Wed, 13 Oct 2021 15:09:54 GMT", | ||
"comments": { | ||
"patch": [ | ||
{ | ||
"comment": "Add support for ESLint 8.0.0" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"version": "1.0.7", | ||
@@ -7,0 +19,0 @@ "tag": "@rushstack/eslint-patch_v1.0.7", |
# Change Log - @rushstack/eslint-patch | ||
This log was last generated on Thu, 23 Sep 2021 00:10:40 GMT and should not be manually modified. | ||
This log was last generated on Wed, 13 Oct 2021 15:09:54 GMT and should not be manually modified. | ||
## 1.0.8 | ||
Wed, 13 Oct 2021 15:09:54 GMT | ||
### Patches | ||
- Add support for ESLint 8.0.0 | ||
## 1.0.7 | ||
@@ -6,0 +13,0 @@ Thu, 23 Sep 2021 00:10:40 GMT |
declare const path: any; | ||
declare const fs: any; | ||
declare let eslintrcBundlePath: string | undefined; | ||
declare let configArrayFactoryPath: string | undefined; | ||
@@ -11,3 +12,3 @@ declare let moduleResolverPath: string | undefined; | ||
declare const eslintMajorVersion: number; | ||
declare const ConfigArrayFactory: any; | ||
declare let ConfigArrayFactory: any; | ||
//# sourceMappingURL=modern-module-resolution.d.ts.map |
@@ -12,2 +12,5 @@ "use strict"; | ||
const fs = require('fs'); | ||
// Module path for eslintrc.cjs | ||
// Example: ".../@eslint/eslintrc/dist/eslintrc.cjs" | ||
let eslintrcBundlePath = undefined; | ||
// Module path for config-array-factory.js | ||
@@ -22,11 +25,10 @@ // Example: ".../@eslint/eslintrc/lib/config-array-factory" | ||
let eslintFolder = undefined; | ||
// Probe for the ESLint >=7.8.0 layout: | ||
// Probe for the ESLint >=8.0.0 layout: | ||
for (let currentModule = module;;) { | ||
if (!configArrayFactoryPath) { | ||
// For ESLint >=7.8.0, config-array-factory.js is at this path: | ||
// .../@eslint/eslintrc/lib/config-array-factory.js | ||
if (/[\\/]@eslint[\\/]eslintrc[\\/]lib[\\/]config-array-factory\.js$/i.test(currentModule.filename)) { | ||
if (!eslintrcBundlePath) { | ||
// For ESLint >=8.0.0, all @eslint/eslintrc code is bundled at this path: | ||
// .../@eslint/eslintrc/dist/eslintrc.cjs | ||
if (/[\\/]@eslint[\\/]eslintrc[\\/]dist[\\/]eslintrc\.cjs$/i.test(currentModule.filename)) { | ||
const eslintrcFolder = path.join(path.dirname(currentModule.filename), '..'); | ||
configArrayFactoryPath = path.join(eslintrcFolder, 'lib/config-array-factory'); | ||
moduleResolverPath = path.join(eslintrcFolder, 'lib/shared/relative-module-resolver'); | ||
eslintrcBundlePath = path.join(eslintrcFolder, 'dist/eslintrc.cjs'); | ||
} | ||
@@ -48,2 +50,28 @@ } | ||
if (!eslintFolder) { | ||
// Probe for the ESLint >=7.8.0 layout: | ||
for (let currentModule = module;;) { | ||
if (!configArrayFactoryPath) { | ||
// For ESLint >=7.8.0, config-array-factory.js is at this path: | ||
// .../@eslint/eslintrc/lib/config-array-factory.js | ||
if (/[\\/]@eslint[\\/]eslintrc[\\/]lib[\\/]config-array-factory\.js$/i.test(currentModule.filename)) { | ||
const eslintrcFolder = path.join(path.dirname(currentModule.filename), '..'); | ||
configArrayFactoryPath = path.join(eslintrcFolder, 'lib/config-array-factory'); | ||
moduleResolverPath = path.join(eslintrcFolder, 'lib/shared/relative-module-resolver'); | ||
} | ||
} | ||
else { | ||
// Next look for a file in ESLint's folder | ||
// .../eslint/lib/cli-engine/cli-engine.js | ||
if (/[\\/]eslint[\\/]lib[\\/]cli-engine[\\/]cli-engine\.js$/i.test(currentModule.filename)) { | ||
eslintFolder = path.join(path.dirname(currentModule.filename), '../..'); | ||
break; | ||
} | ||
} | ||
if (!currentModule.parent) { | ||
break; | ||
} | ||
currentModule = currentModule.parent; | ||
} | ||
} | ||
if (!eslintFolder) { | ||
// Probe for the <7.8.0 layout: | ||
@@ -77,4 +105,4 @@ for (let currentModule = module;;) { | ||
const eslintMajorVersion = Number(versionMatch[1]); | ||
if (!(eslintMajorVersion >= 6 && eslintMajorVersion <= 7)) { | ||
throw new Error('The patch-eslint.js script has only been tested with ESLint version 6.x or 7.x.' + | ||
if (!(eslintMajorVersion >= 6 && eslintMajorVersion <= 8)) { | ||
throw new Error('The patch-eslint.js script has only been tested with ESLint version 6.x, 7.x, and 8.x.' + | ||
` (Your version: ${eslintPackageVersion})\n` + | ||
@@ -84,6 +112,18 @@ 'Consider reporting a GitHub issue:\n' + | ||
} | ||
const ConfigArrayFactory = require(configArrayFactoryPath).ConfigArrayFactory; | ||
let ConfigArrayFactory; | ||
if (eslintMajorVersion === 8) { | ||
ConfigArrayFactory = require(eslintrcBundlePath).Legacy.ConfigArrayFactory; | ||
} | ||
else { | ||
ConfigArrayFactory = require(configArrayFactoryPath).ConfigArrayFactory; | ||
} | ||
if (!ConfigArrayFactory.__patched) { | ||
ConfigArrayFactory.__patched = true; | ||
const ModuleResolver = require(moduleResolverPath); | ||
let ModuleResolver; | ||
if (eslintMajorVersion === 8) { | ||
ModuleResolver = require(eslintrcBundlePath).Legacy.ModuleResolver; | ||
} | ||
else { | ||
ModuleResolver = require(moduleResolverPath); | ||
} | ||
const originalLoadPlugin = ConfigArrayFactory.prototype._loadPlugin; | ||
@@ -107,3 +147,3 @@ if (eslintMajorVersion === 6) { | ||
else { | ||
// ESLint 7.x | ||
// ESLint 7.x || 8.x | ||
ConfigArrayFactory.prototype._loadPlugin = function (name, ctx) { | ||
@@ -110,0 +150,0 @@ const originalResolve = ModuleResolver.resolve; |
{ | ||
"name": "@rushstack/eslint-patch", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "A patch that improves how ESLint loads plugins when working in a monorepo with a reusable toolchain", | ||
@@ -24,8 +24,7 @@ "main": "lib/usage.js", | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@rushstack/heft": "0.38.1", | ||
"@rushstack/heft-node-rig": "1.2.13", | ||
"@rushstack/heft": "0.41.6", | ||
"@rushstack/heft-node-rig": "1.2.25", | ||
"@types/node": "12.20.24" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29884
276
6