From 777e9f86911e28e9eb293bc982f5cd7826780eb2 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Thu, 16 May 2024 11:51:00 -0400 Subject: [PATCH 1/2] Update eslint-patch for v9 --- eslint/eslint-patch/src/_patch-base.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eslint/eslint-patch/src/_patch-base.ts b/eslint/eslint-patch/src/_patch-base.ts index 7a9b007d50a..68651d3cb0a 100644 --- a/eslint/eslint-patch/src/_patch-base.ts +++ b/eslint/eslint-patch/src/_patch-base.ts @@ -204,9 +204,9 @@ if (isNaN(ESLINT_MAJOR_VERSION)) { ); } -if (!(ESLINT_MAJOR_VERSION >= 6 && ESLINT_MAJOR_VERSION <= 8)) { +if (!(ESLINT_MAJOR_VERSION >= 6 && ESLINT_MAJOR_VERSION <= 9)) { throw new Error( - 'The ESLint patch script has only been tested with ESLint version 6.x, 7.x, and 8.x.' + + 'The ESLint patch script has only been tested with ESLint version 6.x, 7.x, 8.x, and 9.x.' + ` (Your version: ${eslintPackageVersion})\n` + 'Consider reporting a GitHub issue:\n' + 'https://github.com/microsoft/rushstack/issues' @@ -215,7 +215,7 @@ if (!(ESLINT_MAJOR_VERSION >= 6 && ESLINT_MAJOR_VERSION <= 8)) { // eslint-disable-next-line @typescript-eslint/no-explicit-any let configArrayFactory: any; -if (ESLINT_MAJOR_VERSION === 8) { +if (ESLINT_MAJOR_VERSION >= 8) { configArrayFactory = require(eslintrcBundlePath!).Legacy.ConfigArrayFactory; } else { configArrayFactory = require(configArrayFactoryPath!).ConfigArrayFactory; @@ -225,7 +225,7 @@ if (ESLINT_MAJOR_VERSION === 8) { let ModuleResolver: { resolve: any }; // eslint-disable-next-line @typescript-eslint/no-explicit-any let Naming: { normalizePackageName: any }; -if (ESLINT_MAJOR_VERSION === 8) { +if (ESLINT_MAJOR_VERSION >= 8) { ModuleResolver = require(eslintrcBundlePath!).Legacy.ModuleResolver; Naming = require(eslintrcBundlePath!).Legacy.naming; } else { From 1dc0e7d127c31f90176825fdc245875b46dbb101 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Thu, 16 May 2024 12:06:21 -0400 Subject: [PATCH 2/2] [eslint-patch] Allow use of ESLint v9 --- .../eslint-patch/main_2024-05-16-16-05.json | 10 ++++++++++ eslint/eslint-patch/src/_patch-base.ts | 16 ++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 common/changes/@rushstack/eslint-patch/main_2024-05-16-16-05.json diff --git a/common/changes/@rushstack/eslint-patch/main_2024-05-16-16-05.json b/common/changes/@rushstack/eslint-patch/main_2024-05-16-16-05.json new file mode 100644 index 00000000000..5a6c97d177c --- /dev/null +++ b/common/changes/@rushstack/eslint-patch/main_2024-05-16-16-05.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/eslint-patch", + "comment": "[eslint-patch] Allow use of ESLint v9", + "type": "patch" + } + ], + "packageName": "@rushstack/eslint-patch" +} \ No newline at end of file diff --git a/eslint/eslint-patch/src/_patch-base.ts b/eslint/eslint-patch/src/_patch-base.ts index 68651d3cb0a..9088f4c9572 100644 --- a/eslint/eslint-patch/src/_patch-base.ts +++ b/eslint/eslint-patch/src/_patch-base.ts @@ -34,7 +34,7 @@ let namingPath: string | undefined = undefined; let eslintFolder: string | undefined = undefined; // Probe for the ESLint >=8.0.0 layout: -for (let currentModule: NodeModule = module; ; ) { +for (let currentModule: NodeModule = module; ;) { if (!eslintrcBundlePath) { if (currentModule.filename.endsWith('eslintrc.cjs')) { // For ESLint >=8.0.0, all @eslint/eslintrc code is bundled at this path: @@ -93,7 +93,7 @@ for (let currentModule: NodeModule = module; ; ) { if (!eslintFolder) { // Probe for the ESLint >=7.12.0 layout: - for (let currentModule: NodeModule = module; ; ) { + for (let currentModule: NodeModule = module; ;) { if (!configArrayFactoryPath) { // For ESLint >=7.12.0, config-array-factory.js is at this path: // .../@eslint/eslintrc/lib/config-array-factory.js @@ -154,7 +154,7 @@ if (!eslintFolder) { if (!eslintFolder) { // Probe for the <7.12.0 layout: - for (let currentModule: NodeModule = module; ; ) { + for (let currentModule: NodeModule = module; ;) { // For ESLint <7.12.0, config-array-factory.js was at this path: // .../eslint/lib/cli-engine/config-array-factory.js if (/[\\/]eslint[\\/]lib[\\/]cli-engine[\\/]config-array-factory\.js$/i.test(currentModule.filename)) { @@ -185,8 +185,8 @@ if (!eslintFolder) { // This was tested with ESLint 6.1.0 .. 7.12.1. throw new Error( 'Failed to patch ESLint because the calling module was not recognized.\n' + - 'If you are using a newer ESLint version that may be unsupported, please create a GitHub issue:\n' + - 'https://github.com/microsoft/rushstack/issues' + 'If you are using a newer ESLint version that may be unsupported, please create a GitHub issue:\n' + + 'https://github.com/microsoft/rushstack/issues' ); } currentModule = currentModule.parent; @@ -207,9 +207,9 @@ if (isNaN(ESLINT_MAJOR_VERSION)) { if (!(ESLINT_MAJOR_VERSION >= 6 && ESLINT_MAJOR_VERSION <= 9)) { throw new Error( 'The ESLint patch script has only been tested with ESLint version 6.x, 7.x, 8.x, and 9.x.' + - ` (Your version: ${eslintPackageVersion})\n` + - 'Consider reporting a GitHub issue:\n' + - 'https://github.com/microsoft/rushstack/issues' + ` (Your version: ${eslintPackageVersion})\n` + + 'Consider reporting a GitHub issue:\n' + + 'https://github.com/microsoft/rushstack/issues' ); }