@ms-cloudpack/eslint-plugin 0.4.0 → 0.4.1
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/lib/utils/createRule.js +1 -2
- package/lib/utils/createRule.js.map +1 -1
- package/lib/utils/getImportPathLiteralNode.js +1 -2
- package/lib/utils/getImportPathLiteralNode.js.map +1 -1
- package/lib/utils/getPackageInfo.js +1 -2
- package/lib/utils/getPackageInfo.js.map +1 -1
- package/lib/utils/getRegexpsFromStrings.js +1 -2
- package/lib/utils/getRegexpsFromStrings.js.map +1 -1
- package/lib/utils/testExports/extractIdentifiersFromExport.js +1 -2
- package/lib/utils/testExports/extractIdentifiersFromExport.js.map +1 -1
- package/lib/utils/testExports/isIncludedIndexFile.js +1 -2
- package/lib/utils/testExports/isIncludedIndexFile.js.map +1 -1
- package/lib/utils/unsupportedImports/parseImportIfRelevant.js +2 -3
- package/lib/utils/unsupportedImports/parseImportIfRelevant.js.map +1 -1
- package/lib/utils/unsupportedImports/pathSatisfiesAnyExport.js +1 -2
- package/lib/utils/unsupportedImports/pathSatisfiesAnyExport.js.map +1 -1
- package/lib/utils/unsupportedImports/resolvePackageRoot.js +1 -2
- package/lib/utils/unsupportedImports/resolvePackageRoot.js.map +1 -1
- package/package.json +4 -2
package/lib/utils/createRule.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRule =
|
|
3
|
+
exports.createRule = createRule;
|
|
4
4
|
/**
|
|
5
5
|
* Create a lint rule, with strongly typed data in `context.report`.
|
|
6
6
|
* (This assumes all error/suggestion messages share a common data type.)
|
|
@@ -29,5 +29,4 @@ function createRule(params) {
|
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
exports.createRule = createRule;
|
|
33
32
|
//# sourceMappingURL=createRule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRule.js","sourceRoot":"","sources":["../../src/utils/createRule.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"createRule.js","sourceRoot":"","sources":["../../src/utils/createRule.ts"],"names":[],"mappings":";;AA2EA,gCA2BC;AA/BD;;;GAGG;AACH,SAAgB,UAAU,CACxB,MAA4D;IAE5D,OAAO;QACL,GAAG,MAAM;QACT,IAAI,EAAE;YACJ,GAAG,MAAM,CAAC,IAAI;YACd,IAAI,EAAE;gBACJ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI;gBACnB,GAAG,EAAE,6DAA6D,MAAM,CAAC,IAAI,EAAE;aAChF;SACF;QACD,cAAc,EAAE,EAAE;QAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;YAClB,MAAM,WAAW,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;YAEnC,sDAAsD;YACtD,sCAAsC;YACtC,WAAW,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YACvC,WAAW,CAAC,QAAQ,KAAK,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;YACjD,WAAW,CAAC,gBAAgB,KAAK,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;YACjE,WAAW,CAAC,UAAU,KAAK,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;YACrD,qCAAqC;YAErC,OAAO,MAAM,CAAC,MAAM,CAAC,WAA6D,CAAC,CAAC;QACtF,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["//\n// This file contains wrappers for rule creation and related types.\n//\nimport type { ESLintUtils, TSESLint, TSESTree } from '@typescript-eslint/utils';\n\ntype Writable<T> = { -readonly [K in keyof T]: T[K] };\n\n/**\n * Problem report descriptor with strongly typed error and suggestion data.\n * (This assumes all error/suggestion messages share a common data type.)\n */\nexport type ReportDescriptor<TMessageIds extends string, TErrorData> = Omit<\n // Make the descriptor writable for convenience (like conditionally adding a fix)\n Writable<TSESLint.ReportDescriptor<TMessageIds>>,\n 'data' | 'node' | 'suggest'\n> & {\n data: TErrorData;\n // have to re-declare `node` due to an oddity with union types (built-in ReportDescriptor is a union) and omit\n node: TSESTree.Node;\n suggest?: SuggestionDescriptor<TMessageIds, TErrorData>[] | null;\n};\n\n/** Fix suggestion with strongly typed data. */\nexport type SuggestionDescriptor<TMessageIds extends string, TErrorData> = Omit<\n ReportDescriptor<TMessageIds, TErrorData>,\n 'suggest' | 'node'\n>;\n\n/** Fix suggestion output (for testing). */\nexport type SuggestionOutput<TMessageIds extends string, TErrorData> = Omit<\n TSESLint.SuggestionOutput<TMessageIds>,\n 'data'\n> & { data?: TErrorData };\n\n/**\n * Rule context with strongly typed `report`.\n * (This assumes all error/suggestion messages share a common data type.)\n */\nexport type RuleContext<TOptions, TMessageIds extends string, TErrorData> = Omit<\n TSESLint.RuleContext<TMessageIds, TOptions[]>,\n 'report'\n> & {\n report: (descriptor: ReportDescriptor<TMessageIds, TErrorData>) => void;\n};\n\n/**\n * Rule info with better {@link RuleContext} type for the `create` function.\n * (This assumes all error/suggestion messages share a common data type.)\n */\ntype CreateRuleOptions<TOptions, TMessageIds extends string, TErrorData> = Omit<\n ESLintUtils.RuleWithMetaAndName<TOptions[], TMessageIds>,\n // Why remove defaultOptions (array): typescript-eslint merges this array with the original\n // options array and passes the merged array as the second argument to `create`. However,\n // this isn't reflected in the types, and its behavior is kind of weird (an empty `defaultOptions`\n // array will cause the provided options to be ignored). So remove it from the types\n // and fill in a default value in `createRule` instead.\n 'create' | 'defaultOptions'\n> & {\n create(this: void, context: Readonly<RuleContext<TOptions, TMessageIds, TErrorData>>): TSESLint.RuleListener;\n};\n\n/**\n * This exported alias is just to avoid an error when exporting the `rule` returned from `createRule`\n * (\"the inferred type of 'rule' cannot be named without a reference to ...\").\n */\nexport type RuleModule<TOptions, TMessageIds extends string> = ESLintUtils.RuleModule<\n TMessageIds,\n TOptions[],\n ESLintUtils.RuleListener\n>;\n\n/**\n * Create a lint rule, with strongly typed data in `context.report`.\n * (This assumes all error/suggestion messages share a common data type.)\n */\nexport function createRule<TOptions, TMessageIds extends string, TErrorData>(\n params: CreateRuleOptions<TOptions, TMessageIds, TErrorData>,\n): RuleModule<TOptions, TMessageIds> {\n return {\n ...params,\n meta: {\n ...params.meta,\n docs: {\n ...params.meta.docs,\n url: `https://www.npmjs.com/package/@ms-cloudpack/eslint-plugin#${params.name}`,\n },\n },\n defaultOptions: [],\n create: (context) => {\n const contextCopy = { ...context };\n\n // Fill in properties that were added in eslint 8.40.0\n /* eslint-disable etc/no-deprecated */\n contextCopy.cwd ??= context.getCwd?.();\n contextCopy.filename ??= context.getFilename?.();\n contextCopy.physicalFilename ??= context.getPhysicalFilename?.();\n contextCopy.sourceCode ??= context.getSourceCode?.();\n /* eslint-enable etc/no-deprecated */\n\n return params.create(contextCopy as RuleContext<TOptions, TMessageIds, TErrorData>);\n },\n };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getImportPathLiteralNode =
|
|
3
|
+
exports.getImportPathLiteralNode = getImportPathLiteralNode;
|
|
4
4
|
/**
|
|
5
5
|
* Verifies that the given node contains a string literal import path, and if so, returns the path node.
|
|
6
6
|
* (For `CallExpression` nodes, also verifies that the callee is `require` or `require.resolve`.)
|
|
@@ -41,5 +41,4 @@ function getImportPathLiteralNode(node) {
|
|
|
41
41
|
}
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
|
-
exports.getImportPathLiteralNode = getImportPathLiteralNode;
|
|
45
44
|
//# sourceMappingURL=getImportPathLiteralNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getImportPathLiteralNode.js","sourceRoot":"","sources":["../../src/utils/getImportPathLiteralNode.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getImportPathLiteralNode.js","sourceRoot":"","sources":["../../src/utils/getImportPathLiteralNode.ts"],"names":[],"mappings":";;AAcA,4DA0CC;AA9CD;;;GAGG;AACH,SAAgB,wBAAwB,CACtC,IAAoB;IAEpB,IAAI,QAAQ,GAAyB,IAAI,CAAC;IAE1C,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;QACtF,MAAM,gBAAgB,GACpB,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB;YACvC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;YACxC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS;YACrC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;YAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC;QAE1C,IAAI,CAAC,SAAS,IAAI,gBAAgB,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnE,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;SAAM,IAAI,IAAI,CAAC,IAAI,KAAK,2BAA2B,EAAE,CAAC;QACrD,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,KAAK,2BAA2B,EAAE,CAAC;YAC9D,+BAA+B;YAC/B,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC;QAC7C,CAAC;IACH,CAAC;SAAM,IACL,IAAI,CAAC,IAAI,KAAK,wBAAwB;QACtC,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,2BAA2B;QACtD,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,KAAK,2BAA2B,EACrE,CAAC;QACD,sCAAsC;QACtC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC;IACzD,CAAC;SAAM,CAAC;QACN,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ,EAAE,IAAI,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;IAClD,CAAC;IAED,IAAI,QAAQ,EAAE,IAAI,KAAK,iBAAiB,IAAI,QAAQ,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9G,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IACnE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\n\nexport type ImportLikeNode =\n | TSESTree.CallExpression\n | TSESTree.ExportAllDeclaration\n | TSESTree.ExportNamedDeclaration\n | TSESTree.ImportDeclaration\n | TSESTree.ImportExpression\n | TSESTree.TSImportEqualsDeclaration;\n\n/**\n * Verifies that the given node contains a string literal import path, and if so, returns the path node.\n * (For `CallExpression` nodes, also verifies that the callee is `require` or `require.resolve`.)\n */\nexport function getImportPathLiteralNode(\n node: ImportLikeNode,\n): { pathNode: TSESTree.StringLiteral | TSESTree.TemplateLiteral; importPath: string } | null {\n let pathNode: TSESTree.Node | null = null;\n\n if (node.type === 'CallExpression') {\n const isRequire = node.callee.type === 'Identifier' && node.callee.name === 'require';\n const isRequireResolve =\n node.callee.type === 'MemberExpression' &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'require' &&\n node.callee.property.type === 'Identifier' &&\n node.callee.property.name === 'resolve';\n\n if ((isRequire || isRequireResolve) && node.arguments.length === 1) {\n pathNode = node.arguments[0];\n }\n } else if (node.type === 'TSImportEqualsDeclaration') {\n if (node.moduleReference.type === 'TSExternalModuleReference') {\n // import foo = require('foo');\n pathNode = node.moduleReference.expression;\n }\n } else if (\n node.type === 'ExportNamedDeclaration' &&\n node.declaration?.type === 'TSImportEqualsDeclaration' &&\n node.declaration.moduleReference.type === 'TSExternalModuleReference'\n ) {\n // export import foo = require('foo');\n pathNode = node.declaration.moduleReference.expression;\n } else {\n pathNode = node.source;\n }\n\n if (pathNode?.type === 'Literal' && typeof pathNode.value === 'string') {\n return { pathNode, importPath: pathNode.value };\n }\n\n if (pathNode?.type === 'TemplateLiteral' && pathNode.expressions.length === 0 && pathNode.quasis.length === 1) {\n return { pathNode, importPath: pathNode.quasis[0].value.cooked };\n }\n\n return null;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPackageInfo =
|
|
3
|
+
exports.getPackageInfo = getPackageInfo;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const packageInfoCache = new Map();
|
|
@@ -57,5 +57,4 @@ function getPackageInfo(startPath, debug) {
|
|
|
57
57
|
packageInfoCache.set(startDir, packageInfo);
|
|
58
58
|
return packageInfo;
|
|
59
59
|
}
|
|
60
|
-
exports.getPackageInfo = getPackageInfo;
|
|
61
60
|
//# sourceMappingURL=getPackageInfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageInfo.js","sourceRoot":"","sources":["../../src/utils/getPackageInfo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPackageInfo.js","sourceRoot":"","sources":["../../src/utils/getPackageInfo.ts"],"names":[],"mappings":";;AAmBA,wCAmDC;AAtED,yBAAyB;AACzB,6BAA6B;AAY7B,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA8B,CAAC;AAC/D;;;;GAIG;AACH,SAAgB,cAAc,CAAC,SAAiB,EAAE,KAAe;IAC/D,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7D,2FAA2F;QAC3F,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kEAAkE;IAClE,SAAS,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;IAExC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAE5G,IAAI,GAAG,GAAG,QAAQ,CAAC;IACnB,IAAI,eAAe,GAAG,EAAE,CAAC;IACzB,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,OAAO,GAAG,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,UAAU,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;YAC3C,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QACjD,IAAI,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;YACnC,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;aAAM,CAAC;YACN,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,2CAA2C,SAAS,EAAE,CAAC,CAAC;QAC/E,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,WAAW,GAAuB,IAAI,CAAC;IAC3C,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAgB,CAAC;QACxF,WAAW,GAAG;YACZ,IAAI,EAAE,GAAG;YACT,iCAAiC;YACjC,OAAO,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,CAAC;YAC5C,IAAI,EAAE,WAAW;SAClB,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,4BAA4B,eAAe,GAAG,EAAE,GAAG,CAAC,CAAC;IAC9E,CAAC;IACD,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IACvC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC5C,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport type { PackageJson } from './PackageJson';\n\nexport type PackageInfo = {\n /** Path to the package root directory */\n path: string;\n /** Whether this is a package locally developed in the same monorepo */\n isLocal: boolean;\n /** package.json contents */\n json: PackageJson;\n};\n\nconst packageInfoCache = new Map<string, PackageInfo | null>();\n/**\n * Find the package root directory relative to the given file (based on the presence of a\n * package.json file) and read the package.json.\n * @param startPath Search up starting from this file or directory\n */\nexport function getPackageInfo(startPath: string, debug?: boolean): PackageInfo | null {\n if (!path.isAbsolute(startPath) || !fs.existsSync(startPath)) {\n // prevent unexpected results if a test or other code passes a relative or nonexistent path\n return null;\n }\n\n // Use the realpath in case this is a linked package in a monorepo\n startPath = fs.realpathSync(startPath);\n const root = path.parse(startPath).root;\n\n const startDir = path.normalize(fs.statSync(startPath).isDirectory() ? startPath : path.dirname(startPath));\n\n let dir = startDir;\n let packageJsonPath = '';\n let found = false;\n while (dir !== root && !found) {\n const cachedInfo = packageInfoCache.get(dir);\n if (cachedInfo !== undefined) {\n packageInfoCache.set(startDir, cachedInfo);\n return cachedInfo;\n }\n\n packageJsonPath = path.join(dir, 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n found = true;\n } else {\n dir = path.dirname(dir);\n }\n }\n\n if (!found) {\n debug && console.error(`no package.json found searching up from ${startPath}`);\n packageInfoCache.set(startDir, null);\n return null;\n }\n\n let packageInfo: PackageInfo | null = null;\n try {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) as PackageJson;\n packageInfo = {\n path: dir,\n // TODO may not work with yarn 3?\n isLocal: !/[\\\\/]node_modules[\\\\/]/.test(dir),\n json: packageJson,\n };\n } catch (err) {\n debug && console.error(`error reading or parsing ${packageJsonPath}:`, err);\n }\n packageInfoCache.set(dir, packageInfo);\n packageInfoCache.set(startDir, packageInfo);\n return packageInfo;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRegexpsFromStrings =
|
|
3
|
+
exports.getRegexpsFromStrings = getRegexpsFromStrings;
|
|
4
4
|
/**
|
|
5
5
|
* Get an array of regular expressions from an array of strings, replacing the `...` string with
|
|
6
6
|
* the default values (if provided). If `strs` is undefined, returns `defaults` or an empty array.
|
|
@@ -8,5 +8,4 @@ exports.getRegexpsFromStrings = void 0;
|
|
|
8
8
|
function getRegexpsFromStrings(strs, defaults = []) {
|
|
9
9
|
return strs?.map((str) => (str === '...' ? defaults : new RegExp(str))).flat() || defaults;
|
|
10
10
|
}
|
|
11
|
-
exports.getRegexpsFromStrings = getRegexpsFromStrings;
|
|
12
11
|
//# sourceMappingURL=getRegexpsFromStrings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRegexpsFromStrings.js","sourceRoot":"","sources":["../../src/utils/getRegexpsFromStrings.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getRegexpsFromStrings.js","sourceRoot":"","sources":["../../src/utils/getRegexpsFromStrings.ts"],"names":[],"mappings":";;AAIA,sDAEC;AAND;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,IAA0B,EAAE,WAAqB,EAAE;IACvF,OAAO,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,QAAQ,CAAC;AAC7F,CAAC","sourcesContent":["/**\n * Get an array of regular expressions from an array of strings, replacing the `...` string with\n * the default values (if provided). If `strs` is undefined, returns `defaults` or an empty array.\n */\nexport function getRegexpsFromStrings(strs: string[] | undefined, defaults: RegExp[] = []): RegExp[] {\n return strs?.map((str) => (str === '...' ? defaults : new RegExp(str))).flat() || defaults;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractIdentifiersFromExport =
|
|
3
|
+
exports.extractIdentifiersFromExport = extractIdentifiersFromExport;
|
|
4
4
|
/**
|
|
5
5
|
* Extract identifiers from an export declaration.
|
|
6
6
|
*/
|
|
@@ -54,5 +54,4 @@ function extractIdentifiersFromExport(node) {
|
|
|
54
54
|
}
|
|
55
55
|
return ids;
|
|
56
56
|
}
|
|
57
|
-
exports.extractIdentifiersFromExport = extractIdentifiersFromExport;
|
|
58
57
|
//# sourceMappingURL=extractIdentifiersFromExport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractIdentifiersFromExport.js","sourceRoot":"","sources":["../../../src/utils/testExports/extractIdentifiersFromExport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extractIdentifiersFromExport.js","sourceRoot":"","sources":["../../../src/utils/testExports/extractIdentifiersFromExport.ts"],"names":[],"mappings":";;AAKA,oEAoDC;AAvDD;;GAEG;AACH,SAAgB,4BAA4B,CAC1C,IAAqE;IAErE,IAAI,IAAI,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;QACzC,6BAA6B;QAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,CAAC;IAED,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QAC3B,kBAAkB;QAClB,6BAA6B;QAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,qBAAqB,EAAE,CAAC;QACzE,qCAAqC;QACrC,2CAA2C;QAC3C,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACjF,CAAC;IAED,MAAM,GAAG,GAA0B,EAAE,CAAC;IACtC,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,YAAY,IAAI,EAAE,CAAC;IAE1D,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YAClC,2BAA2B;YAC3B,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC;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);\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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isIncludedIndexFile =
|
|
3
|
+
exports.isIncludedIndexFile = isIncludedIndexFile;
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const getPackageInfo_js_1 = require("../getPackageInfo.js");
|
|
6
6
|
/**
|
|
@@ -24,5 +24,4 @@ function isIncludedIndexFile(params) {
|
|
|
24
24
|
}
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
|
-
exports.isIncludedIndexFile = isIncludedIndexFile;
|
|
28
27
|
//# sourceMappingURL=isIncludedIndexFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isIncludedIndexFile.js","sourceRoot":"","sources":["../../../src/utils/testExports/isIncludedIndexFile.ts"],"names":[],"mappings":"
|
|
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,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseImportIfRelevant = parseImportIfRelevant;
|
|
4
|
+
exports.parseModuleId = parseModuleId;
|
|
4
5
|
const module_1 = require("module");
|
|
5
6
|
/**
|
|
6
7
|
* Verify that the import is relevant for the very specific purposes of the `no-unsupported-imports` rule,
|
|
@@ -22,7 +23,6 @@ function parseImportIfRelevant(importPath, ignorePatterns) {
|
|
|
22
23
|
}
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
25
|
-
exports.parseImportIfRelevant = parseImportIfRelevant;
|
|
26
26
|
/**
|
|
27
27
|
* Parse a module ID which is assumed to point to an actual file in a package (no loader prefixes,
|
|
28
28
|
* relative paths, node builtins, or data URIs).
|
|
@@ -36,5 +36,4 @@ function parseModuleId(moduleId) {
|
|
|
36
36
|
const subPath = nameParts.slice(hasScope ? 2 : 1).join('/');
|
|
37
37
|
return { packageName, subPath };
|
|
38
38
|
}
|
|
39
|
-
exports.parseModuleId = parseModuleId;
|
|
40
39
|
//# sourceMappingURL=parseImportIfRelevant.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseImportIfRelevant.js","sourceRoot":"","sources":["../../../src/utils/unsupportedImports/parseImportIfRelevant.ts"],"names":[],"mappings":"
|
|
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) {\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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pathSatisfiesAnyExport =
|
|
3
|
+
exports.pathSatisfiesAnyExport = pathSatisfiesAnyExport;
|
|
4
4
|
/**
|
|
5
5
|
* Determine whether `importSubPath` might satisfy any sub-path from the exports map,
|
|
6
6
|
* disregarding conditions and file existence.
|
|
@@ -34,5 +34,4 @@ function pathSatisfiesAnyExport(exportsMap, importSubPath) {
|
|
|
34
34
|
return key === importSubPath;
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
|
-
exports.pathSatisfiesAnyExport = pathSatisfiesAnyExport;
|
|
38
37
|
//# sourceMappingURL=pathSatisfiesAnyExport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathSatisfiesAnyExport.js","sourceRoot":"","sources":["../../../src/utils/unsupportedImports/pathSatisfiesAnyExport.ts"],"names":[],"mappings":"
|
|
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) {\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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePackageRoot =
|
|
3
|
+
exports.resolvePackageRoot = resolvePackageRoot;
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const _resolve = require("resolve");
|
|
6
6
|
// 'resolve' index.js looks like this:
|
|
@@ -45,5 +45,4 @@ function resolvePackageRoot(fromDir, packageName, debug) {
|
|
|
45
45
|
resolveCache.set(cacheKey, resolved);
|
|
46
46
|
return resolved;
|
|
47
47
|
}
|
|
48
|
-
exports.resolvePackageRoot = resolvePackageRoot;
|
|
49
48
|
//# sourceMappingURL=resolvePackageRoot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePackageRoot.js","sourceRoot":"","sources":["../../../src/utils/unsupportedImports/resolvePackageRoot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolvePackageRoot.js","sourceRoot":"","sources":["../../../src/utils/unsupportedImports/resolvePackageRoot.ts"],"names":[],"mappings":";;AAqBA,gDAyBC;AA9CD,6BAA6B;AAC7B,oCAAoC;AAEpC,sCAAsC;AACtC,0CAA0C;AAC1C,0CAA0C;AAC1C,8BAA8B;AAC9B,kGAAkG;AAClG,gGAAgG;AAChG,mFAAmF;AACnF,2BAA2B;AAC3B,MAAM,WAAW,GAAyB,QAAQ,CAAC,IAAI,IAAK,QAAgB,CAAC,OAAO,EAAE,IAAI,CAAC;AAE3F,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,WAAmB,EAAE,EAAE,CAAC,GAAG,OAAO,KAAK,WAAW,EAAE,CAAC;AAC3F,MAAM,YAAY,GAAG,IAAI,GAAG,EAAyB,CAAC;AAEtD;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,OAAe,EAAE,WAAmB,EAAE,KAAc;IACrF,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,WAAW,GAAG,GAAG,WAAW,eAAe,CAAC;IAClD,IAAI,QAAQ,GAAkB,IAAI,CAAC;IACnC,IAAI,CAAC;QACH,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACnG,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,KAAK,EAAE,CAAC;YACV,2BAA2B;YAC3B,IAAK,GAAW,EAAE,IAAI,KAAK,kBAAkB,EAAE,CAAC;gBAC9C,OAAO,CAAC,KAAK,CAAC,qBAAqB,WAAW,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) => `${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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/eslint-plugin",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "A set of ESLint rules for Cloudpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -35,7 +35,9 @@
|
|
|
35
35
|
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
36
36
|
"@typescript-eslint/parser": "^7.0.0",
|
|
37
37
|
"@typescript-eslint/rule-tester": "^7.0.0",
|
|
38
|
-
"@typescript-eslint/utils": "^7.0.0"
|
|
38
|
+
"@typescript-eslint/utils": "^7.0.0",
|
|
39
|
+
"eslint": "^8.50.0",
|
|
40
|
+
"typescript": "~5.5.0"
|
|
39
41
|
},
|
|
40
42
|
"files": [
|
|
41
43
|
"lib/**/!(*.test.*)"
|