Skip to content

Commit f82793b

Browse files
authored
Merge pull request #4719 from nzakas/main
[eslint-patch] Update for v9
2 parents 73e4e90 + 1dc0e7d commit f82793b

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/eslint-patch",
5+
"comment": "[eslint-patch] Allow use of ESLint v9",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@rushstack/eslint-patch"
10+
}

eslint/eslint-patch/src/_patch-base.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let namingPath: string | undefined = undefined;
3434
let eslintFolder: string | undefined = undefined;
3535

3636
// Probe for the ESLint >=8.0.0 layout:
37-
for (let currentModule: NodeModule = module; ; ) {
37+
for (let currentModule: NodeModule = module; ;) {
3838
if (!eslintrcBundlePath) {
3939
if (currentModule.filename.endsWith('eslintrc.cjs')) {
4040
// For ESLint >=8.0.0, all @eslint/eslintrc code is bundled at this path:
@@ -93,7 +93,7 @@ for (let currentModule: NodeModule = module; ; ) {
9393

9494
if (!eslintFolder) {
9595
// Probe for the ESLint >=7.12.0 layout:
96-
for (let currentModule: NodeModule = module; ; ) {
96+
for (let currentModule: NodeModule = module; ;) {
9797
if (!configArrayFactoryPath) {
9898
// For ESLint >=7.12.0, config-array-factory.js is at this path:
9999
// .../@eslint/eslintrc/lib/config-array-factory.js
@@ -154,7 +154,7 @@ if (!eslintFolder) {
154154

155155
if (!eslintFolder) {
156156
// Probe for the <7.12.0 layout:
157-
for (let currentModule: NodeModule = module; ; ) {
157+
for (let currentModule: NodeModule = module; ;) {
158158
// For ESLint <7.12.0, config-array-factory.js was at this path:
159159
// .../eslint/lib/cli-engine/config-array-factory.js
160160
if (/[\\/]eslint[\\/]lib[\\/]cli-engine[\\/]config-array-factory\.js$/i.test(currentModule.filename)) {
@@ -185,8 +185,8 @@ if (!eslintFolder) {
185185
// This was tested with ESLint 6.1.0 .. 7.12.1.
186186
throw new Error(
187187
'Failed to patch ESLint because the calling module was not recognized.\n' +
188-
'If you are using a newer ESLint version that may be unsupported, please create a GitHub issue:\n' +
189-
'https://github.com/microsoft/rushstack/issues'
188+
'If you are using a newer ESLint version that may be unsupported, please create a GitHub issue:\n' +
189+
'https://github.com/microsoft/rushstack/issues'
190190
);
191191
}
192192
currentModule = currentModule.parent;
@@ -204,18 +204,18 @@ if (isNaN(ESLINT_MAJOR_VERSION)) {
204204
);
205205
}
206206

207-
if (!(ESLINT_MAJOR_VERSION >= 6 && ESLINT_MAJOR_VERSION <= 8)) {
207+
if (!(ESLINT_MAJOR_VERSION >= 6 && ESLINT_MAJOR_VERSION <= 9)) {
208208
throw new Error(
209-
'The ESLint patch script has only been tested with ESLint version 6.x, 7.x, and 8.x.' +
210-
` (Your version: ${eslintPackageVersion})\n` +
211-
'Consider reporting a GitHub issue:\n' +
212-
'https://github.com/microsoft/rushstack/issues'
209+
'The ESLint patch script has only been tested with ESLint version 6.x, 7.x, 8.x, and 9.x.' +
210+
` (Your version: ${eslintPackageVersion})\n` +
211+
'Consider reporting a GitHub issue:\n' +
212+
'https://github.com/microsoft/rushstack/issues'
213213
);
214214
}
215215

216216
// eslint-disable-next-line @typescript-eslint/no-explicit-any
217217
let configArrayFactory: any;
218-
if (ESLINT_MAJOR_VERSION === 8) {
218+
if (ESLINT_MAJOR_VERSION >= 8) {
219219
configArrayFactory = require(eslintrcBundlePath!).Legacy.ConfigArrayFactory;
220220
} else {
221221
configArrayFactory = require(configArrayFactoryPath!).ConfigArrayFactory;
@@ -225,7 +225,7 @@ if (ESLINT_MAJOR_VERSION === 8) {
225225
let ModuleResolver: { resolve: any };
226226
// eslint-disable-next-line @typescript-eslint/no-explicit-any
227227
let Naming: { normalizePackageName: any };
228-
if (ESLINT_MAJOR_VERSION === 8) {
228+
if (ESLINT_MAJOR_VERSION >= 8) {
229229
ModuleResolver = require(eslintrcBundlePath!).Legacy.ModuleResolver;
230230
Naming = require(eslintrcBundlePath!).Legacy.naming;
231231
} else {

0 commit comments

Comments
 (0)