@ms-cloudpack/eslint-plugin 0.6.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -52
- package/package.json +12 -21
- package/lib/configs/classic.d.ts +0 -9
- package/lib/configs/classic.d.ts.map +0 -1
- package/lib/configs/classic.js +0 -32
- package/lib/configs/classic.js.map +0 -1
- package/lib/configs/flat.d.ts +0 -4
- package/lib/configs/flat.d.ts.map +0 -1
- package/lib/configs/flat.js +0 -24
- package/lib/configs/flat.js.map +0 -1
- package/lib/flat.d.mts +0 -12
- package/lib/flat.d.mts.map +0 -1
- package/lib/flat.mjs +0 -8
- package/lib/flat.mjs.map +0 -1
- package/lib/index.d.ts +0 -13
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -10
- package/lib/index.js.map +0 -1
- package/lib/plugin.d.ts +0 -6
- package/lib/plugin.d.ts.map +0 -1
- package/lib/plugin.js +0 -19
- package/lib/plugin.js.map +0 -1
- package/lib/rules/no-test-exports.d.ts +0 -18
- package/lib/rules/no-test-exports.d.ts.map +0 -1
- package/lib/rules/no-test-exports.js +0 -133
- package/lib/rules/no-test-exports.js.map +0 -1
- package/lib/rules/no-unsupported-imports.d.ts +0 -14
- package/lib/rules/no-unsupported-imports.d.ts.map +0 -1
- package/lib/rules/no-unsupported-imports.js +0 -174
- package/lib/rules/no-unsupported-imports.js.map +0 -1
- package/lib/utils/PackageJson.d.ts +0 -43
- package/lib/utils/PackageJson.d.ts.map +0 -1
- package/lib/utils/PackageJson.js +0 -4
- package/lib/utils/PackageJson.js.map +0 -1
- package/lib/utils/createRule.d.ts +0 -41
- package/lib/utils/createRule.d.ts.map +0 -1
- package/lib/utils/createRule.js +0 -32
- package/lib/utils/createRule.js.map +0 -1
- package/lib/utils/getImportPathLiteralNode.d.ts +0 -11
- package/lib/utils/getImportPathLiteralNode.d.ts.map +0 -1
- package/lib/utils/getImportPathLiteralNode.js +0 -47
- package/lib/utils/getImportPathLiteralNode.js.map +0 -1
- package/lib/utils/getPackageInfo.d.ts +0 -16
- package/lib/utils/getPackageInfo.d.ts.map +0 -1
- package/lib/utils/getPackageInfo.js +0 -60
- package/lib/utils/getPackageInfo.js.map +0 -1
- package/lib/utils/getRegexpsFromStrings.d.ts +0 -6
- package/lib/utils/getRegexpsFromStrings.d.ts.map +0 -1
- package/lib/utils/getRegexpsFromStrings.js +0 -11
- package/lib/utils/getRegexpsFromStrings.js.map +0 -1
- package/lib/utils/testExports/extractIdentifiersFromExport.d.ts +0 -6
- package/lib/utils/testExports/extractIdentifiersFromExport.d.ts.map +0 -1
- package/lib/utils/testExports/extractIdentifiersFromExport.js +0 -57
- package/lib/utils/testExports/extractIdentifiersFromExport.js.map +0 -1
- package/lib/utils/testExports/isIncludedIndexFile.d.ts +0 -10
- package/lib/utils/testExports/isIncludedIndexFile.d.ts.map +0 -1
- package/lib/utils/testExports/isIncludedIndexFile.js +0 -27
- package/lib/utils/testExports/isIncludedIndexFile.js.map +0 -1
- package/lib/utils/unsupportedImports/parseImportIfRelevant.d.ts +0 -19
- package/lib/utils/unsupportedImports/parseImportIfRelevant.d.ts.map +0 -1
- package/lib/utils/unsupportedImports/parseImportIfRelevant.js +0 -39
- package/lib/utils/unsupportedImports/parseImportIfRelevant.js.map +0 -1
- package/lib/utils/unsupportedImports/pathSatisfiesAnyExport.d.ts +0 -8
- package/lib/utils/unsupportedImports/pathSatisfiesAnyExport.d.ts.map +0 -1
- package/lib/utils/unsupportedImports/pathSatisfiesAnyExport.js +0 -37
- package/lib/utils/unsupportedImports/pathSatisfiesAnyExport.js.map +0 -1
- package/lib/utils/unsupportedImports/resolvePackageRoot.d.ts +0 -7
- package/lib/utils/unsupportedImports/resolvePackageRoot.d.ts.map +0 -1
- package/lib/utils/unsupportedImports/resolvePackageRoot.js +0 -48
- package/lib/utils/unsupportedImports/resolvePackageRoot.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":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AAC;aAAM,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YAC3C,mEAAmE;YACnE,2CAA2C;YAC3C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;gBACpC,IAAI,IAAI,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;oBAChC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACjB,CAAC;qBAAM,IAAI,IAAI,EAAE,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAC/E,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,oEAAoE;YACpE,yDAAyD;YACzD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;gBACtC,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBACjE,0FAA0F;oBAC1F,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,CAAC;qBAAM,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAC9E,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\n\n/**\n * Extract identifiers from an export declaration.\n */\nexport function extractIdentifiersFromExport(\n node: TSESTree.ExportAllDeclaration | TSESTree.ExportNamedDeclaration,\n): TSESTree.Identifier[] {\n if (node.type === 'ExportAllDeclaration') {\n // export * as foo from 'foo'\n return node.exported ? [node.exported] : [];\n }\n\n if (node.specifiers.length) {\n // export { a, b }\n // export { a, b } from 'foo'\n return node.specifiers.map((s) => s.exported).filter((s): s is TSESTree.Identifier => s.type === 'Identifier');\n }\n\n if (node.declaration && node.declaration?.type !== 'VariableDeclaration') {\n // export import foo = require('foo')\n // also class, function, type, interface...\n return node.declaration.id?.type === 'Identifier' ? [node.declaration.id] : [];\n }\n\n const ids: TSESTree.Identifier[] = [];\n const declarations = node.declaration?.declarations || [];\n\n for (const decl of declarations) {\n if (decl.id.type === 'Identifier') {\n // export const foo = 'foo'\n ids.push(decl.id);\n } else if (decl.id.type === 'ArrayPattern') {\n // Unlikely array destructuring export (ignore any nested variants)\n // export const [foo, bar] = ['foo', 'bar']\n for (const elem of decl.id.elements) {\n if (elem?.type === 'Identifier') {\n ids.push(elem);\n } else if (elem?.type === 'RestElement' && elem.argument.type === 'Identifier') {\n ids.push(elem.argument);\n }\n }\n } else {\n // Unlikely object destructuring export (ignore any nested variants)\n // export const { foo, bar } = { foo: 'foo', bar: 'bar' }\n for (const prop of decl.id.properties) {\n if (prop.type === 'Property' && prop.value.type === 'Identifier') {\n // .value instead of .key handles renaming and prevents including non-exported nested keys\n ids.push(prop.value);\n } else if (prop.type === 'RestElement' && prop.argument.type === 'Identifier') {\n ids.push(prop.argument);\n }\n }\n }\n }\n\n return ids;\n}\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks whether the given file is an index file, is not under an ignored path, and is not
|
|
3
|
-
* nested too deep in the package.
|
|
4
|
-
*/
|
|
5
|
-
export declare function isIncludedIndexFile(params: {
|
|
6
|
-
filename: string;
|
|
7
|
-
ignorePaths: RegExp[];
|
|
8
|
-
maxDepth: number;
|
|
9
|
-
}): boolean;
|
|
10
|
-
//# sourceMappingURL=isIncludedIndexFile.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isIncludedIndexFile.d.ts","sourceRoot":"","sources":["../../../src/utils/testExports/isIncludedIndexFile.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAoBlH"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isIncludedIndexFile = isIncludedIndexFile;
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const getPackageInfo_js_1 = require("../getPackageInfo.js");
|
|
6
|
-
/**
|
|
7
|
-
* Checks whether the given file is an index file, is not under an ignored path, and is not
|
|
8
|
-
* nested too deep in the package.
|
|
9
|
-
*/
|
|
10
|
-
function isIncludedIndexFile(params) {
|
|
11
|
-
const { filename, ignorePaths, maxDepth } = params;
|
|
12
|
-
// ignore non index files
|
|
13
|
-
if (!filename || !/^index\.[cm]?[jt]sx?$/.test(path.basename(filename))) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
const packageInfo = (0, getPackageInfo_js_1.getPackageInfo)(filename);
|
|
17
|
-
if (packageInfo) {
|
|
18
|
-
const relativePath = path.normalize(filename).replace(packageInfo.path, '').slice(1).replace(/\\/g, '/');
|
|
19
|
-
// Ignore index files that are too deep, or if the relative path (within the package)
|
|
20
|
-
// matches an ignore path
|
|
21
|
-
if (relativePath.split('/').length > maxDepth + 1 || ignorePaths.some((re) => re.test('./' + relativePath))) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=isIncludedIndexFile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isIncludedIndexFile.js","sourceRoot":"","sources":["../../../src/utils/testExports/isIncludedIndexFile.ts"],"names":[],"mappings":";;AAOA,kDAoBC;AA3BD,6BAA6B;AAC7B,4DAAsD;AAEtD;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,MAAqE;IACvG,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAEnD,yBAAyB;IACzB,IAAI,CAAC,QAAQ,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,WAAW,GAAG,IAAA,kCAAc,EAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAEzG,qFAAqF;QACrF,yBAAyB;QACzB,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,QAAQ,GAAG,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC;YAC5G,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import * as path from 'path';\nimport { getPackageInfo } from '../getPackageInfo.js';\n\n/**\n * Checks whether the given file is an index file, is not under an ignored path, and is not\n * nested too deep in the package.\n */\nexport function isIncludedIndexFile(params: { filename: string; ignorePaths: RegExp[]; maxDepth: number }): boolean {\n const { filename, ignorePaths, maxDepth } = params;\n\n // ignore non index files\n if (!filename || !/^index\\.[cm]?[jt]sx?$/.test(path.basename(filename))) {\n return false;\n }\n\n const packageInfo = getPackageInfo(filename);\n if (packageInfo) {\n const relativePath = path.normalize(filename).replace(packageInfo.path, '').slice(1).replace(/\\\\/g, '/');\n\n // Ignore index files that are too deep, or if the relative path (within the package)\n // matches an ignore path\n if (relativePath.split('/').length > maxDepth + 1 || ignorePaths.some((re) => re.test('./' + relativePath))) {\n return false;\n }\n }\n\n return true;\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verify that the import is relevant for the very specific purposes of the `no-unsupported-imports` rule,
|
|
3
|
-
* and if so, find the package name and sub-path.
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseImportIfRelevant(importPath: string, ignorePatterns: RegExp[]): {
|
|
6
|
-
packageName: string;
|
|
7
|
-
subPath: string;
|
|
8
|
-
} | null;
|
|
9
|
-
/**
|
|
10
|
-
* Parse a module ID which is assumed to point to an actual file in a package (no loader prefixes,
|
|
11
|
-
* relative paths, node builtins, or data URIs).
|
|
12
|
-
* @returns Package name and sub-path (if any). Sub-path does *not* include a leading `./`,
|
|
13
|
-
* e.g. `@foo/bar/baz` returns `{ packageName: '@foo/bar', subPath: 'baz' }`.
|
|
14
|
-
*/
|
|
15
|
-
export declare function parseModuleId(moduleId: string): {
|
|
16
|
-
packageName: string;
|
|
17
|
-
subPath: string;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=parseImportIfRelevant.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseImportIfRelevant.d.ts","sourceRoot":"","sources":["../../../src/utils/unsupportedImports/parseImportIfRelevant.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EAAE,GACvB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAiBjD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAOxF"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseImportIfRelevant = parseImportIfRelevant;
|
|
4
|
-
exports.parseModuleId = parseModuleId;
|
|
5
|
-
const module_1 = require("module");
|
|
6
|
-
/**
|
|
7
|
-
* Verify that the import is relevant for the very specific purposes of the `no-unsupported-imports` rule,
|
|
8
|
-
* and if so, find the package name and sub-path.
|
|
9
|
-
*/
|
|
10
|
-
function parseImportIfRelevant(importPath, ignorePatterns) {
|
|
11
|
-
// Remove any webpack loader prefix
|
|
12
|
-
// (* is greedy, so it will work even if multiple loaders are specified)
|
|
13
|
-
const normalizedImport = importPath.replace(/.*!/, '');
|
|
14
|
-
// Ignore relative imports, internal imports, builtins, and data URLs
|
|
15
|
-
// (builtinModules includes valid sub-paths like "fs/promises")
|
|
16
|
-
if (!/^([.#]|node:|data:)/.test(normalizedImport) && !module_1.builtinModules.includes(normalizedImport)) {
|
|
17
|
-
// Find the package name and sub-path (if any)
|
|
18
|
-
const { packageName, subPath } = parseModuleId(normalizedImport);
|
|
19
|
-
// Ignore top-level imports, or anything from an ignored package
|
|
20
|
-
if (subPath && !ignorePatterns.some((r) => r.test(normalizedImport))) {
|
|
21
|
-
return { packageName, subPath };
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Parse a module ID which is assumed to point to an actual file in a package (no loader prefixes,
|
|
28
|
-
* relative paths, node builtins, or data URIs).
|
|
29
|
-
* @returns Package name and sub-path (if any). Sub-path does *not* include a leading `./`,
|
|
30
|
-
* e.g. `@foo/bar/baz` returns `{ packageName: '@foo/bar', subPath: 'baz' }`.
|
|
31
|
-
*/
|
|
32
|
-
function parseModuleId(moduleId) {
|
|
33
|
-
const nameParts = moduleId.split('/');
|
|
34
|
-
const hasScope = nameParts.length >= 2 && nameParts[0][0] === '@';
|
|
35
|
-
const packageName = hasScope ? `${nameParts[0]}/${nameParts[1]}` : nameParts[0];
|
|
36
|
-
const subPath = nameParts.slice(hasScope ? 2 : 1).join('/');
|
|
37
|
-
return { packageName, subPath };
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=parseImportIfRelevant.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseImportIfRelevant.js","sourceRoot":"","sources":["../../../src/utils/unsupportedImports/parseImportIfRelevant.ts"],"names":[],"mappings":";;AAMA,sDAoBC;AAQD,sCAOC;AAzCD,mCAAwC;AAExC;;;GAGG;AACH,SAAgB,qBAAqB,CACnC,UAAkB,EAClB,cAAwB;IAExB,mCAAmC;IACnC,wEAAwE;IACxE,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAEvD,qEAAqE;IACrE,+DAA+D;IAC/D,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,uBAAc,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAChG,8CAA8C;QAC9C,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAEjE,gEAAgE;QAChE,IAAI,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC;YACrE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;QAClC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,QAAgB;IAC5C,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;IAElE,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAChF,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import { builtinModules } from 'module';\n\n/**\n * Verify that the import is relevant for the very specific purposes of the `no-unsupported-imports` rule,\n * and if so, find the package name and sub-path.\n */\nexport function parseImportIfRelevant(\n importPath: string,\n ignorePatterns: RegExp[],\n): { packageName: string; subPath: string } | null {\n // Remove any webpack loader prefix\n // (* is greedy, so it will work even if multiple loaders are specified)\n const normalizedImport = importPath.replace(/.*!/, '');\n\n // Ignore relative imports, internal imports, builtins, and data URLs\n // (builtinModules includes valid sub-paths like \"fs/promises\")\n if (!/^([.#]|node:|data:)/.test(normalizedImport) && !builtinModules.includes(normalizedImport)) {\n // Find the package name and sub-path (if any)\n const { packageName, subPath } = parseModuleId(normalizedImport);\n\n // Ignore top-level imports, or anything from an ignored package\n if (subPath && !ignorePatterns.some((r) => r.test(normalizedImport))) {\n return { packageName, subPath };\n }\n }\n return null;\n}\n\n/**\n * Parse a module ID which is assumed to point to an actual file in a package (no loader prefixes,\n * relative paths, node builtins, or data URIs).\n * @returns Package name and sub-path (if any). Sub-path does *not* include a leading `./`,\n * e.g. `@foo/bar/baz` returns `{ packageName: '@foo/bar', subPath: 'baz' }`.\n */\nexport function parseModuleId(moduleId: string): { packageName: string; subPath: string } {\n const nameParts = moduleId.split('/');\n const hasScope = nameParts.length >= 2 && nameParts[0][0] === '@';\n\n const packageName = hasScope ? `${nameParts[0]}/${nameParts[1]}` : nameParts[0];\n const subPath = nameParts.slice(hasScope ? 2 : 1).join('/');\n return { packageName, subPath };\n}\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { PackageExports } from '../PackageJson.js';
|
|
2
|
-
/**
|
|
3
|
-
* Determine whether `importSubPath` might satisfy any sub-path from the exports map,
|
|
4
|
-
* disregarding conditions and file existence.
|
|
5
|
-
* @param importSubPath Sub-path such as `lib/foo`
|
|
6
|
-
*/
|
|
7
|
-
export declare function pathSatisfiesAnyExport(exportsMap: PackageExports | undefined, importSubPath: string): boolean;
|
|
8
|
-
//# sourceMappingURL=pathSatisfiesAnyExport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pathSatisfiesAnyExport.d.ts","sourceRoot":"","sources":["../../../src/utils/unsupportedImports/pathSatisfiesAnyExport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,cAAc,GAAG,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CA8B7G"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pathSatisfiesAnyExport = pathSatisfiesAnyExport;
|
|
4
|
-
/**
|
|
5
|
-
* Determine whether `importSubPath` might satisfy any sub-path from the exports map,
|
|
6
|
-
* disregarding conditions and file existence.
|
|
7
|
-
* @param importSubPath Sub-path such as `lib/foo`
|
|
8
|
-
*/
|
|
9
|
-
function pathSatisfiesAnyExport(exportsMap, importSubPath) {
|
|
10
|
-
// If the exports map is a string, it's a shorthand for a single export.
|
|
11
|
-
// If it's an array, the contents are fallbacks for a single export.
|
|
12
|
-
if (!exportsMap || typeof exportsMap === 'string' || Array.isArray(exportsMap)) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
importSubPath = `./${importSubPath}`;
|
|
16
|
-
return (
|
|
17
|
-
// Check for very basic exclusions. (Technically a path could also be excluded by setting
|
|
18
|
-
// a condition to null, or by setting a later wildcard to override an earlier one.
|
|
19
|
-
// Handling for this can be added later if needed.)
|
|
20
|
-
exportsMap[importSubPath] !== null &&
|
|
21
|
-
Object.keys(exportsMap).some((key) => {
|
|
22
|
-
// . is the root import, not a sub-path.
|
|
23
|
-
// Starting character other than . means this is a condition, not a path.
|
|
24
|
-
if (key === '.' || key[0] !== '.') {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
if (key.includes('*')) {
|
|
28
|
-
return new RegExp(`^${key.replace(/\./g, '\\.').replace(/\*/g, '.*')}$`).test(importSubPath);
|
|
29
|
-
}
|
|
30
|
-
if (key.endsWith('/')) {
|
|
31
|
-
return importSubPath.startsWith(key);
|
|
32
|
-
}
|
|
33
|
-
// Check if the path is a literal match for this key
|
|
34
|
-
return key === importSubPath;
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=pathSatisfiesAnyExport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pathSatisfiesAnyExport.js","sourceRoot":"","sources":["../../../src/utils/unsupportedImports/pathSatisfiesAnyExport.ts"],"names":[],"mappings":";;AAOA,wDA8BC;AAnCD;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,UAAsC,EAAE,aAAqB;IAClG,wEAAwE;IACxE,oEAAoE;IACpE,IAAI,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/E,OAAO,KAAK,CAAC;IACf,CAAC;IAED,aAAa,GAAG,KAAK,aAAa,EAAE,CAAC;IAErC,OAAO;IACL,yFAAyF;IACzF,kFAAkF;IAClF,mDAAmD;IAClD,UAAsC,CAAC,aAAa,CAAC,KAAK,IAAI;QAC/D,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACnC,wCAAwC;YACxC,yEAAyE;YACzE,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;gBAClC,OAAO,KAAK,CAAC;YACf,CAAC;YACD,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACtB,OAAO,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC/F,CAAC;YACD,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACtB,OAAO,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACvC,CAAC;YACD,oDAAoD;YACpD,OAAO,GAAG,KAAK,aAAa,CAAC;QAC/B,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageExports } from '../PackageJson.js';\n\n/**\n * Determine whether `importSubPath` might satisfy any sub-path from the exports map,\n * disregarding conditions and file existence.\n * @param importSubPath Sub-path such as `lib/foo`\n */\nexport function pathSatisfiesAnyExport(exportsMap: PackageExports | undefined, importSubPath: string): boolean {\n // If the exports map is a string, it's a shorthand for a single export.\n // If it's an array, the contents are fallbacks for a single export.\n if (!exportsMap || typeof exportsMap === 'string' || Array.isArray(exportsMap)) {\n return false;\n }\n\n importSubPath = `./${importSubPath}`;\n\n return (\n // Check for very basic exclusions. (Technically a path could also be excluded by setting\n // a condition to null, or by setting a later wildcard to override an earlier one.\n // Handling for this can be added later if needed.)\n (exportsMap as Record<string, unknown>)[importSubPath] !== null &&\n Object.keys(exportsMap).some((key) => {\n // . is the root import, not a sub-path.\n // Starting character other than . means this is a condition, not a path.\n if (key === '.' || key[0] !== '.') {\n return false;\n }\n if (key.includes('*')) {\n return new RegExp(`^${key.replace(/\\./g, '\\\\.').replace(/\\*/g, '.*')}$`).test(importSubPath);\n }\n if (key.endsWith('/')) {\n return importSubPath.startsWith(key);\n }\n // Check if the path is a literal match for this key\n return key === importSubPath;\n })\n );\n}\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolve the root directory of `packageName` starting from `fromDir`, with caching.
|
|
3
|
-
* This uses the basic `resolve` package (which doesn't respect exports maps) to resolve
|
|
4
|
-
* `${packageName}/package.json`, which should always exist.
|
|
5
|
-
*/
|
|
6
|
-
export declare function resolvePackageRoot(fromDir: string, packageName: string, debug: boolean): string | null;
|
|
7
|
-
//# sourceMappingURL=resolvePackageRoot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePackageRoot.d.ts","sourceRoot":"","sources":["../../../src/utils/unsupportedImports/resolvePackageRoot.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAyBtG"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePackageRoot = resolvePackageRoot;
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const _resolve = require("resolve");
|
|
6
|
-
// 'resolve' index.js looks like this:
|
|
7
|
-
// var async = require('./lib/async');
|
|
8
|
-
// async.sync = require('./lib/sync');
|
|
9
|
-
// module.exports = async;
|
|
10
|
-
// This does not play nicely with at least one transpilation or interop step, possibly on specific
|
|
11
|
-
// Node versions: `import * as resolve` *usually* gives the `resolve` function, but sometimes it
|
|
12
|
-
// gives an object with property `default`... This is a workaround for either case.
|
|
13
|
-
// eslint-disable-next-line
|
|
14
|
-
const resolveSync = _resolve.sync || _resolve.default?.sync;
|
|
15
|
-
const getCacheKey = (fromDir, packageName) => `${fromDir}::${packageName}`;
|
|
16
|
-
const resolveCache = new Map();
|
|
17
|
-
/**
|
|
18
|
-
* Resolve the root directory of `packageName` starting from `fromDir`, with caching.
|
|
19
|
-
* This uses the basic `resolve` package (which doesn't respect exports maps) to resolve
|
|
20
|
-
* `${packageName}/package.json`, which should always exist.
|
|
21
|
-
*/
|
|
22
|
-
function resolvePackageRoot(fromDir, packageName, debug) {
|
|
23
|
-
const cacheKey = getCacheKey(fromDir, packageName);
|
|
24
|
-
const cached = resolveCache.get(cacheKey);
|
|
25
|
-
if (cached !== undefined) {
|
|
26
|
-
return cached;
|
|
27
|
-
}
|
|
28
|
-
const resolvePath = `${packageName}/package.json`;
|
|
29
|
-
let resolved = null;
|
|
30
|
-
try {
|
|
31
|
-
resolved = path.dirname(resolveSync(resolvePath, { basedir: fromDir, preserveSymlinks: false }));
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
if (debug) {
|
|
35
|
-
// eslint-disable-next-line
|
|
36
|
-
if (err?.code === 'MODULE_NOT_FOUND') {
|
|
37
|
-
console.error(`Failed to resolve ${resolvePath} from ${fromDir} (module not found)`);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
console.error(`Failed to resolve ${resolvePath} from ${fromDir}: ${err.message || err}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Cache even if resolution failed so we don't waste time trying again
|
|
45
|
-
resolveCache.set(cacheKey, resolved);
|
|
46
|
-
return resolved;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=resolvePackageRoot.js.map
|
|
@@ -1 +0,0 @@
|
|
|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,SAAS,OAAO,qBAAqB,CAAC,CAAC;YACvF,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,qBAAqB,WAAW,SAAS,OAAO,KAAM,GAAa,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC;YACtG,CAAC;QACH,CAAC;IACH,CAAC;IAED,sEAAsE;IACtE,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACrC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import * as path from 'path';\nimport * as _resolve from 'resolve';\n\n// 'resolve' index.js looks like this:\n// var async = require('./lib/async');\n// async.sync = require('./lib/sync');\n// module.exports = async;\n// This does not play nicely with at least one transpilation or interop step, possibly on specific\n// Node versions: `import * as resolve` *usually* gives the `resolve` function, but sometimes it\n// gives an object with property `default`... This is a workaround for either case.\n// eslint-disable-next-line\nconst resolveSync: typeof _resolve.sync = _resolve.sync || (_resolve as any).default?.sync;\n\nconst getCacheKey = (fromDir: string, packageName: string): string => `${fromDir}::${packageName}`;\nconst resolveCache = new Map<string, string | null>();\n\n/**\n * Resolve the root directory of `packageName` starting from `fromDir`, with caching.\n * This uses the basic `resolve` package (which doesn't respect exports maps) to resolve\n * `${packageName}/package.json`, which should always exist.\n */\nexport function resolvePackageRoot(fromDir: string, packageName: string, debug: boolean): string | null {\n const cacheKey = getCacheKey(fromDir, packageName);\n const cached = resolveCache.get(cacheKey);\n if (cached !== undefined) {\n return cached;\n }\n\n const resolvePath = `${packageName}/package.json`;\n let resolved: string | null = null;\n try {\n resolved = path.dirname(resolveSync(resolvePath, { basedir: fromDir, preserveSymlinks: false }));\n } catch (err) {\n if (debug) {\n // eslint-disable-next-line\n if ((err as any)?.code === 'MODULE_NOT_FOUND') {\n console.error(`Failed to resolve ${resolvePath} from ${fromDir} (module not found)`);\n } else {\n console.error(`Failed to resolve ${resolvePath} from ${fromDir}: ${(err as Error).message || err}`);\n }\n }\n }\n\n // Cache even if resolution failed so we don't waste time trying again\n resolveCache.set(cacheKey, resolved);\n return resolved;\n}\n"]}
|