| 1 | "use strict";
|
|---|
| 2 | // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|---|
| 3 | // See LICENSE in the project root for license information.
|
|---|
| 4 | Object.defineProperty(exports, "__esModule", { value: true });
|
|---|
| 5 | // This is a workaround for ESLint's requirement to consume shareable configurations from package names prefixed
|
|---|
| 6 | // with "eslint-config".
|
|---|
| 7 | //
|
|---|
| 8 | // To remove this requirement, add this line to the top of your project's .eslintrc.js file:
|
|---|
| 9 | //
|
|---|
| 10 | // require("@rushstack/eslint-patch/custom-config-package-names");
|
|---|
| 11 | //
|
|---|
| 12 | const _patch_base_1 = require("./_patch-base");
|
|---|
| 13 | if (!_patch_base_1.configArrayFactory.__loadExtendedShareableConfigPatched) {
|
|---|
| 14 | _patch_base_1.configArrayFactory.__loadExtendedShareableConfigPatched = true;
|
|---|
| 15 | // eslint-disable-next-line @typescript-eslint/typedef
|
|---|
| 16 | const originalLoadExtendedShareableConfig = _patch_base_1.configArrayFactory.prototype._loadExtendedShareableConfig;
|
|---|
| 17 | // Common between ESLint versions
|
|---|
| 18 | // https://github.com/eslint/eslintrc/blob/242d569020dfe4f561e4503787b99ec016337457/lib/config-array-factory.js#L910
|
|---|
| 19 | _patch_base_1.configArrayFactory.prototype._loadExtendedShareableConfig = function (extendName) {
|
|---|
| 20 | const originalResolve = _patch_base_1.ModuleResolver.resolve;
|
|---|
| 21 | try {
|
|---|
| 22 | _patch_base_1.ModuleResolver.resolve = function (moduleName, relativeToPath) {
|
|---|
| 23 | try {
|
|---|
| 24 | return originalResolve.call(this, moduleName, relativeToPath);
|
|---|
| 25 | }
|
|---|
| 26 | catch (e) {
|
|---|
| 27 | // Only change the name we resolve if we cannot find the normalized module, since it is
|
|---|
| 28 | // valid to rely on the normalized package name. Use the originally provided module path
|
|---|
| 29 | // instead of the normalized module path.
|
|---|
| 30 | if ((e === null || e === void 0 ? void 0 : e.code) === 'MODULE_NOT_FOUND' &&
|
|---|
| 31 | moduleName !== extendName &&
|
|---|
| 32 | moduleName === _patch_base_1.Naming.normalizePackageName(extendName, 'eslint-config')) {
|
|---|
| 33 | return originalResolve.call(this, extendName, relativeToPath);
|
|---|
| 34 | }
|
|---|
| 35 | else {
|
|---|
| 36 | throw e;
|
|---|
| 37 | }
|
|---|
| 38 | }
|
|---|
| 39 | };
|
|---|
| 40 | return originalLoadExtendedShareableConfig.apply(this, arguments);
|
|---|
| 41 | }
|
|---|
| 42 | finally {
|
|---|
| 43 | _patch_base_1.ModuleResolver.resolve = originalResolve;
|
|---|
| 44 | }
|
|---|
| 45 | };
|
|---|
| 46 | }
|
|---|
| 47 | //# sourceMappingURL=custom-config-package-names.js.map |
|---|