From 60e51274568cd219f8dcdb679046a656ae5e1cea Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 25 Sep 2023 14:02:31 -0700 Subject: [PATCH 01/11] Move the original implementation into the base and remove scenario-specific code --- ...rn-module-resolution.ts => _patch-base.ts} | 73 ++++--------------- 1 file changed, 16 insertions(+), 57 deletions(-) rename eslint/eslint-patch/src/{modern-module-resolution.ts => _patch-base.ts} (78%) diff --git a/eslint/eslint-patch/src/modern-module-resolution.ts b/eslint/eslint-patch/src/_patch-base.ts similarity index 78% rename from eslint/eslint-patch/src/modern-module-resolution.ts rename to eslint/eslint-patch/src/_patch-base.ts index e0e5fe42fea..1165eb2c8ad 100644 --- a/eslint/eslint-patch/src/modern-module-resolution.ts +++ b/eslint/eslint-patch/src/_patch-base.ts @@ -29,6 +29,10 @@ let configArrayFactoryPath: string | undefined = undefined; // Example: ".../@eslint/eslintrc/lib/shared/relative-module-resolver" let moduleResolverPath: string | undefined = undefined; +// Module path for naming.js +// Example: ".../@eslint/eslintrc/lib/shared/naming" +let namingPath: string | undefined = undefined; + // Folder path where ESLint's package.json can be found // Example: ".../node_modules/eslint" let eslintFolder: string | undefined = undefined; @@ -104,6 +108,7 @@ if (!eslintFolder) { if (path.join(eslintrcFolder, '/lib/config-array-factory.js') == currentModule.filename) { configArrayFactoryPath = path.join(eslintrcFolder, 'lib/config-array-factory.js'); moduleResolverPath = path.join(eslintrcFolder, 'lib/shared/relative-module-resolver'); + namingPath = path.join(eslintrcFolder, 'lib/shared/naming'); } } catch (ex: unknown) { // Module resolution failures are expected, as we're walking @@ -153,6 +158,7 @@ if (!eslintFolder) { eslintFolder = path.join(path.dirname(currentModule.filename), '../..'); configArrayFactoryPath = path.join(eslintFolder, 'lib/cli-engine/config-array-factory'); moduleResolverPath = path.join(eslintFolder, 'lib/shared/relative-module-resolver'); + namingPath = path.join(eslintFolder, 'lib/shared/naming'); break; } @@ -192,62 +198,15 @@ if (eslintMajorVersion === 8) { } else { ConfigArrayFactory = require(configArrayFactoryPath!).ConfigArrayFactory; } -if (!ConfigArrayFactory.__patched) { - ConfigArrayFactory.__patched = true; - let ModuleResolver: { resolve: any }; - if (eslintMajorVersion === 8) { - ModuleResolver = require(eslintrcBundlePath!).Legacy.ModuleResolver; - } else { - ModuleResolver = require(moduleResolverPath!); - } - const originalLoadPlugin = ConfigArrayFactory.prototype._loadPlugin; - - if (eslintMajorVersion === 6) { - // ESLint 6.x - ConfigArrayFactory.prototype._loadPlugin = function ( - name: string, - importerPath: string, - importerName: string - ) { - const originalResolve = ModuleResolver.resolve; - try { - ModuleResolver.resolve = function (moduleName: string, relativeToPath: string) { - try { - // resolve using importerPath instead of relativeToPath - return originalResolve.call(this, moduleName, importerPath); - } catch (e) { - if (isModuleResolutionError(e) || isInvalidImporterPath(e)) { - return originalResolve.call(this, moduleName, relativeToPath); - } - throw e; - } - }; - return originalLoadPlugin.apply(this, arguments); - } finally { - ModuleResolver.resolve = originalResolve; - } - }; - } else { - // ESLint 7.x || 8.x - ConfigArrayFactory.prototype._loadPlugin = function (name: string, ctx: Record) { - const originalResolve = ModuleResolver.resolve; - try { - ModuleResolver.resolve = function (moduleName: string, relativeToPath: string) { - try { - // resolve using ctx.filePath instead of relativeToPath - return originalResolve.call(this, moduleName, ctx.filePath); - } catch (e) { - if (isModuleResolutionError(e) || isInvalidImporterPath(e)) { - return originalResolve.call(this, moduleName, relativeToPath); - } - throw e; - } - }; - return originalLoadPlugin.apply(this, arguments); - } finally { - ModuleResolver.resolve = originalResolve; - } - }; - } +let ModuleResolver: { resolve: any }; +let Naming: { normalizePackageName: any }; +if (eslintMajorVersion === 8) { + ModuleResolver = require(eslintrcBundlePath!).Legacy.ModuleResolver; + Naming = require(eslintrcBundlePath!).Legacy.naming; +} else { + ModuleResolver = require(moduleResolverPath!); + Naming = require(namingPath!); } + +export { ConfigArrayFactory, ModuleResolver, Naming, eslintMajorVersion as EslintMajorVersion }; From cb2949609a6c52d6dc7f0e20b24ea7139a2908ad Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 25 Sep 2023 14:46:06 -0700 Subject: [PATCH 02/11] Update based on PR feedback --- eslint/eslint-patch/src/_patch-base.ts | 31 +++++--- .../src/custom-config-package-names.ts | 45 +++++++++++ .../src/modern-module-resolution.ts | 74 +++++++++++++++++++ 3 files changed, 138 insertions(+), 12 deletions(-) create mode 100644 eslint/eslint-patch/src/custom-config-package-names.ts create mode 100644 eslint/eslint-patch/src/modern-module-resolution.ts diff --git a/eslint/eslint-patch/src/_patch-base.ts b/eslint/eslint-patch/src/_patch-base.ts index 1165eb2c8ad..9524e1cee76 100644 --- a/eslint/eslint-patch/src/_patch-base.ts +++ b/eslint/eslint-patch/src/_patch-base.ts @@ -13,10 +13,6 @@ const fs = require('fs'); const isModuleResolutionError: (ex: unknown) => boolean = (ex) => typeof ex === 'object' && !!ex && 'code' in ex && (ex as { code: unknown }).code === 'MODULE_NOT_FOUND'; -// error: "The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''" -const isInvalidImporterPath: (ex: unknown) => boolean = (ex) => - (ex as { code: unknown } | undefined)?.code === 'ERR_INVALID_ARG_VALUE'; - // Module path for eslintrc.cjs // Example: ".../@eslint/eslintrc/dist/eslintrc.cjs" let eslintrcBundlePath: string | undefined = undefined; @@ -39,7 +35,7 @@ let eslintFolder: string | undefined = undefined; // Probe for the ESLint >=8.0.0 layout: for (let currentModule = module; ; ) { - if (!eslintrcBundlePath) { + if (!eslintrcBundlePath && currentModule.filename.endsWith('eslintrc.cjs')) { // For ESLint >=8.0.0, all @eslint/eslintrc code is bundled at this path: // .../@eslint/eslintrc/dist/eslintrc.cjs try { @@ -49,8 +45,9 @@ for (let currentModule = module; ; ) { // Make sure we actually resolved the module in our call path // and not some other spurious dependency. - if (path.join(eslintrcFolder, 'dist/eslintrc.cjs') === currentModule.filename) { - eslintrcBundlePath = path.join(eslintrcFolder, 'dist/eslintrc.cjs'); + const resolvedEslintrcBundlePath: string = path.join(eslintrcFolder, 'dist/eslintrc.cjs'); + if (resolvedEslintrcBundlePath === currentModule.filename) { + eslintrcBundlePath = resolvedEslintrcBundlePath; } } catch (ex: unknown) { // Module resolution failures are expected, as we're walking @@ -95,7 +92,7 @@ for (let currentModule = module; ; ) { if (!eslintFolder) { // Probe for the ESLint >=7.8.0 layout: for (let currentModule = module; ; ) { - if (!configArrayFactoryPath) { + if (!configArrayFactoryPath && currentModule.filename.endsWith('config-array-factory.js')) { // For ESLint >=7.8.0, config-array-factory.js is at this path: // .../@eslint/eslintrc/lib/config-array-factory.js try { @@ -105,8 +102,12 @@ if (!eslintFolder) { }) ); - if (path.join(eslintrcFolder, '/lib/config-array-factory.js') == currentModule.filename) { - configArrayFactoryPath = path.join(eslintrcFolder, 'lib/config-array-factory.js'); + const resolvedConfigArrayFactoryPath: string = path.join( + eslintrcFolder, + '/lib/config-array-factory.js' + ); + if (resolvedConfigArrayFactoryPath === currentModule.filename) { + configArrayFactoryPath = resolvedConfigArrayFactoryPath; moduleResolverPath = path.join(eslintrcFolder, 'lib/shared/relative-module-resolver'); namingPath = path.join(eslintrcFolder, 'lib/shared/naming'); } @@ -118,7 +119,7 @@ if (!eslintFolder) { throw ex; } } - } else { + } else if (currentModule.filename.endsWith('cli-engine.js')) { // Next look for a file in ESLint's folder // .../eslint/lib/cli-engine/cli-engine.js try { @@ -209,4 +210,10 @@ if (eslintMajorVersion === 8) { Naming = require(namingPath!); } -export { ConfigArrayFactory, ModuleResolver, Naming, eslintMajorVersion as EslintMajorVersion }; +export { + ConfigArrayFactory, + ModuleResolver, + Naming, + eslintMajorVersion as EslintMajorVersion, + isModuleResolutionError +}; diff --git a/eslint/eslint-patch/src/custom-config-package-names.ts b/eslint/eslint-patch/src/custom-config-package-names.ts new file mode 100644 index 00000000000..740b9c66ba4 --- /dev/null +++ b/eslint/eslint-patch/src/custom-config-package-names.ts @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +// This is a workaround for ESLint's requirement to consume shareable configurations from package names prefixed +// with "eslint-config". +// +// To remove this requirement, add this line to the top of your project's .eslintrc.js file: +// +// require("@rushstack/eslint-patch/custom-config-package-names"); +// +import { ConfigArrayFactory, ModuleResolver, Naming } from './_patch-base'; + +if (!ConfigArrayFactory.__loadExtendedShareableConfigPatched) { + ConfigArrayFactory.__loadExtendedShareableConfigPatched = true; + const originalLoadExtendedShareableConfig = ConfigArrayFactory.prototype._loadExtendedShareableConfig; + + // Common between ESLint versions + // https://github.com/eslint/eslintrc/blob/242d569020dfe4f561e4503787b99ec016337457/lib/config-array-factory.js#L910 + ConfigArrayFactory.prototype._loadExtendedShareableConfig = function (extendName: string) { + const originalResolve = ModuleResolver.resolve; + try { + ModuleResolver.resolve = function (moduleName: string, relativeToPath: string) { + try { + return originalResolve.call(this, moduleName, relativeToPath); + } catch (e) { + // Only change the name we resolve if we cannot find the normalized module, since it is + // valid to rely on the normalized package name. Use the originally provided module path + // instead of the normalized module path. + if ( + (e as NodeJS.ErrnoException)?.code === 'MODULE_NOT_FOUND' && + moduleName !== extendName && + moduleName === Naming.normalizePackageName(extendName, 'eslint-config') + ) { + return originalResolve.call(this, extendName, relativeToPath); + } else { + throw e; + } + } + }; + return originalLoadExtendedShareableConfig.apply(this, arguments); + } finally { + ModuleResolver.resolve = originalResolve; + } + }; +} diff --git a/eslint/eslint-patch/src/modern-module-resolution.ts b/eslint/eslint-patch/src/modern-module-resolution.ts new file mode 100644 index 00000000000..f1c3d8b9905 --- /dev/null +++ b/eslint/eslint-patch/src/modern-module-resolution.ts @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. +// This is a workaround for https://github.com/eslint/eslint/issues/3458 +// +// To correct how ESLint searches for plugin packages, add this line to the top of your project's .eslintrc.js file: +// +// require("@rushstack/eslint-patch/modern-module-resolution"); +// + +import { + EslintMajorVersion, + ConfigArrayFactory, + ModuleResolver, + isModuleResolutionError +} from './_patch-base'; + +// error: "The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''" +const isInvalidImporterPath: (ex: unknown) => boolean = (ex) => + (ex as { code: unknown } | undefined)?.code === 'ERR_INVALID_ARG_VALUE'; + +if (!ConfigArrayFactory.__loadPluginPatched) { + ConfigArrayFactory.__loadPluginPatched = true; + const originalLoadPlugin = ConfigArrayFactory.prototype._loadPlugin; + + if (EslintMajorVersion === 6) { + // ESLint 6.x + // https://github.com/eslint/eslint/blob/9738f8cc864d769988ccf42bb70f524444df1349/lib/cli-engine/config-array-factory.js#L915 + ConfigArrayFactory.prototype._loadPlugin = function ( + name: string, + importerPath: string, + importerName: string + ) { + const originalResolve = ModuleResolver.resolve; + try { + ModuleResolver.resolve = function (moduleName: string, relativeToPath: string) { + try { + // resolve using importerPath instead of relativeToPath + return originalResolve.call(this, moduleName, importerPath); + } catch (e) { + if (isModuleResolutionError(e) || isInvalidImporterPath(e)) { + return originalResolve.call(this, moduleName, relativeToPath); + } + throw e; + } + }; + return originalLoadPlugin.apply(this, arguments); + } finally { + ModuleResolver.resolve = originalResolve; + } + }; + } else { + // ESLint 7.x || 8.x + // https://github.com/eslint/eslintrc/blob/242d569020dfe4f561e4503787b99ec016337457/lib/config-array-factory.js#L1023 + ConfigArrayFactory.prototype._loadPlugin = function (name: string, ctx: Record) { + const originalResolve = ModuleResolver.resolve; + try { + ModuleResolver.resolve = function (moduleName: string, relativeToPath: string) { + try { + // resolve using ctx.filePath instead of relativeToPath + return originalResolve.call(this, moduleName, ctx.filePath); + } catch (e) { + if (isModuleResolutionError(e) || isInvalidImporterPath(e)) { + return originalResolve.call(this, moduleName, relativeToPath); + } + throw e; + } + }; + return originalLoadPlugin.apply(this, arguments); + } finally { + ModuleResolver.resolve = originalResolve; + } + }; + } +} From a65f336983b3fa2b0171062a7503dffd2f2afb19 Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 25 Sep 2023 15:26:54 -0700 Subject: [PATCH 03/11] Fixes --- eslint/eslint-config/patch/custom-config-package-names.js | 4 ++++ eslint/eslint-patch/src/_patch-base.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 eslint/eslint-config/patch/custom-config-package-names.js diff --git a/eslint/eslint-config/patch/custom-config-package-names.js b/eslint/eslint-config/patch/custom-config-package-names.js new file mode 100644 index 00000000000..20341195020 --- /dev/null +++ b/eslint/eslint-config/patch/custom-config-package-names.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/eslint-patch/custom-config-package-names'); diff --git a/eslint/eslint-patch/src/_patch-base.ts b/eslint/eslint-patch/src/_patch-base.ts index 9524e1cee76..b2b533bc14e 100644 --- a/eslint/eslint-patch/src/_patch-base.ts +++ b/eslint/eslint-patch/src/_patch-base.ts @@ -193,7 +193,7 @@ if (!(eslintMajorVersion >= 6 && eslintMajorVersion <= 8)) { ); } -let ConfigArrayFactory; +let ConfigArrayFactory: any; if (eslintMajorVersion === 8) { ConfigArrayFactory = require(eslintrcBundlePath!).Legacy.ConfigArrayFactory; } else { From 78777f8c78aaa5a7292c57008582698486f34e9d Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 25 Sep 2023 15:27:48 -0700 Subject: [PATCH 04/11] Add eslint profiles, mixins, and patches to rigs --- common/config/rush/pnpm-lock.yaml | 13 ++++++++++++- common/config/rush/repo-state.json | 2 +- rigs/heft-node-rig/package.json | 1 + .../includes/eslint/mixins/friendly-locals.js | 6 ++++++ .../default/includes/eslint/mixins/packlets.js | 6 ++++++ .../default/includes/eslint/mixins/react.js | 6 ++++++ .../default/includes/eslint/mixins/todoc.js | 6 ++++++ .../eslint/patch/custom-config-package-names.js | 4 ++++ .../eslint/patch/modern-module-resolution.js | 4 ++++ .../includes/eslint/profile/node-trusted-tool.js | 0 .../default/includes/eslint/profile/node.js | 6 ++++++ rigs/heft-web-rig/package.json | 1 + .../app/includes/eslint/mixins/friendly-locals.js | 6 ++++++ .../profiles/app/includes/eslint/mixins/packlets.js | 6 ++++++ .../profiles/app/includes/eslint/mixins/react.js | 6 ++++++ .../profiles/app/includes/eslint/mixins/todoc.js | 6 ++++++ .../eslint/patch/custom-config-package-names.js | 4 ++++ .../eslint/patch/modern-module-resolution.js | 4 ++++ .../profiles/app/includes/eslint/profile/web-app.js | 6 ++++++ .../includes/eslint/mixins/friendly-locals.js | 6 ++++++ .../library/includes/eslint/mixins/packlets.js | 6 ++++++ .../library/includes/eslint/mixins/react.js | 6 ++++++ .../library/includes/eslint/mixins/todoc.js | 6 ++++++ .../eslint/patch/custom-config-package-names.js | 4 ++++ .../eslint/patch/modern-module-resolution.js | 4 ++++ .../library/includes/eslint/profile/web-app.js | 6 ++++++ .../includes/eslint/mixins/friendly-locals.js | 6 ++++++ .../default/includes/eslint/mixins/packlets.js | 6 ++++++ .../default/includes/eslint/mixins/react.js | 6 ++++++ .../default/includes/eslint/mixins/todoc.js | 6 ++++++ .../eslint/patch/custom-config-package-names.js | 4 ++++ .../eslint/patch/modern-module-resolution.js | 4 ++++ .../includes/eslint/profile/node-trusted-tool.js | 6 ++++++ .../default/includes/eslint/profile/node.js | 6 ++++++ .../app/includes/eslint/mixins/friendly-locals.js | 6 ++++++ .../profiles/app/includes/eslint/mixins/packlets.js | 6 ++++++ .../profiles/app/includes/eslint/mixins/react.js | 6 ++++++ .../profiles/app/includes/eslint/mixins/todoc.js | 6 ++++++ .../eslint/patch/custom-config-package-names.js | 4 ++++ .../eslint/patch/modern-module-resolution.js | 4 ++++ .../profiles/app/includes/eslint/profile/web-app.js | 6 ++++++ .../includes/eslint/mixins/friendly-locals.js | 6 ++++++ .../library/includes/eslint/mixins/packlets.js | 6 ++++++ .../library/includes/eslint/mixins/react.js | 6 ++++++ .../library/includes/eslint/mixins/todoc.js | 6 ++++++ .../eslint/patch/custom-config-package-names.js | 4 ++++ .../eslint/patch/modern-module-resolution.js | 4 ++++ .../library/includes/eslint/profile/web-app.js | 6 ++++++ 48 files changed, 249 insertions(+), 2 deletions(-) create mode 100644 rigs/heft-node-rig/profiles/default/includes/eslint/mixins/friendly-locals.js create mode 100644 rigs/heft-node-rig/profiles/default/includes/eslint/mixins/packlets.js create mode 100644 rigs/heft-node-rig/profiles/default/includes/eslint/mixins/react.js create mode 100644 rigs/heft-node-rig/profiles/default/includes/eslint/mixins/todoc.js create mode 100644 rigs/heft-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names.js create mode 100644 rigs/heft-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution.js create mode 100644 rigs/heft-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool.js create mode 100644 rigs/heft-node-rig/profiles/default/includes/eslint/profile/node.js create mode 100644 rigs/heft-web-rig/profiles/app/includes/eslint/mixins/friendly-locals.js create mode 100644 rigs/heft-web-rig/profiles/app/includes/eslint/mixins/packlets.js create mode 100644 rigs/heft-web-rig/profiles/app/includes/eslint/mixins/react.js create mode 100644 rigs/heft-web-rig/profiles/app/includes/eslint/mixins/todoc.js create mode 100644 rigs/heft-web-rig/profiles/app/includes/eslint/patch/custom-config-package-names.js create mode 100644 rigs/heft-web-rig/profiles/app/includes/eslint/patch/modern-module-resolution.js create mode 100644 rigs/heft-web-rig/profiles/app/includes/eslint/profile/web-app.js create mode 100644 rigs/heft-web-rig/profiles/library/includes/eslint/mixins/friendly-locals.js create mode 100644 rigs/heft-web-rig/profiles/library/includes/eslint/mixins/packlets.js create mode 100644 rigs/heft-web-rig/profiles/library/includes/eslint/mixins/react.js create mode 100644 rigs/heft-web-rig/profiles/library/includes/eslint/mixins/todoc.js create mode 100644 rigs/heft-web-rig/profiles/library/includes/eslint/patch/custom-config-package-names.js create mode 100644 rigs/heft-web-rig/profiles/library/includes/eslint/patch/modern-module-resolution.js create mode 100644 rigs/heft-web-rig/profiles/library/includes/eslint/profile/web-app.js create mode 100644 rigs/local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals.js create mode 100644 rigs/local-node-rig/profiles/default/includes/eslint/mixins/packlets.js create mode 100644 rigs/local-node-rig/profiles/default/includes/eslint/mixins/react.js create mode 100644 rigs/local-node-rig/profiles/default/includes/eslint/mixins/todoc.js create mode 100644 rigs/local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names.js create mode 100644 rigs/local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution.js create mode 100644 rigs/local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool.js create mode 100644 rigs/local-node-rig/profiles/default/includes/eslint/profile/node.js create mode 100644 rigs/local-web-rig/profiles/app/includes/eslint/mixins/friendly-locals.js create mode 100644 rigs/local-web-rig/profiles/app/includes/eslint/mixins/packlets.js create mode 100644 rigs/local-web-rig/profiles/app/includes/eslint/mixins/react.js create mode 100644 rigs/local-web-rig/profiles/app/includes/eslint/mixins/todoc.js create mode 100644 rigs/local-web-rig/profiles/app/includes/eslint/patch/custom-config-package-names.js create mode 100644 rigs/local-web-rig/profiles/app/includes/eslint/patch/modern-module-resolution.js create mode 100644 rigs/local-web-rig/profiles/app/includes/eslint/profile/web-app.js create mode 100644 rigs/local-web-rig/profiles/library/includes/eslint/mixins/friendly-locals.js create mode 100644 rigs/local-web-rig/profiles/library/includes/eslint/mixins/packlets.js create mode 100644 rigs/local-web-rig/profiles/library/includes/eslint/mixins/react.js create mode 100644 rigs/local-web-rig/profiles/library/includes/eslint/mixins/todoc.js create mode 100644 rigs/local-web-rig/profiles/library/includes/eslint/patch/custom-config-package-names.js create mode 100644 rigs/local-web-rig/profiles/library/includes/eslint/patch/modern-module-resolution.js create mode 100644 rigs/local-web-rig/profiles/library/includes/eslint/profile/web-app.js diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index b940bcc8fb0..b67dbf75f50 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1713,7 +1713,7 @@ importers: version: 29.5.5 '@types/node': specifier: ts4.9 - version: 20.6.2 + version: 20.7.0 eslint: specifier: ~8.7.0 version: 8.7.0 @@ -3528,6 +3528,9 @@ importers: '@microsoft/api-extractor': specifier: workspace:* version: link:../../apps/api-extractor + '@rushstack/eslint-config': + specifier: workspace:* + version: link:../../eslint/eslint-config '@rushstack/heft-api-extractor-plugin': specifier: workspace:* version: link:../../heft-plugins/heft-api-extractor-plugin @@ -3562,6 +3565,9 @@ importers: '@microsoft/api-extractor': specifier: workspace:* version: link:../../apps/api-extractor + '@rushstack/eslint-config': + specifier: workspace:* + version: link:../../eslint/eslint-config '@rushstack/heft-api-extractor-plugin': specifier: workspace:* version: link:../../heft-plugins/heft-api-extractor-plugin @@ -11455,6 +11461,11 @@ packages: /@types/node@20.6.2: resolution: {integrity: sha512-Y+/1vGBHV/cYk6OI1Na/LHzwnlNCAfU3ZNGrc1LdRe/LAIbdDPTTv/HU3M7yXN448aTVDq3eKRm2cg7iKLb8gw==} + dev: false + + /@types/node@20.7.0: + resolution: {integrity: sha512-zI22/pJW2wUZOVyguFaUL1HABdmSVxpXrzIqkjsHmyUjNhPoWM1CKfvVuXfetHhIok4RY573cqS0mZ1SJEnoTg==} + dev: true /@types/normalize-package-data@2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} diff --git a/common/config/rush/repo-state.json b/common/config/rush/repo-state.json index a14b4c836f8..1fe5517b54c 100644 --- a/common/config/rush/repo-state.json +++ b/common/config/rush/repo-state.json @@ -1,5 +1,5 @@ // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. { - "pnpmShrinkwrapHash": "d51a09f515584d6959a8837c0df5200d2d8856f7", + "pnpmShrinkwrapHash": "92561e650a0b5a0ffde5b5dcc107d597c755b413", "preferredVersionsHash": "1926a5b12ac8f4ab41e76503a0d1d0dccc9c0e06" } diff --git a/rigs/heft-node-rig/package.json b/rigs/heft-node-rig/package.json index d056578756b..2a7935a8cca 100644 --- a/rigs/heft-node-rig/package.json +++ b/rigs/heft-node-rig/package.json @@ -17,6 +17,7 @@ }, "dependencies": { "@microsoft/api-extractor": "workspace:*", + "@rushstack/eslint-config": "workspace:*", "@rushstack/heft-api-extractor-plugin": "workspace:*", "@rushstack/heft-jest-plugin": "workspace:*", "@rushstack/heft-lint-plugin": "workspace:*", diff --git a/rigs/heft-node-rig/profiles/default/includes/eslint/mixins/friendly-locals.js b/rigs/heft-node-rig/profiles/default/includes/eslint/mixins/friendly-locals.js new file mode 100644 index 00000000000..e6cbfeacc95 --- /dev/null +++ b/rigs/heft-node-rig/profiles/default/includes/eslint/mixins/friendly-locals.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/mixins/friendly-locals'] +}; diff --git a/rigs/heft-node-rig/profiles/default/includes/eslint/mixins/packlets.js b/rigs/heft-node-rig/profiles/default/includes/eslint/mixins/packlets.js new file mode 100644 index 00000000000..82a19efce16 --- /dev/null +++ b/rigs/heft-node-rig/profiles/default/includes/eslint/mixins/packlets.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/mixins/packlets'] +}; diff --git a/rigs/heft-node-rig/profiles/default/includes/eslint/mixins/react.js b/rigs/heft-node-rig/profiles/default/includes/eslint/mixins/react.js new file mode 100644 index 00000000000..796699ee874 --- /dev/null +++ b/rigs/heft-node-rig/profiles/default/includes/eslint/mixins/react.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/mixins/react'] +}; diff --git a/rigs/heft-node-rig/profiles/default/includes/eslint/mixins/todoc.js b/rigs/heft-node-rig/profiles/default/includes/eslint/mixins/todoc.js new file mode 100644 index 00000000000..6549f342a9b --- /dev/null +++ b/rigs/heft-node-rig/profiles/default/includes/eslint/mixins/todoc.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/mixins/todoc'] +}; diff --git a/rigs/heft-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names.js b/rigs/heft-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names.js new file mode 100644 index 00000000000..1fe7079f030 --- /dev/null +++ b/rigs/heft-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/eslint-config/patch/custom-config-package-names'); diff --git a/rigs/heft-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution.js b/rigs/heft-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution.js new file mode 100644 index 00000000000..14e8d976c23 --- /dev/null +++ b/rigs/heft-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/eslint-config/patch/modern-module-resolution'); diff --git a/rigs/heft-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool.js b/rigs/heft-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/rigs/heft-node-rig/profiles/default/includes/eslint/profile/node.js b/rigs/heft-node-rig/profiles/default/includes/eslint/profile/node.js new file mode 100644 index 00000000000..edd8dbb2cd2 --- /dev/null +++ b/rigs/heft-node-rig/profiles/default/includes/eslint/profile/node.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/profile/node'] +}; diff --git a/rigs/heft-web-rig/package.json b/rigs/heft-web-rig/package.json index e3a644fd2c4..83af5bd316d 100644 --- a/rigs/heft-web-rig/package.json +++ b/rigs/heft-web-rig/package.json @@ -17,6 +17,7 @@ }, "dependencies": { "@microsoft/api-extractor": "workspace:*", + "@rushstack/eslint-config": "workspace:*", "@rushstack/heft-api-extractor-plugin": "workspace:*", "@rushstack/heft-jest-plugin": "workspace:*", "@rushstack/heft-lint-plugin": "workspace:*", diff --git a/rigs/heft-web-rig/profiles/app/includes/eslint/mixins/friendly-locals.js b/rigs/heft-web-rig/profiles/app/includes/eslint/mixins/friendly-locals.js new file mode 100644 index 00000000000..e6cbfeacc95 --- /dev/null +++ b/rigs/heft-web-rig/profiles/app/includes/eslint/mixins/friendly-locals.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/mixins/friendly-locals'] +}; diff --git a/rigs/heft-web-rig/profiles/app/includes/eslint/mixins/packlets.js b/rigs/heft-web-rig/profiles/app/includes/eslint/mixins/packlets.js new file mode 100644 index 00000000000..82a19efce16 --- /dev/null +++ b/rigs/heft-web-rig/profiles/app/includes/eslint/mixins/packlets.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/mixins/packlets'] +}; diff --git a/rigs/heft-web-rig/profiles/app/includes/eslint/mixins/react.js b/rigs/heft-web-rig/profiles/app/includes/eslint/mixins/react.js new file mode 100644 index 00000000000..796699ee874 --- /dev/null +++ b/rigs/heft-web-rig/profiles/app/includes/eslint/mixins/react.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/mixins/react'] +}; diff --git a/rigs/heft-web-rig/profiles/app/includes/eslint/mixins/todoc.js b/rigs/heft-web-rig/profiles/app/includes/eslint/mixins/todoc.js new file mode 100644 index 00000000000..6549f342a9b --- /dev/null +++ b/rigs/heft-web-rig/profiles/app/includes/eslint/mixins/todoc.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/mixins/todoc'] +}; diff --git a/rigs/heft-web-rig/profiles/app/includes/eslint/patch/custom-config-package-names.js b/rigs/heft-web-rig/profiles/app/includes/eslint/patch/custom-config-package-names.js new file mode 100644 index 00000000000..1fe7079f030 --- /dev/null +++ b/rigs/heft-web-rig/profiles/app/includes/eslint/patch/custom-config-package-names.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/eslint-config/patch/custom-config-package-names'); diff --git a/rigs/heft-web-rig/profiles/app/includes/eslint/patch/modern-module-resolution.js b/rigs/heft-web-rig/profiles/app/includes/eslint/patch/modern-module-resolution.js new file mode 100644 index 00000000000..14e8d976c23 --- /dev/null +++ b/rigs/heft-web-rig/profiles/app/includes/eslint/patch/modern-module-resolution.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/eslint-config/patch/modern-module-resolution'); diff --git a/rigs/heft-web-rig/profiles/app/includes/eslint/profile/web-app.js b/rigs/heft-web-rig/profiles/app/includes/eslint/profile/web-app.js new file mode 100644 index 00000000000..eaa661335e4 --- /dev/null +++ b/rigs/heft-web-rig/profiles/app/includes/eslint/profile/web-app.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/profile/web-app'] +}; diff --git a/rigs/heft-web-rig/profiles/library/includes/eslint/mixins/friendly-locals.js b/rigs/heft-web-rig/profiles/library/includes/eslint/mixins/friendly-locals.js new file mode 100644 index 00000000000..e6cbfeacc95 --- /dev/null +++ b/rigs/heft-web-rig/profiles/library/includes/eslint/mixins/friendly-locals.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/mixins/friendly-locals'] +}; diff --git a/rigs/heft-web-rig/profiles/library/includes/eslint/mixins/packlets.js b/rigs/heft-web-rig/profiles/library/includes/eslint/mixins/packlets.js new file mode 100644 index 00000000000..82a19efce16 --- /dev/null +++ b/rigs/heft-web-rig/profiles/library/includes/eslint/mixins/packlets.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/mixins/packlets'] +}; diff --git a/rigs/heft-web-rig/profiles/library/includes/eslint/mixins/react.js b/rigs/heft-web-rig/profiles/library/includes/eslint/mixins/react.js new file mode 100644 index 00000000000..796699ee874 --- /dev/null +++ b/rigs/heft-web-rig/profiles/library/includes/eslint/mixins/react.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/mixins/react'] +}; diff --git a/rigs/heft-web-rig/profiles/library/includes/eslint/mixins/todoc.js b/rigs/heft-web-rig/profiles/library/includes/eslint/mixins/todoc.js new file mode 100644 index 00000000000..6549f342a9b --- /dev/null +++ b/rigs/heft-web-rig/profiles/library/includes/eslint/mixins/todoc.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/mixins/todoc'] +}; diff --git a/rigs/heft-web-rig/profiles/library/includes/eslint/patch/custom-config-package-names.js b/rigs/heft-web-rig/profiles/library/includes/eslint/patch/custom-config-package-names.js new file mode 100644 index 00000000000..1fe7079f030 --- /dev/null +++ b/rigs/heft-web-rig/profiles/library/includes/eslint/patch/custom-config-package-names.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/eslint-config/patch/custom-config-package-names'); diff --git a/rigs/heft-web-rig/profiles/library/includes/eslint/patch/modern-module-resolution.js b/rigs/heft-web-rig/profiles/library/includes/eslint/patch/modern-module-resolution.js new file mode 100644 index 00000000000..14e8d976c23 --- /dev/null +++ b/rigs/heft-web-rig/profiles/library/includes/eslint/patch/modern-module-resolution.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/eslint-config/patch/modern-module-resolution'); diff --git a/rigs/heft-web-rig/profiles/library/includes/eslint/profile/web-app.js b/rigs/heft-web-rig/profiles/library/includes/eslint/profile/web-app.js new file mode 100644 index 00000000000..eaa661335e4 --- /dev/null +++ b/rigs/heft-web-rig/profiles/library/includes/eslint/profile/web-app.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/profile/web-app'] +}; diff --git a/rigs/local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals.js b/rigs/local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals.js new file mode 100644 index 00000000000..49bc508ea28 --- /dev/null +++ b/rigs/local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'] +}; diff --git a/rigs/local-node-rig/profiles/default/includes/eslint/mixins/packlets.js b/rigs/local-node-rig/profiles/default/includes/eslint/mixins/packlets.js new file mode 100644 index 00000000000..8bfe919b136 --- /dev/null +++ b/rigs/local-node-rig/profiles/default/includes/eslint/mixins/packlets.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-node-rig/profiles/default/includes/eslint/mixins/packlets'] +}; diff --git a/rigs/local-node-rig/profiles/default/includes/eslint/mixins/react.js b/rigs/local-node-rig/profiles/default/includes/eslint/mixins/react.js new file mode 100644 index 00000000000..729dc3907cc --- /dev/null +++ b/rigs/local-node-rig/profiles/default/includes/eslint/mixins/react.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-node-rig/profiles/default/includes/eslint/mixins/react'] +}; diff --git a/rigs/local-node-rig/profiles/default/includes/eslint/mixins/todoc.js b/rigs/local-node-rig/profiles/default/includes/eslint/mixins/todoc.js new file mode 100644 index 00000000000..32406a12216 --- /dev/null +++ b/rigs/local-node-rig/profiles/default/includes/eslint/mixins/todoc.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-node-rig/profiles/default/includes/eslint/mixins/todoc'] +}; diff --git a/rigs/local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names.js b/rigs/local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names.js new file mode 100644 index 00000000000..8c890cc064a --- /dev/null +++ b/rigs/local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/heft-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names'); diff --git a/rigs/local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution.js b/rigs/local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution.js new file mode 100644 index 00000000000..2b1490952e9 --- /dev/null +++ b/rigs/local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/heft-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution'); diff --git a/rigs/local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool.js b/rigs/local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool.js new file mode 100644 index 00000000000..409f02f8b55 --- /dev/null +++ b/rigs/local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool'] +}; diff --git a/rigs/local-node-rig/profiles/default/includes/eslint/profile/node.js b/rigs/local-node-rig/profiles/default/includes/eslint/profile/node.js new file mode 100644 index 00000000000..f8acc7596c2 --- /dev/null +++ b/rigs/local-node-rig/profiles/default/includes/eslint/profile/node.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-node-rig/profiles/default/includes/eslint/profile/node'] +}; diff --git a/rigs/local-web-rig/profiles/app/includes/eslint/mixins/friendly-locals.js b/rigs/local-web-rig/profiles/app/includes/eslint/mixins/friendly-locals.js new file mode 100644 index 00000000000..316e696305e --- /dev/null +++ b/rigs/local-web-rig/profiles/app/includes/eslint/mixins/friendly-locals.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-web-rig/profiles/default/includes/eslint/mixins/friendly-locals'] +}; diff --git a/rigs/local-web-rig/profiles/app/includes/eslint/mixins/packlets.js b/rigs/local-web-rig/profiles/app/includes/eslint/mixins/packlets.js new file mode 100644 index 00000000000..c2137f92f29 --- /dev/null +++ b/rigs/local-web-rig/profiles/app/includes/eslint/mixins/packlets.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-web-rig/profiles/default/includes/eslint/mixins/packlets'] +}; diff --git a/rigs/local-web-rig/profiles/app/includes/eslint/mixins/react.js b/rigs/local-web-rig/profiles/app/includes/eslint/mixins/react.js new file mode 100644 index 00000000000..1ebbea88ff4 --- /dev/null +++ b/rigs/local-web-rig/profiles/app/includes/eslint/mixins/react.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-web-rig/profiles/default/includes/eslint/mixins/react'] +}; diff --git a/rigs/local-web-rig/profiles/app/includes/eslint/mixins/todoc.js b/rigs/local-web-rig/profiles/app/includes/eslint/mixins/todoc.js new file mode 100644 index 00000000000..baeaac3cd3b --- /dev/null +++ b/rigs/local-web-rig/profiles/app/includes/eslint/mixins/todoc.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-web-rig/profiles/default/includes/eslint/mixins/todoc'] +}; diff --git a/rigs/local-web-rig/profiles/app/includes/eslint/patch/custom-config-package-names.js b/rigs/local-web-rig/profiles/app/includes/eslint/patch/custom-config-package-names.js new file mode 100644 index 00000000000..a237a04e48f --- /dev/null +++ b/rigs/local-web-rig/profiles/app/includes/eslint/patch/custom-config-package-names.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/heft-web-rig/profiles/default/includes/eslint/patch/custom-config-package-names'); diff --git a/rigs/local-web-rig/profiles/app/includes/eslint/patch/modern-module-resolution.js b/rigs/local-web-rig/profiles/app/includes/eslint/patch/modern-module-resolution.js new file mode 100644 index 00000000000..d34dc95fc19 --- /dev/null +++ b/rigs/local-web-rig/profiles/app/includes/eslint/patch/modern-module-resolution.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/heft-web-rig/profiles/default/includes/eslint/patch/modern-module-resolution'); diff --git a/rigs/local-web-rig/profiles/app/includes/eslint/profile/web-app.js b/rigs/local-web-rig/profiles/app/includes/eslint/profile/web-app.js new file mode 100644 index 00000000000..5e57a323a20 --- /dev/null +++ b/rigs/local-web-rig/profiles/app/includes/eslint/profile/web-app.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-web-rig/profiles/app/includes/eslint/profile/web-app'] +}; diff --git a/rigs/local-web-rig/profiles/library/includes/eslint/mixins/friendly-locals.js b/rigs/local-web-rig/profiles/library/includes/eslint/mixins/friendly-locals.js new file mode 100644 index 00000000000..316e696305e --- /dev/null +++ b/rigs/local-web-rig/profiles/library/includes/eslint/mixins/friendly-locals.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-web-rig/profiles/default/includes/eslint/mixins/friendly-locals'] +}; diff --git a/rigs/local-web-rig/profiles/library/includes/eslint/mixins/packlets.js b/rigs/local-web-rig/profiles/library/includes/eslint/mixins/packlets.js new file mode 100644 index 00000000000..c2137f92f29 --- /dev/null +++ b/rigs/local-web-rig/profiles/library/includes/eslint/mixins/packlets.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-web-rig/profiles/default/includes/eslint/mixins/packlets'] +}; diff --git a/rigs/local-web-rig/profiles/library/includes/eslint/mixins/react.js b/rigs/local-web-rig/profiles/library/includes/eslint/mixins/react.js new file mode 100644 index 00000000000..1ebbea88ff4 --- /dev/null +++ b/rigs/local-web-rig/profiles/library/includes/eslint/mixins/react.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-web-rig/profiles/default/includes/eslint/mixins/react'] +}; diff --git a/rigs/local-web-rig/profiles/library/includes/eslint/mixins/todoc.js b/rigs/local-web-rig/profiles/library/includes/eslint/mixins/todoc.js new file mode 100644 index 00000000000..baeaac3cd3b --- /dev/null +++ b/rigs/local-web-rig/profiles/library/includes/eslint/mixins/todoc.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-web-rig/profiles/default/includes/eslint/mixins/todoc'] +}; diff --git a/rigs/local-web-rig/profiles/library/includes/eslint/patch/custom-config-package-names.js b/rigs/local-web-rig/profiles/library/includes/eslint/patch/custom-config-package-names.js new file mode 100644 index 00000000000..a237a04e48f --- /dev/null +++ b/rigs/local-web-rig/profiles/library/includes/eslint/patch/custom-config-package-names.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/heft-web-rig/profiles/default/includes/eslint/patch/custom-config-package-names'); diff --git a/rigs/local-web-rig/profiles/library/includes/eslint/patch/modern-module-resolution.js b/rigs/local-web-rig/profiles/library/includes/eslint/patch/modern-module-resolution.js new file mode 100644 index 00000000000..d34dc95fc19 --- /dev/null +++ b/rigs/local-web-rig/profiles/library/includes/eslint/patch/modern-module-resolution.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +require('@rushstack/heft-web-rig/profiles/default/includes/eslint/patch/modern-module-resolution'); diff --git a/rigs/local-web-rig/profiles/library/includes/eslint/profile/web-app.js b/rigs/local-web-rig/profiles/library/includes/eslint/profile/web-app.js new file mode 100644 index 00000000000..778b25a02f5 --- /dev/null +++ b/rigs/local-web-rig/profiles/library/includes/eslint/profile/web-app.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/heft-web-rig/profiles/library/includes/eslint/profile/web-app'] +}; From bb2b7db487ae7a5392c58d5442b19f6c0c396eef Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 25 Sep 2023 16:36:40 -0700 Subject: [PATCH 05/11] Rush change --- ...-danade-EslintResolverTweaks2_2023-09-25-23-36.json | 10 ++++++++++ ...-danade-EslintResolverTweaks2_2023-09-25-23-36.json | 10 ++++++++++ ...-danade-EslintResolverTweaks2_2023-09-25-23-36.json | 10 ++++++++++ ...-danade-EslintResolverTweaks2_2023-09-25-23-36.json | 10 ++++++++++ 4 files changed, 40 insertions(+) create mode 100644 common/changes/@rushstack/eslint-config/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json create mode 100644 common/changes/@rushstack/eslint-patch/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json create mode 100644 common/changes/@rushstack/heft-node-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json create mode 100644 common/changes/@rushstack/heft-web-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json diff --git a/common/changes/@rushstack/eslint-config/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json b/common/changes/@rushstack/eslint-config/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json new file mode 100644 index 00000000000..2852448fe04 --- /dev/null +++ b/common/changes/@rushstack/eslint-config/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/eslint-config", + "comment": "Adds an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix", + "type": "minor" + } + ], + "packageName": "@rushstack/eslint-config" +} \ No newline at end of file diff --git a/common/changes/@rushstack/eslint-patch/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json b/common/changes/@rushstack/eslint-patch/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json new file mode 100644 index 00000000000..89a160af8bb --- /dev/null +++ b/common/changes/@rushstack/eslint-patch/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/eslint-patch", + "comment": "Adds an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix", + "type": "minor" + } + ], + "packageName": "@rushstack/eslint-patch" +} \ No newline at end of file diff --git a/common/changes/@rushstack/heft-node-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json b/common/changes/@rushstack/heft-node-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json new file mode 100644 index 00000000000..89c27565361 --- /dev/null +++ b/common/changes/@rushstack/heft-node-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/heft-node-rig", + "comment": "Adds an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix. This change also includes the ESLint configurations sourced from \"@rushstack/eslint-config\"", + "type": "minor" + } + ], + "packageName": "@rushstack/heft-node-rig" +} \ No newline at end of file diff --git a/common/changes/@rushstack/heft-web-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json b/common/changes/@rushstack/heft-web-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json new file mode 100644 index 00000000000..38222140e6e --- /dev/null +++ b/common/changes/@rushstack/heft-web-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/heft-web-rig", + "comment": "Adds an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix. This chang", + "type": "minor" + } + ], + "packageName": "@rushstack/heft-web-rig" +} \ No newline at end of file From 119eb2b24b6cefdfaa2e7e2f582ac9cfffd4c5aa Mon Sep 17 00:00:00 2001 From: Daniel <3473356+D4N14L@users.noreply.github.com> Date: Mon, 25 Sep 2023 16:56:58 -0700 Subject: [PATCH 06/11] Apply suggestions from code review Co-authored-by: Ian Clanton-Thuon --- ...ade-EslintResolverTweaks2_2023-09-25-23-36.json | 2 +- ...ade-EslintResolverTweaks2_2023-09-25-23-36.json | 2 +- ...ade-EslintResolverTweaks2_2023-09-25-23-36.json | 2 +- ...ade-EslintResolverTweaks2_2023-09-25-23-36.json | 2 +- eslint/eslint-patch/src/_patch-base.ts | 14 +++++++------- .../eslint-patch/src/modern-module-resolution.ts | 1 + 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/common/changes/@rushstack/eslint-config/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json b/common/changes/@rushstack/eslint-config/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json index 2852448fe04..03de21cff45 100644 --- a/common/changes/@rushstack/eslint-config/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json +++ b/common/changes/@rushstack/eslint-config/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json @@ -2,7 +2,7 @@ "changes": [ { "packageName": "@rushstack/eslint-config", - "comment": "Adds an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix", + "comment": "Add an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix", "type": "minor" } ], diff --git a/common/changes/@rushstack/eslint-patch/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json b/common/changes/@rushstack/eslint-patch/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json index 89a160af8bb..890044c31e4 100644 --- a/common/changes/@rushstack/eslint-patch/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json +++ b/common/changes/@rushstack/eslint-patch/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json @@ -2,7 +2,7 @@ "changes": [ { "packageName": "@rushstack/eslint-patch", - "comment": "Adds an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix", + "comment": "Add an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix", "type": "minor" } ], diff --git a/common/changes/@rushstack/heft-node-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json b/common/changes/@rushstack/heft-node-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json index 89c27565361..4e93a3e8d46 100644 --- a/common/changes/@rushstack/heft-node-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json +++ b/common/changes/@rushstack/heft-node-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json @@ -2,7 +2,7 @@ "changes": [ { "packageName": "@rushstack/heft-node-rig", - "comment": "Adds an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix. This change also includes the ESLint configurations sourced from \"@rushstack/eslint-config\"", + "comment": "Add an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix. This change also includes the ESLint configurations sourced from \"@rushstack/eslint-config\"", "type": "minor" } ], diff --git a/common/changes/@rushstack/heft-web-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json b/common/changes/@rushstack/heft-web-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json index 38222140e6e..62a115a6174 100644 --- a/common/changes/@rushstack/heft-web-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json +++ b/common/changes/@rushstack/heft-web-rig/user-danade-EslintResolverTweaks2_2023-09-25-23-36.json @@ -2,7 +2,7 @@ "changes": [ { "packageName": "@rushstack/heft-web-rig", - "comment": "Adds an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix. This chang", + "comment": "Add an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix. This change also includes the ESLint configurations sourced from \"@rushstack/eslint-config\"", "type": "minor" } ], diff --git a/eslint/eslint-patch/src/_patch-base.ts b/eslint/eslint-patch/src/_patch-base.ts index b2b533bc14e..12792ee016b 100644 --- a/eslint/eslint-patch/src/_patch-base.ts +++ b/eslint/eslint-patch/src/_patch-base.ts @@ -108,8 +108,8 @@ if (!eslintFolder) { ); if (resolvedConfigArrayFactoryPath === currentModule.filename) { configArrayFactoryPath = resolvedConfigArrayFactoryPath; - moduleResolverPath = path.join(eslintrcFolder, 'lib/shared/relative-module-resolver'); - namingPath = path.join(eslintrcFolder, 'lib/shared/naming'); + moduleResolverPath = `${eslintrcFolder}/lib/shared/relative-module-resolver`; + namingPath = `${eslintrcFolder}/lib/shared/naming`; } } catch (ex: unknown) { // Module resolution failures are expected, as we're walking @@ -157,9 +157,9 @@ if (!eslintFolder) { // .../eslint/lib/cli-engine/config-array-factory.js if (/[\\/]eslint[\\/]lib[\\/]cli-engine[\\/]config-array-factory\.js$/i.test(currentModule.filename)) { eslintFolder = path.join(path.dirname(currentModule.filename), '../..'); - configArrayFactoryPath = path.join(eslintFolder, 'lib/cli-engine/config-array-factory'); - moduleResolverPath = path.join(eslintFolder, 'lib/shared/relative-module-resolver'); - namingPath = path.join(eslintFolder, 'lib/shared/naming'); + configArrayFactoryPath = `${eslintFolder}/lib/cli-engine/config-array-factory`; + moduleResolverPath = `${eslintFolder}/lib/shared/relative-module-resolver`; + namingPath = `${eslintFolder}/lib/shared/naming`; break; } @@ -176,10 +176,10 @@ if (!eslintFolder) { } // Detect the ESLint package version -const eslintPackageJson = fs.readFileSync(path.join(eslintFolder, 'package.json')).toString(); +const eslintPackageJson = fs.readFileSync(`${eslintFolder}/package.json`).toString(); const eslintPackageObject = JSON.parse(eslintPackageJson); const eslintPackageVersion = eslintPackageObject.version; -const versionMatch = /^([0-9]+)\./.exec(eslintPackageVersion); // parse the SemVer MAJOR part +const versionMatch = parseInt(eslintPackageVersion, 10); if (!versionMatch) { throw new Error('Unable to parse ESLint version: ' + eslintPackageVersion); } diff --git a/eslint/eslint-patch/src/modern-module-resolution.ts b/eslint/eslint-patch/src/modern-module-resolution.ts index f1c3d8b9905..e411aa71574 100644 --- a/eslint/eslint-patch/src/modern-module-resolution.ts +++ b/eslint/eslint-patch/src/modern-module-resolution.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. + // This is a workaround for https://github.com/eslint/eslint/issues/3458 // // To correct how ESLint searches for plugin packages, add this line to the top of your project's .eslintrc.js file: From 6103a23b83909ead47f68031e09da2d90d62248a Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 25 Sep 2023 17:05:20 -0700 Subject: [PATCH 07/11] PR feedback --- eslint/eslint-patch/src/_patch-base.ts | 14 ++++++++------ .../eslint-patch/src/modern-module-resolution.ts | 6 +++--- .../includes/eslint/profile/node-trusted-tool.js | 6 ++++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/eslint/eslint-patch/src/_patch-base.ts b/eslint/eslint-patch/src/_patch-base.ts index 12792ee016b..28148e69f3f 100644 --- a/eslint/eslint-patch/src/_patch-base.ts +++ b/eslint/eslint-patch/src/_patch-base.ts @@ -179,14 +179,16 @@ if (!eslintFolder) { const eslintPackageJson = fs.readFileSync(`${eslintFolder}/package.json`).toString(); const eslintPackageObject = JSON.parse(eslintPackageJson); const eslintPackageVersion = eslintPackageObject.version; -const versionMatch = parseInt(eslintPackageVersion, 10); -if (!versionMatch) { - throw new Error('Unable to parse ESLint version: ' + eslintPackageVersion); +let eslintMajorVersion: number; +try { + eslintMajorVersion = parseInt(eslintPackageVersion, 10); +} catch (e) { + throw new Error(`Unable to parse ESLint version "${eslintPackageVersion}": ${e}`); } -const eslintMajorVersion = Number(versionMatch[1]); + 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.' + + 'The ESLint patch script has only been tested with ESLint version 6.x, 7.x, and 8.x.' + ` (Your version: ${eslintPackageVersion})\n` + 'Consider reporting a GitHub issue:\n' + 'https://github.com/microsoft/rushstack/issues' @@ -214,6 +216,6 @@ export { ConfigArrayFactory, ModuleResolver, Naming, - eslintMajorVersion as EslintMajorVersion, + eslintMajorVersion as ESLINT_MAJOR_VERSION, isModuleResolutionError }; diff --git a/eslint/eslint-patch/src/modern-module-resolution.ts b/eslint/eslint-patch/src/modern-module-resolution.ts index e411aa71574..17a088b65f2 100644 --- a/eslint/eslint-patch/src/modern-module-resolution.ts +++ b/eslint/eslint-patch/src/modern-module-resolution.ts @@ -9,10 +9,10 @@ // import { - EslintMajorVersion, ConfigArrayFactory, ModuleResolver, - isModuleResolutionError + isModuleResolutionError, + ESLINT_MAJOR_VERSION } from './_patch-base'; // error: "The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''" @@ -23,7 +23,7 @@ if (!ConfigArrayFactory.__loadPluginPatched) { ConfigArrayFactory.__loadPluginPatched = true; const originalLoadPlugin = ConfigArrayFactory.prototype._loadPlugin; - if (EslintMajorVersion === 6) { + if (ESLINT_MAJOR_VERSION === 6) { // ESLint 6.x // https://github.com/eslint/eslint/blob/9738f8cc864d769988ccf42bb70f524444df1349/lib/cli-engine/config-array-factory.js#L915 ConfigArrayFactory.prototype._loadPlugin = function ( diff --git a/rigs/heft-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool.js b/rigs/heft-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool.js index e69de29bb2d..e5b291a3b08 100644 --- a/rigs/heft-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool.js +++ b/rigs/heft-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +module.exports = { + extends: ['@rushstack/eslint-config/profile/node-trusted-tool'] +}; From af3dc781e53d7b2b8e0ea8247ec773c424f38269 Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 25 Sep 2023 17:10:30 -0700 Subject: [PATCH 08/11] Fix version check --- eslint/eslint-patch/src/_patch-base.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/eslint/eslint-patch/src/_patch-base.ts b/eslint/eslint-patch/src/_patch-base.ts index 28148e69f3f..91335edb5cc 100644 --- a/eslint/eslint-patch/src/_patch-base.ts +++ b/eslint/eslint-patch/src/_patch-base.ts @@ -176,14 +176,15 @@ if (!eslintFolder) { } // Detect the ESLint package version -const eslintPackageJson = fs.readFileSync(`${eslintFolder}/package.json`).toString(); +const eslintPackageJsonPath: string = `${eslintFolder}/package.json`; +const eslintPackageJson = fs.readFileSync(eslintPackageJsonPath).toString(); const eslintPackageObject = JSON.parse(eslintPackageJson); const eslintPackageVersion = eslintPackageObject.version; -let eslintMajorVersion: number; -try { - eslintMajorVersion = parseInt(eslintPackageVersion, 10); -} catch (e) { - throw new Error(`Unable to parse ESLint version "${eslintPackageVersion}": ${e}`); +const eslintMajorVersion: number = parseInt(eslintPackageVersion, 10); +if (isNaN(eslintMajorVersion)) { + throw new Error( + `Unable to parse ESLint version "${eslintPackageVersion}" in file "${eslintPackageJsonPath}"` + ); } if (!(eslintMajorVersion >= 6 && eslintMajorVersion <= 8)) { From 995ab7117209f25014ae950f451335f643cfaa85 Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 25 Sep 2023 17:36:20 -0700 Subject: [PATCH 09/11] Add eslint 8 test --- build-tests/eslint-8-test/.eslintrc.js | 25 ++++++++++++++++++++ build-tests/eslint-8-test/README.md | 6 +++++ build-tests/eslint-8-test/config/rig.json | 7 ++++++ build-tests/eslint-8-test/package.json | 21 +++++++++++++++++ build-tests/eslint-8-test/src/index.ts | 7 ++++++ build-tests/eslint-8-test/tsconfig.json | 24 +++++++++++++++++++ common/config/rush/pnpm-lock.yaml | 28 +++++++++++++++++++++-- common/config/rush/repo-state.json | 2 +- rush.json | 6 +++++ 9 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 build-tests/eslint-8-test/.eslintrc.js create mode 100644 build-tests/eslint-8-test/README.md create mode 100644 build-tests/eslint-8-test/config/rig.json create mode 100644 build-tests/eslint-8-test/package.json create mode 100644 build-tests/eslint-8-test/src/index.ts create mode 100644 build-tests/eslint-8-test/tsconfig.json diff --git a/build-tests/eslint-8-test/.eslintrc.js b/build-tests/eslint-8-test/.eslintrc.js new file mode 100644 index 00000000000..9a6c31a97f4 --- /dev/null +++ b/build-tests/eslint-8-test/.eslintrc.js @@ -0,0 +1,25 @@ +// This is a workaround for https://github.com/eslint/eslint/issues/3458 +require('@rushstack/eslint-config/patch/modern-module-resolution'); + +module.exports = { + extends: [ + '@rushstack/eslint-config/profile/node-trusted-tool', + '@rushstack/eslint-config/mixins/friendly-locals' + ], + parserOptions: { tsconfigRootDir: __dirname }, + + overrides: [ + /** + * Override the parser from @rushstack/eslint-config. Since the config is coming + * from the workspace instead of the external NPM package, the versions of ESLint + * and TypeScript that the config consumes will be resolved from the devDependencies + * of the config instead of from the eslint-7-test package. Overriding the parser + * ensures that the these dependencies come from the eslint-7-test package. See: + * https://github.com/microsoft/rushstack/issues/3021 + */ + { + files: ['*.ts', '*.tsx'], + parser: '@typescript-eslint/parser' + } + ] +}; diff --git a/build-tests/eslint-8-test/README.md b/build-tests/eslint-8-test/README.md new file mode 100644 index 00000000000..f4d85f1fdb3 --- /dev/null +++ b/build-tests/eslint-8-test/README.md @@ -0,0 +1,6 @@ +# eslint-7-test + +This project folder is one of the **build-tests** for the Rushstack [ESLint configuration](https://www.npmjs.com/package/@rushstack/eslint-config) (and by extension, the [ESLint plugin](https://www.npmjs.com/package/@rushstack/eslint-plugin)) +package. This project builds using ESLint v7 and contains a simple index file to ensure that the build runs ESLint successfully against source code. + +Please see the [ESLint Heft task documentation](https://rushstack.io/pages/heft_tasks/eslint/) for documentation and tutorials. diff --git a/build-tests/eslint-8-test/config/rig.json b/build-tests/eslint-8-test/config/rig.json new file mode 100644 index 00000000000..165ffb001f5 --- /dev/null +++ b/build-tests/eslint-8-test/config/rig.json @@ -0,0 +1,7 @@ +{ + // The "rig.json" file directs tools to look for their config files in an external package. + // Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package + "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json", + + "rigPackageName": "local-node-rig" +} diff --git a/build-tests/eslint-8-test/package.json b/build-tests/eslint-8-test/package.json new file mode 100644 index 00000000000..001bccc7169 --- /dev/null +++ b/build-tests/eslint-8-test/package.json @@ -0,0 +1,21 @@ +{ + "name": "eslint-8-test", + "description": "This project contains a build test to validate ESLint 8 compatibility with the latest version of @rushstack/eslint-config (and by extension, the ESLint plugin)", + "version": "1.0.0", + "private": true, + "main": "lib/index.js", + "license": "MIT", + "scripts": { + "build": "heft build --clean", + "_phase:build": "heft run --only build -- --clean" + }, + "devDependencies": { + "@rushstack/eslint-config": "workspace:*", + "@rushstack/heft": "workspace:*", + "local-node-rig": "workspace:*", + "@types/node": "18.17.15", + "@typescript-eslint/parser": "~5.59.2", + "eslint": "~8.7.0", + "typescript": "~5.0.4" + } +} diff --git a/build-tests/eslint-8-test/src/index.ts b/build-tests/eslint-8-test/src/index.ts new file mode 100644 index 00000000000..428f8caba4f --- /dev/null +++ b/build-tests/eslint-8-test/src/index.ts @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +export class Foo { + private _bar: string = 'bar'; + public baz: string = this._bar; +} diff --git a/build-tests/eslint-8-test/tsconfig.json b/build-tests/eslint-8-test/tsconfig.json new file mode 100644 index 00000000000..8a46ac2445e --- /dev/null +++ b/build-tests/eslint-8-test/tsconfig.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json.schemastore.org/tsconfig", + + "compilerOptions": { + "outDir": "lib", + "rootDir": "src", + + "forceConsistentCasingInFileNames": true, + "declaration": true, + "sourceMap": true, + "declarationMap": true, + "inlineSources": true, + "experimentalDecorators": true, + "strictNullChecks": true, + "noUnusedLocals": true, + + "module": "esnext", + "moduleResolution": "node", + "target": "es5", + "lib": ["es5"] + }, + "include": ["src/**/*.ts", "src/**/*.tsx"], + "exclude": ["node_modules", "lib"] +} diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index b67dbf75f50..d1887333f3b 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1072,6 +1072,30 @@ importers: specifier: ~5.0.4 version: 5.0.4 + ../../build-tests/eslint-8-test: + devDependencies: + '@rushstack/eslint-config': + specifier: workspace:* + version: link:../../eslint/eslint-config + '@rushstack/heft': + specifier: workspace:* + version: link:../../apps/heft + '@types/node': + specifier: 18.17.15 + version: 18.17.15 + '@typescript-eslint/parser': + specifier: ~5.59.2 + version: 5.59.11(eslint@8.7.0)(typescript@5.0.4) + eslint: + specifier: ~8.7.0 + version: 8.7.0 + local-node-rig: + specifier: workspace:* + version: link:../../rigs/local-node-rig + typescript: + specifier: ~5.0.4 + version: 5.0.4 + ../../build-tests/hashed-folder-copy-plugin-webpack4-test: devDependencies: '@rushstack/hashed-folder-copy-plugin': @@ -16029,7 +16053,7 @@ packages: json-stable-stringify-without-jsonify: 1.0.1 levn: 0.4.1 lodash.merge: 4.6.2 - minimatch: 3.1.2 + minimatch: 3.0.8 natural-compare: 1.4.0 optionator: 0.9.3 regexpp: 3.2.0 @@ -25697,7 +25721,7 @@ packages: /wide-align@1.1.5: resolution: {integrity: sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==} dependencies: - string-width: 1.0.2 + string-width: 4.2.3 dev: true /widest-line@3.1.0: diff --git a/common/config/rush/repo-state.json b/common/config/rush/repo-state.json index 1fe5517b54c..b7ec88a0999 100644 --- a/common/config/rush/repo-state.json +++ b/common/config/rush/repo-state.json @@ -1,5 +1,5 @@ // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. { - "pnpmShrinkwrapHash": "92561e650a0b5a0ffde5b5dcc107d597c755b413", + "pnpmShrinkwrapHash": "00aeb975643cac9bd71b0f5af110395618d2eedf", "preferredVersionsHash": "1926a5b12ac8f4ab41e76503a0d1d0dccc9c0e06" } diff --git a/rush.json b/rush.json index 945abff5e8a..600dee85570 100644 --- a/rush.json +++ b/rush.json @@ -536,6 +536,12 @@ "reviewCategory": "tests", "shouldPublish": false }, + { + "packageName": "eslint-8-test", + "projectFolder": "build-tests/eslint-8-test", + "reviewCategory": "tests", + "shouldPublish": false + }, { "packageName": "package-extractor-test-01", "projectFolder": "build-tests/package-extractor-test-01", From 9174b9ebff6837066deb9432d1b2732a625c4b41 Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 25 Sep 2023 17:36:37 -0700 Subject: [PATCH 10/11] Fix logic bug in eslint 7 --- eslint/eslint-patch/src/_patch-base.ts | 40 ++++++++++++++------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/eslint/eslint-patch/src/_patch-base.ts b/eslint/eslint-patch/src/_patch-base.ts index 91335edb5cc..770433c441a 100644 --- a/eslint/eslint-patch/src/_patch-base.ts +++ b/eslint/eslint-patch/src/_patch-base.ts @@ -35,26 +35,28 @@ let eslintFolder: string | undefined = undefined; // Probe for the ESLint >=8.0.0 layout: for (let currentModule = module; ; ) { - if (!eslintrcBundlePath && currentModule.filename.endsWith('eslintrc.cjs')) { - // For ESLint >=8.0.0, all @eslint/eslintrc code is bundled at this path: - // .../@eslint/eslintrc/dist/eslintrc.cjs - try { - const eslintrcFolder = path.dirname( - require.resolve('@eslint/eslintrc/package.json', { paths: [currentModule.path] }) - ); + if (!eslintrcBundlePath) { + if (currentModule.filename.endsWith('eslintrc.cjs')) { + // For ESLint >=8.0.0, all @eslint/eslintrc code is bundled at this path: + // .../@eslint/eslintrc/dist/eslintrc.cjs + try { + const eslintrcFolder = path.dirname( + require.resolve('@eslint/eslintrc/package.json', { paths: [currentModule.path] }) + ); - // Make sure we actually resolved the module in our call path - // and not some other spurious dependency. - const resolvedEslintrcBundlePath: string = path.join(eslintrcFolder, 'dist/eslintrc.cjs'); - if (resolvedEslintrcBundlePath === currentModule.filename) { - eslintrcBundlePath = resolvedEslintrcBundlePath; - } - } catch (ex: unknown) { - // Module resolution failures are expected, as we're walking - // up our require stack to look for eslint. All other errors - // are rethrown. - if (!isModuleResolutionError(ex)) { - throw ex; + // Make sure we actually resolved the module in our call path + // and not some other spurious dependency. + const resolvedEslintrcBundlePath: string = path.join(eslintrcFolder, 'dist/eslintrc.cjs'); + if (resolvedEslintrcBundlePath === currentModule.filename) { + eslintrcBundlePath = resolvedEslintrcBundlePath; + } + } catch (ex: unknown) { + // Module resolution failures are expected, as we're walking + // up our require stack to look for eslint. All other errors + // are rethrown. + if (!isModuleResolutionError(ex)) { + throw ex; + } } } } else { From b9ec0f15e577b4e5f822358f220543414cd47277 Mon Sep 17 00:00:00 2001 From: Daniel Nadeau <3473356+D4N14L@users.noreply.github.com> Date: Mon, 25 Sep 2023 17:55:18 -0700 Subject: [PATCH 11/11] Update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index eaaa8c48440..7255137640a 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ These GitHub repositories provide supplementary resources for Rush Stack: | [/build-tests/api-extractor-test-03](./build-tests/api-extractor-test-03/) | Building this project is a regression test for api-extractor | | [/build-tests/api-extractor-test-04](./build-tests/api-extractor-test-04/) | Building this project is a regression test for api-extractor | | [/build-tests/eslint-7-test](./build-tests/eslint-7-test/) | This project contains a build test to validate ESLint 7 compatibility with the latest version of @rushstack/eslint-config (and by extension, the ESLint plugin) | +| [/build-tests/eslint-8-test](./build-tests/eslint-8-test/) | This project contains a build test to validate ESLint 8 compatibility with the latest version of @rushstack/eslint-config (and by extension, the ESLint plugin) | | [/build-tests/hashed-folder-copy-plugin-webpack4-test](./build-tests/hashed-folder-copy-plugin-webpack4-test/) | Building this project exercises @rushstack/hashed-folder-copy-plugin with Webpack 4. | | [/build-tests/hashed-folder-copy-plugin-webpack5-test](./build-tests/hashed-folder-copy-plugin-webpack5-test/) | Building this project exercises @rushstack/hashed-folder-copy-plugin with Webpack 5. NOTE - THIS TEST IS CURRENTLY EXPECTED TO BE BROKEN | | [/build-tests/heft-copy-files-test](./build-tests/heft-copy-files-test/) | Building this project tests copying files with Heft |