File size: 2,369 Bytes
e9d4f6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;
    // eslint-disable-next-line @typescript-eslint/typedef
    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) {
        const originalResolve = ModuleResolver.resolve;
        try {
            ModuleResolver.resolve = function (moduleName, relativeToPath) {
                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 === null || e === void 0 ? void 0 : e.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;
        }
    };
}
//# sourceMappingURL=custom-config-package-names.js.map