source: frontend/node_modules/@rushstack/eslint-patch/lib-esm/custom-config-package-names.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

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