source: frontend/node_modules/@rushstack/eslint-patch/lib-esm/modern-module-resolution.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: 3.2 KB
RevLine 
[9af201e]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 https://github.com/eslint/eslint/issues/3458
4//
5// To correct how ESLint searches for plugin packages, add this line to the top of your project's .eslintrc.js file:
6//
7// require("@rushstack/eslint-patch/modern-module-resolution");
8//
9import { configArrayFactory, ModuleResolver, isModuleResolutionError, ESLINT_MAJOR_VERSION } from './_patch-base';
10// error: "The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ''"
11const isInvalidImporterPath = (ex) => (ex === null || ex === void 0 ? void 0 : ex.code) === 'ERR_INVALID_ARG_VALUE';
12if (!configArrayFactory.__loadPluginPatched) {
13 configArrayFactory.__loadPluginPatched = true;
14 // eslint-disable-next-line @typescript-eslint/typedef
15 const originalLoadPlugin = configArrayFactory.prototype._loadPlugin;
16 if (ESLINT_MAJOR_VERSION === 6) {
17 // ESLint 6.x
18 // https://github.com/eslint/eslint/blob/9738f8cc864d769988ccf42bb70f524444df1349/lib/cli-engine/config-array-factory.js#L915
19 configArrayFactory.prototype._loadPlugin = function (name, importerPath, importerName) {
20 const originalResolve = ModuleResolver.resolve;
21 try {
22 ModuleResolver.resolve = function (moduleName, relativeToPath) {
23 try {
24 // resolve using importerPath instead of relativeToPath
25 return originalResolve.call(this, moduleName, importerPath);
26 }
27 catch (e) {
28 if (isModuleResolutionError(e) || isInvalidImporterPath(e)) {
29 return originalResolve.call(this, moduleName, relativeToPath);
30 }
31 throw e;
32 }
33 };
34 return originalLoadPlugin.apply(this, arguments);
35 }
36 finally {
37 ModuleResolver.resolve = originalResolve;
38 }
39 };
40 }
41 else {
42 // ESLint 7.x || 8.x
43 // https://github.com/eslint/eslintrc/blob/242d569020dfe4f561e4503787b99ec016337457/lib/config-array-factory.js#L1023
44 configArrayFactory.prototype._loadPlugin = function (name, ctx) {
45 const originalResolve = ModuleResolver.resolve;
46 try {
47 ModuleResolver.resolve = function (moduleName, relativeToPath) {
48 try {
49 // resolve using ctx.filePath instead of relativeToPath
50 return originalResolve.call(this, moduleName, ctx.filePath);
51 }
52 catch (e) {
53 if (isModuleResolutionError(e) || isInvalidImporterPath(e)) {
54 return originalResolve.call(this, moduleName, relativeToPath);
55 }
56 throw e;
57 }
58 };
59 return originalLoadPlugin.apply(this, arguments);
60 }
61 finally {
62 ModuleResolver.resolve = originalResolve;
63 }
64 };
65 }
66}
67//# sourceMappingURL=modern-module-resolution.js.map
Note: See TracBrowser for help on using the repository browser.