@atlaskit/eslint-plugin-platform 2.7.1 → 2.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/CHANGELOG.md +14 -0
- package/dist/cjs/index.js +17 -9
- package/dist/cjs/rules/constants.js +1 -1
- package/dist/cjs/rules/ensure-critical-dependency-resolutions/index.js +5 -5
- package/dist/cjs/rules/ensure-no-private-dependencies/index.js +48 -66
- package/dist/cjs/rules/feature-gating/inline-usage/index.js +14 -3
- package/dist/cjs/rules/feature-gating/no-alias/index.js +1 -1
- package/dist/cjs/rules/feature-gating/no-module-level-eval/index.js +1 -1
- package/dist/cjs/rules/feature-gating/no-module-level-eval-nav4/index.js +1 -1
- package/dist/cjs/rules/feature-gating/no-preconditioning/index.js +4 -1
- package/dist/cjs/rules/feature-gating/prefer-fg/index.js +1 -1
- package/dist/cjs/rules/feature-gating/static-feature-flags/index.js +2 -2
- package/dist/cjs/rules/feature-gating/use-recommended-utils/index.js +1 -1
- package/dist/cjs/rules/feature-gating/valid-gate-name/index.js +60 -0
- package/dist/cjs/rules/import/no-barrel-entry-imports/index.js +871 -0
- package/dist/cjs/rules/import/no-barrel-entry-jest-mock/index.js +1384 -0
- package/dist/cjs/rules/import/no-conversation-assistant-barrel-imports/index.js +43 -0
- package/dist/cjs/rules/import/no-jest-mock-barrel-files/index.js +1401 -0
- package/dist/cjs/rules/import/no-relative-barrel-file-imports/index.js +777 -0
- package/dist/cjs/rules/import/shared/barrel-parsing.js +511 -0
- package/dist/cjs/rules/import/shared/file-system.js +186 -0
- package/dist/cjs/rules/import/shared/jest-utils.js +191 -0
- package/dist/cjs/rules/import/shared/package-registry.js +263 -0
- package/dist/cjs/rules/import/shared/package-resolution.js +185 -0
- package/dist/cjs/rules/import/shared/perf.js +89 -0
- package/dist/cjs/rules/import/shared/types.js +67 -0
- package/dist/cjs/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
- package/dist/cjs/rules/no-sparse-checkout/index.js +1 -1
- package/dist/cjs/rules/prefer-crypto-random-uuid/index.js +87 -0
- package/dist/cjs/rules/use-entrypoints-in-examples/index.js +1 -1
- package/dist/es2019/index.js +17 -9
- package/dist/es2019/rules/constants.js +1 -1
- package/dist/es2019/rules/ensure-critical-dependency-resolutions/index.js +5 -5
- package/dist/es2019/rules/ensure-no-private-dependencies/index.js +10 -9
- package/dist/es2019/rules/feature-gating/inline-usage/index.js +14 -3
- package/dist/es2019/rules/feature-gating/no-alias/index.js +1 -1
- package/dist/es2019/rules/feature-gating/no-module-level-eval/index.js +1 -1
- package/dist/es2019/rules/feature-gating/no-module-level-eval-nav4/index.js +1 -1
- package/dist/es2019/rules/feature-gating/no-preconditioning/index.js +4 -1
- package/dist/es2019/rules/feature-gating/prefer-fg/index.js +1 -1
- package/dist/es2019/rules/feature-gating/static-feature-flags/index.js +2 -2
- package/dist/es2019/rules/feature-gating/use-recommended-utils/index.js +1 -1
- package/dist/es2019/rules/feature-gating/valid-gate-name/index.js +52 -0
- package/dist/es2019/rules/import/no-barrel-entry-imports/index.js +801 -0
- package/dist/es2019/rules/import/no-barrel-entry-jest-mock/index.js +1113 -0
- package/dist/es2019/rules/import/no-conversation-assistant-barrel-imports/index.js +37 -0
- package/dist/es2019/rules/import/no-jest-mock-barrel-files/index.js +1179 -0
- package/dist/es2019/rules/import/no-relative-barrel-file-imports/index.js +738 -0
- package/dist/es2019/rules/import/shared/barrel-parsing.js +433 -0
- package/dist/es2019/rules/import/shared/file-system.js +174 -0
- package/dist/es2019/rules/import/shared/jest-utils.js +159 -0
- package/dist/es2019/rules/import/shared/package-registry.js +240 -0
- package/dist/es2019/rules/import/shared/package-resolution.js +161 -0
- package/dist/es2019/rules/import/shared/perf.js +83 -0
- package/dist/es2019/rules/import/shared/types.js +57 -0
- package/dist/es2019/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
- package/dist/es2019/rules/no-sparse-checkout/index.js +1 -1
- package/dist/es2019/rules/prefer-crypto-random-uuid/index.js +81 -0
- package/dist/es2019/rules/use-entrypoints-in-examples/index.js +1 -1
- package/dist/esm/index.js +17 -9
- package/dist/esm/rules/constants.js +1 -1
- package/dist/esm/rules/ensure-critical-dependency-resolutions/index.js +5 -5
- package/dist/esm/rules/ensure-no-private-dependencies/index.js +48 -65
- package/dist/esm/rules/feature-gating/inline-usage/index.js +14 -3
- package/dist/esm/rules/feature-gating/no-alias/index.js +1 -1
- package/dist/esm/rules/feature-gating/no-module-level-eval/index.js +1 -1
- package/dist/esm/rules/feature-gating/no-module-level-eval-nav4/index.js +1 -1
- package/dist/esm/rules/feature-gating/no-preconditioning/index.js +4 -1
- package/dist/esm/rules/feature-gating/prefer-fg/index.js +1 -1
- package/dist/esm/rules/feature-gating/static-feature-flags/index.js +2 -2
- package/dist/esm/rules/feature-gating/use-recommended-utils/index.js +1 -1
- package/dist/esm/rules/feature-gating/valid-gate-name/index.js +53 -0
- package/dist/esm/rules/import/no-barrel-entry-imports/index.js +864 -0
- package/dist/esm/rules/import/no-barrel-entry-jest-mock/index.js +1375 -0
- package/dist/esm/rules/import/no-conversation-assistant-barrel-imports/index.js +37 -0
- package/dist/esm/rules/import/no-jest-mock-barrel-files/index.js +1391 -0
- package/dist/esm/rules/import/no-relative-barrel-file-imports/index.js +770 -0
- package/dist/esm/rules/import/shared/barrel-parsing.js +500 -0
- package/dist/esm/rules/import/shared/file-system.js +176 -0
- package/dist/esm/rules/import/shared/jest-utils.js +179 -0
- package/dist/esm/rules/import/shared/package-registry.js +256 -0
- package/dist/esm/rules/import/shared/package-resolution.js +175 -0
- package/dist/esm/rules/import/shared/perf.js +80 -0
- package/dist/esm/rules/import/shared/types.js +61 -0
- package/dist/esm/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
- package/dist/esm/rules/no-sparse-checkout/index.js +1 -1
- package/dist/esm/rules/prefer-crypto-random-uuid/index.js +81 -0
- package/dist/esm/rules/use-entrypoints-in-examples/index.js +1 -1
- package/dist/types/index.d.ts +18 -16
- package/dist/types/rules/import/no-barrel-entry-imports/index.d.ts +9 -0
- package/dist/types/rules/import/no-barrel-entry-jest-mock/index.d.ts +9 -0
- package/dist/types/rules/import/no-conversation-assistant-barrel-imports/index.d.ts +3 -0
- package/dist/types/rules/import/no-jest-mock-barrel-files/index.d.ts +22 -0
- package/dist/types/rules/import/no-relative-barrel-file-imports/index.d.ts +5 -0
- package/dist/types/rules/import/shared/barrel-parsing.d.ts +30 -0
- package/dist/types/rules/import/shared/file-system.d.ts +38 -0
- package/dist/types/rules/import/shared/jest-utils.d.ts +47 -0
- package/dist/types/rules/import/shared/package-registry.d.ts +26 -0
- package/dist/types/rules/import/shared/package-resolution.d.ts +38 -0
- package/dist/types/rules/import/shared/perf.d.ts +13 -0
- package/dist/types/rules/import/shared/types.d.ts +131 -0
- package/dist/types/rules/prefer-crypto-random-uuid/index.d.ts +3 -0
- package/dist/types-ts4.5/index.d.ts +18 -28
- package/dist/types-ts4.5/rules/import/no-barrel-entry-imports/index.d.ts +9 -0
- package/dist/types-ts4.5/rules/import/no-barrel-entry-jest-mock/index.d.ts +9 -0
- package/dist/types-ts4.5/rules/import/no-jest-mock-barrel-files/index.d.ts +22 -0
- package/dist/types-ts4.5/rules/import/no-relative-barrel-file-imports/index.d.ts +5 -0
- package/dist/types-ts4.5/rules/import/shared/barrel-parsing.d.ts +30 -0
- package/dist/types-ts4.5/rules/import/shared/file-system.d.ts +38 -0
- package/dist/types-ts4.5/rules/import/shared/jest-utils.d.ts +47 -0
- package/dist/types-ts4.5/rules/import/shared/package-registry.d.ts +26 -0
- package/dist/types-ts4.5/rules/import/shared/package-resolution.d.ts +38 -0
- package/dist/types-ts4.5/rules/import/shared/perf.d.ts +13 -0
- package/dist/types-ts4.5/rules/import/shared/types.d.ts +131 -0
- package/package.json +4 -5
- package/dist/cjs/rules/ensure-feature-flag-prefix/index.js +0 -75
- package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +0 -158
- package/dist/es2019/rules/ensure-feature-flag-prefix/index.js +0 -65
- package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +0 -146
- package/dist/esm/rules/ensure-feature-flag-prefix/index.js +0 -69
- package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +0 -151
- /package/dist/types/rules/{ensure-native-and-af-exports-synced → feature-gating/valid-gate-name}/index.d.ts +0 -0
- /package/dist/types-ts4.5/rules/{ensure-feature-flag-prefix → feature-gating/valid-gate-name}/index.d.ts +0 -0
- /package/dist/types-ts4.5/rules/{ensure-native-and-af-exports-synced → import/no-conversation-assistant-barrel-imports}/index.d.ts +0 -0
- /package/dist/{types/rules/ensure-feature-flag-prefix → types-ts4.5/rules/prefer-crypto-random-uuid}/index.d.ts +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.extractImportPath = extractImportPath;
|
|
8
|
+
exports.findJestRequireMockCalls = findJestRequireMockCalls;
|
|
9
|
+
exports.isJestMockCall = isJestMockCall;
|
|
10
|
+
exports.isJestRequireActual = isJestRequireActual;
|
|
11
|
+
exports.isJestRequireMock = isJestRequireMock;
|
|
12
|
+
exports.resolveNewPathForRequireMock = resolveNewPathForRequireMock;
|
|
13
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
14
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
15
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
16
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
17
|
+
/**
|
|
18
|
+
* Shared utilities for jest.mock-related lint rules.
|
|
19
|
+
*
|
|
20
|
+
* These helpers are used by both `no-barrel-entry-jest-mock` (cross-package)
|
|
21
|
+
* and `no-jest-mock-barrel-files` (relative imports).
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Check if a CallExpression node is a jest.mock() call
|
|
26
|
+
*/
|
|
27
|
+
function isJestMockCall(node) {
|
|
28
|
+
var callee = node.callee;
|
|
29
|
+
if (callee.type === 'MemberExpression') {
|
|
30
|
+
return callee.object.type === 'Identifier' && callee.object.name === 'jest' && callee.property.type === 'Identifier' && callee.property.name === 'mock';
|
|
31
|
+
}
|
|
32
|
+
if (callee.type === 'Identifier') {
|
|
33
|
+
return callee.name === 'jest.mock';
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Check if a node is a jest.requireActual() call
|
|
40
|
+
*/
|
|
41
|
+
function isJestRequireActual(node) {
|
|
42
|
+
if (node.type !== 'CallExpression') {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
var callee = node.callee;
|
|
46
|
+
if (callee.type === 'MemberExpression') {
|
|
47
|
+
return callee.object.type === 'Identifier' && callee.object.name === 'jest' && callee.property.type === 'Identifier' && callee.property.name === 'requireActual';
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Check if a node is a jest.requireMock() call
|
|
54
|
+
*/
|
|
55
|
+
function isJestRequireMock(node) {
|
|
56
|
+
if (node.type !== 'CallExpression') {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
var callee = node.callee;
|
|
60
|
+
if (callee.type === 'MemberExpression') {
|
|
61
|
+
return callee.object.type === 'Identifier' && callee.object.name === 'jest' && callee.property.type === 'Identifier' && callee.property.name === 'requireMock';
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Extract the import path string from a jest.mock/jest.requireMock/jest.requireActual call's arguments.
|
|
68
|
+
* Returns null if the path cannot be statically determined.
|
|
69
|
+
*/
|
|
70
|
+
function extractImportPath(node) {
|
|
71
|
+
if (node.arguments.length === 0) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
var firstArg = node.arguments[0];
|
|
75
|
+
if (firstArg.type === 'Literal') {
|
|
76
|
+
return String(firstArg.value);
|
|
77
|
+
}
|
|
78
|
+
if (firstArg.type === 'TemplateLiteral' && firstArg.expressions.length === 0) {
|
|
79
|
+
return firstArg.quasis[0].value.raw;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Find all jest.requireMock() calls in the AST whose import path matches a given target.
|
|
86
|
+
*
|
|
87
|
+
* The `matchPath` callback allows callers to provide their own path-matching strategy:
|
|
88
|
+
* - Cross-package rules can use simple string equality
|
|
89
|
+
* - Relative import rules can use normalized/resolved path comparison
|
|
90
|
+
*/
|
|
91
|
+
function findJestRequireMockCalls(_ref) {
|
|
92
|
+
var ast = _ref.ast,
|
|
93
|
+
matchPath = _ref.matchPath;
|
|
94
|
+
var results = [];
|
|
95
|
+
var visited = new WeakSet();
|
|
96
|
+
var skipKeys = new Set(['parent', 'loc', 'range', 'tokens', 'comments']);
|
|
97
|
+
function visit(node) {
|
|
98
|
+
if (visited.has(node)) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
visited.add(node);
|
|
102
|
+
if (node.type === 'CallExpression' && isJestRequireMock(node)) {
|
|
103
|
+
var path = extractImportPath(node);
|
|
104
|
+
if (path && matchPath(path)) {
|
|
105
|
+
results.push(node);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
for (var key in node) {
|
|
109
|
+
if (skipKeys.has(key)) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
var value = node[key];
|
|
113
|
+
if (value && (0, _typeof2.default)(value) === 'object') {
|
|
114
|
+
if (Array.isArray(value)) {
|
|
115
|
+
var _iterator = _createForOfIteratorHelper(value),
|
|
116
|
+
_step;
|
|
117
|
+
try {
|
|
118
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
119
|
+
var child = _step.value;
|
|
120
|
+
if (child && (0, _typeof2.default)(child) === 'object' && 'type' in child) {
|
|
121
|
+
visit(child);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
} catch (err) {
|
|
125
|
+
_iterator.e(err);
|
|
126
|
+
} finally {
|
|
127
|
+
_iterator.f();
|
|
128
|
+
}
|
|
129
|
+
} else if ('type' in value) {
|
|
130
|
+
visit(value);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
visit(ast);
|
|
136
|
+
return results;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Determine the best new import path for a jest.requireMock() call by inspecting
|
|
141
|
+
* the destructured symbols or property access at the call site.
|
|
142
|
+
*
|
|
143
|
+
* @param requireMockNode - The jest.requireMock() CallExpression node
|
|
144
|
+
* @param symbolToNewPath - Map from symbol name to the new mock path that provides it
|
|
145
|
+
* @returns The resolved new path, or null if it cannot be determined
|
|
146
|
+
*/
|
|
147
|
+
function resolveNewPathForRequireMock(_ref2) {
|
|
148
|
+
var requireMockNode = _ref2.requireMockNode,
|
|
149
|
+
symbolToNewPath = _ref2.symbolToNewPath;
|
|
150
|
+
var parent = requireMockNode.parent;
|
|
151
|
+
if (parent) {
|
|
152
|
+
var _parent;
|
|
153
|
+
// Check for destructuring pattern: const { foo } = jest.requireMock('...')
|
|
154
|
+
var declarator = parent.type === 'VariableDeclarator' ? parent : ((_parent = parent.parent) === null || _parent === void 0 ? void 0 : _parent.type) === 'VariableDeclarator' ? parent.parent : null;
|
|
155
|
+
if (declarator && declarator.type === 'VariableDeclarator' && declarator.id.type === 'ObjectPattern') {
|
|
156
|
+
var _iterator2 = _createForOfIteratorHelper(declarator.id.properties),
|
|
157
|
+
_step2;
|
|
158
|
+
try {
|
|
159
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
160
|
+
var prop = _step2.value;
|
|
161
|
+
if (prop.type === 'Property' && prop.key.type === 'Identifier') {
|
|
162
|
+
var matchedPath = symbolToNewPath.get(prop.key.name);
|
|
163
|
+
if (matchedPath) {
|
|
164
|
+
return matchedPath;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
} catch (err) {
|
|
169
|
+
_iterator2.e(err);
|
|
170
|
+
} finally {
|
|
171
|
+
_iterator2.f();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Check for property access pattern: jest.requireMock('...').foo
|
|
176
|
+
if (parent.type === 'MemberExpression' && parent.property.type === 'Identifier') {
|
|
177
|
+
var _matchedPath = symbolToNewPath.get(parent.property.name);
|
|
178
|
+
if (_matchedPath) {
|
|
179
|
+
return _matchedPath;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Fallback: if only one new path exists, use it
|
|
185
|
+
var uniquePaths = new Set(symbolToNewPath.values());
|
|
186
|
+
if (uniquePaths.size === 1) {
|
|
187
|
+
var _uniquePaths$values$n;
|
|
188
|
+
return (_uniquePaths$values$n = uniquePaths.values().next().value) !== null && _uniquePaths$values$n !== void 0 ? _uniquePaths$values$n : null;
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findPackageInRegistry = findPackageInRegistry;
|
|
7
|
+
exports.isPackageInApplyToImportsFrom = isPackageInApplyToImportsFrom;
|
|
8
|
+
var _path = require("path");
|
|
9
|
+
var _fileSystem = require("./file-system");
|
|
10
|
+
var _perf = require("./perf");
|
|
11
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
12
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
13
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
|
+
/**
|
|
15
|
+
* The folder paths used for package resolution.
|
|
16
|
+
* All packages under these folders can be resolved regardless of applyToImportsFrom.
|
|
17
|
+
* applyToImportsFrom is only used to filter which packages the lint rules apply to.
|
|
18
|
+
*/
|
|
19
|
+
var PACKAGE_RESOLUTION_ROOTS = ['platform/packages'];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get yarn.lock modification time for cache invalidation.
|
|
23
|
+
* Returns 0 if yarn.lock doesn't exist.
|
|
24
|
+
*/
|
|
25
|
+
function getYarnLockMtime(_ref) {
|
|
26
|
+
var workspaceRoot = _ref.workspaceRoot,
|
|
27
|
+
fs = _ref.fs;
|
|
28
|
+
var yarnLockPath = (0, _path.join)(workspaceRoot, 'yarn.lock');
|
|
29
|
+
try {
|
|
30
|
+
if (fs.existsSync(yarnLockPath)) {
|
|
31
|
+
var _stats$mtimeMs;
|
|
32
|
+
var stats = fs.statSync(yarnLockPath);
|
|
33
|
+
return (_stats$mtimeMs = stats.mtimeMs) !== null && _stats$mtimeMs !== void 0 ? _stats$mtimeMs : 0;
|
|
34
|
+
}
|
|
35
|
+
} catch (_unused) {
|
|
36
|
+
// Ignore errors
|
|
37
|
+
}
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Check if the cache is valid for the given workspace root.
|
|
43
|
+
* Cache is invalid if:
|
|
44
|
+
* - The cache is not fully initialized
|
|
45
|
+
* - The workspace root has changed
|
|
46
|
+
* - The yarn.lock file has been modified
|
|
47
|
+
*/
|
|
48
|
+
function isCacheValid(_ref2) {
|
|
49
|
+
var cache = _ref2.cache,
|
|
50
|
+
workspaceRoot = _ref2.workspaceRoot,
|
|
51
|
+
fs = _ref2.fs;
|
|
52
|
+
// Cache is invalid if not initialized
|
|
53
|
+
if (!cache.packageNameToDir || !cache.scannedDirectories) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Cache is invalid if workspace root changed
|
|
58
|
+
if (cache.workspaceRoot !== workspaceRoot) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Cache is invalid if yarn.lock mtime changed
|
|
63
|
+
var currentMtime = getYarnLockMtime({
|
|
64
|
+
workspaceRoot: workspaceRoot,
|
|
65
|
+
fs: fs
|
|
66
|
+
});
|
|
67
|
+
return currentMtime === cache.yarnLockMtime;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Read package name from a package.json file.
|
|
72
|
+
* Returns null if the file doesn't exist or doesn't have a valid name.
|
|
73
|
+
*/
|
|
74
|
+
function readPackageName(_ref3) {
|
|
75
|
+
var packageJsonPath = _ref3.packageJsonPath,
|
|
76
|
+
fs = _ref3.fs;
|
|
77
|
+
try {
|
|
78
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
var content = fs.readFileSync(packageJsonPath, 'utf-8');
|
|
82
|
+
var pkg = JSON.parse(content);
|
|
83
|
+
if (pkg.name && typeof pkg.name === 'string') {
|
|
84
|
+
return pkg.name;
|
|
85
|
+
}
|
|
86
|
+
} catch (_unused2) {
|
|
87
|
+
// Ignore errors (invalid JSON, etc.)
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Recursively scan a directory for packages and update the cache.
|
|
94
|
+
* Directories are cached (including those without packages) to avoid re-scanning.
|
|
95
|
+
*
|
|
96
|
+
* Once a package.json is found, subdirectories are not scanned since packages
|
|
97
|
+
* don't contain nested packages. The exception is target folder roots (e.g., 'platform')
|
|
98
|
+
* which may have a package.json but still contain packages in subdirectories.
|
|
99
|
+
*/
|
|
100
|
+
function scanDirectoryForPackages(_ref4) {
|
|
101
|
+
var dir = _ref4.dir,
|
|
102
|
+
cache = _ref4.cache,
|
|
103
|
+
fs = _ref4.fs,
|
|
104
|
+
_ref4$isTargetRoot = _ref4.isTargetRoot,
|
|
105
|
+
isTargetRoot = _ref4$isTargetRoot === void 0 ? false : _ref4$isTargetRoot,
|
|
106
|
+
nestedTargetRoots = _ref4.nestedTargetRoots;
|
|
107
|
+
// Skip if already scanned
|
|
108
|
+
if (cache.scannedDirectories.has(dir)) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Mark as scanned (even if it doesn't contain a package)
|
|
113
|
+
cache.scannedDirectories.add(dir);
|
|
114
|
+
try {
|
|
115
|
+
// Check for package.json in current directory
|
|
116
|
+
var packageJsonPath = (0, _path.join)(dir, 'package.json');
|
|
117
|
+
var packageName = readPackageName({
|
|
118
|
+
packageJsonPath: packageJsonPath,
|
|
119
|
+
fs: fs
|
|
120
|
+
});
|
|
121
|
+
if (packageName) {
|
|
122
|
+
cache.packageNameToDir.set(packageName, dir);
|
|
123
|
+
// Don't scan subdirectories - packages don't contain nested packages
|
|
124
|
+
// Exception: target folder roots (e.g., 'platform') may have packages in subdirectories
|
|
125
|
+
if (!isTargetRoot) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Recursively scan subdirectories
|
|
131
|
+
var entries = fs.readdirSync(dir, {
|
|
132
|
+
withFileTypes: true
|
|
133
|
+
});
|
|
134
|
+
var _iterator = _createForOfIteratorHelper(entries),
|
|
135
|
+
_step;
|
|
136
|
+
try {
|
|
137
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
138
|
+
var entry = _step.value;
|
|
139
|
+
// Skip node_modules, hidden directories, and non-directories
|
|
140
|
+
if (!entry.isDirectory() || entry.name === 'node_modules' || entry.name.startsWith('.')) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
scanDirectoryForPackages({
|
|
144
|
+
dir: (0, _path.join)(dir, entry.name),
|
|
145
|
+
cache: cache,
|
|
146
|
+
fs: fs,
|
|
147
|
+
// Only certain directory levels are treated as "target roots"
|
|
148
|
+
isTargetRoot: nestedTargetRoots.has(dir),
|
|
149
|
+
nestedTargetRoots: nestedTargetRoots
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
} catch (err) {
|
|
153
|
+
_iterator.e(err);
|
|
154
|
+
} finally {
|
|
155
|
+
_iterator.f();
|
|
156
|
+
}
|
|
157
|
+
} catch (_unused3) {
|
|
158
|
+
// Directory doesn't exist or not readable, skip
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Ensure all packages under platform/packages have been scanned.
|
|
164
|
+
* Initializes or updates the cache on fs.cache as needed.
|
|
165
|
+
* Package resolution is not constrained by applyToImportsFrom - any package can be resolved.
|
|
166
|
+
*/
|
|
167
|
+
function ensureCachePopulated(_ref5) {
|
|
168
|
+
var workspaceRoot = _ref5.workspaceRoot,
|
|
169
|
+
fs = _ref5.fs;
|
|
170
|
+
// Check if cache is still valid
|
|
171
|
+
if (isCacheValid({
|
|
172
|
+
cache: fs.cache,
|
|
173
|
+
workspaceRoot: workspaceRoot,
|
|
174
|
+
fs: fs
|
|
175
|
+
})) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
(0, _perf.perfInc)({
|
|
179
|
+
fs: fs,
|
|
180
|
+
key: 'packageRegistry.rebuild'
|
|
181
|
+
});
|
|
182
|
+
return (0, _perf.perfTime)({
|
|
183
|
+
fs: fs,
|
|
184
|
+
key: 'packageRegistry.rebuildMs',
|
|
185
|
+
fn: function fn() {
|
|
186
|
+
// Initialize fresh cache
|
|
187
|
+
fs.cache.packageNameToDir = new Map();
|
|
188
|
+
fs.cache.scannedDirectories = new Set();
|
|
189
|
+
fs.cache.yarnLockMtime = getYarnLockMtime({
|
|
190
|
+
workspaceRoot: workspaceRoot,
|
|
191
|
+
fs: fs
|
|
192
|
+
});
|
|
193
|
+
fs.cache.workspaceRoot = workspaceRoot;
|
|
194
|
+
// When the workspace graph changes, clear derived caches as well
|
|
195
|
+
fs.cache.packageExportsByDir = new Map();
|
|
196
|
+
|
|
197
|
+
// Scan all packages under the resolution roots
|
|
198
|
+
// This is not constrained by applyToImportsFrom - any package can be resolved
|
|
199
|
+
// The immediate children of each root (e.g., ai-mate, search) are treated as
|
|
200
|
+
// "nested target roots" - they may have a package.json but still contain nested packages
|
|
201
|
+
var _iterator2 = _createForOfIteratorHelper(PACKAGE_RESOLUTION_ROOTS),
|
|
202
|
+
_step2;
|
|
203
|
+
try {
|
|
204
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
205
|
+
var resolutionRoot = _step2.value;
|
|
206
|
+
var targetPath = (0, _path.join)(workspaceRoot, resolutionRoot);
|
|
207
|
+
scanDirectoryForPackages({
|
|
208
|
+
dir: targetPath,
|
|
209
|
+
cache: fs.cache,
|
|
210
|
+
fs: fs,
|
|
211
|
+
isTargetRoot: true,
|
|
212
|
+
nestedTargetRoots: new Set([targetPath])
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
} catch (err) {
|
|
216
|
+
_iterator2.e(err);
|
|
217
|
+
} finally {
|
|
218
|
+
_iterator2.f();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Find the package directory for a given package name.
|
|
226
|
+
* Returns the absolute path to the package directory or null if not found.
|
|
227
|
+
*
|
|
228
|
+
* This function uses lazy scanning - it will scan platform/packages on first lookup
|
|
229
|
+
* and cache results in fs.cache for subsequent lookups.
|
|
230
|
+
*
|
|
231
|
+
* Note: Package resolution is NOT constrained by applyToImportsFrom. Any package under
|
|
232
|
+
* platform/packages can be resolved. Use isPackageInApplyToImportsFrom to check if a
|
|
233
|
+
* package should be processed by the lint rule.
|
|
234
|
+
*/
|
|
235
|
+
function findPackageInRegistry(_ref6) {
|
|
236
|
+
var _fs$cache$packageName, _fs$cache$packageName2;
|
|
237
|
+
var packageName = _ref6.packageName,
|
|
238
|
+
workspaceRoot = _ref6.workspaceRoot,
|
|
239
|
+
fs = _ref6.fs;
|
|
240
|
+
// Ensure cache is populated
|
|
241
|
+
ensureCachePopulated({
|
|
242
|
+
workspaceRoot: workspaceRoot,
|
|
243
|
+
fs: fs
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// Look up the package
|
|
247
|
+
return (_fs$cache$packageName = (_fs$cache$packageName2 = fs.cache.packageNameToDir) === null || _fs$cache$packageName2 === void 0 ? void 0 : _fs$cache$packageName2.get(packageName)) !== null && _fs$cache$packageName !== void 0 ? _fs$cache$packageName : null;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Check if a package is within one of the applyToImportsFrom folders.
|
|
252
|
+
* This can be used to quickly filter out packages that shouldn't be checked.
|
|
253
|
+
*/
|
|
254
|
+
function isPackageInApplyToImportsFrom(_ref7) {
|
|
255
|
+
var packageDir = _ref7.packageDir,
|
|
256
|
+
workspaceRoot = _ref7.workspaceRoot,
|
|
257
|
+
_ref7$applyToImportsF = _ref7.applyToImportsFrom,
|
|
258
|
+
applyToImportsFrom = _ref7$applyToImportsF === void 0 ? _fileSystem.DEFAULT_TARGET_FOLDERS : _ref7$applyToImportsF;
|
|
259
|
+
return applyToImportsFrom.some(function (folder) {
|
|
260
|
+
var targetPath = (0, _path.join)(workspaceRoot, folder);
|
|
261
|
+
return packageDir.startsWith(targetPath);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.extractPackageNameFromImport = extractPackageNameFromImport;
|
|
8
|
+
exports.findExportForSourceFile = findExportForSourceFile;
|
|
9
|
+
exports.parsePackageExports = parsePackageExports;
|
|
10
|
+
exports.resolveCrossPackageImport = resolveCrossPackageImport;
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
+
var _path = require("path");
|
|
14
|
+
var _fileSystem = require("./file-system");
|
|
15
|
+
var _packageRegistry = require("./package-registry");
|
|
16
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
17
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
18
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
19
|
+
/**
|
|
20
|
+
* Parse the package.json exports field and return a map of export paths to resolved file paths.
|
|
21
|
+
*/
|
|
22
|
+
function parsePackageExports(_ref) {
|
|
23
|
+
var packageDir = _ref.packageDir,
|
|
24
|
+
fs = _ref.fs;
|
|
25
|
+
// Memoize per-package to avoid repeated reads/parses during IDE lint runs.
|
|
26
|
+
// Additionally, invalidate per-package if the package.json mtime changes
|
|
27
|
+
// (covers unstaged local edits in IDE).
|
|
28
|
+
if (!fs.cache.packageExportsByDir) {
|
|
29
|
+
fs.cache.packageExportsByDir = new Map();
|
|
30
|
+
}
|
|
31
|
+
var packageJsonPath = (0, _path.join)(packageDir, 'package.json');
|
|
32
|
+
var currentMtimeMs = null;
|
|
33
|
+
try {
|
|
34
|
+
var _fs$statSync$mtimeMs;
|
|
35
|
+
currentMtimeMs = (_fs$statSync$mtimeMs = fs.statSync(packageJsonPath).mtimeMs) !== null && _fs$statSync$mtimeMs !== void 0 ? _fs$statSync$mtimeMs : null;
|
|
36
|
+
} catch (_unused) {
|
|
37
|
+
// If package.json can't be stat'ed (missing/inaccessible), use null to force re-read
|
|
38
|
+
currentMtimeMs = null;
|
|
39
|
+
}
|
|
40
|
+
var cached = fs.cache.packageExportsByDir.get(packageDir);
|
|
41
|
+
// Only use cache if we have a valid mtime and it matches
|
|
42
|
+
if (cached && currentMtimeMs !== null && cached.packageJsonMtimeMs === currentMtimeMs) {
|
|
43
|
+
return cached.exportsMap;
|
|
44
|
+
}
|
|
45
|
+
var exportsMap = new Map();
|
|
46
|
+
try {
|
|
47
|
+
var content = (0, _fileSystem.readFileContent)({
|
|
48
|
+
filePath: packageJsonPath,
|
|
49
|
+
fs: fs
|
|
50
|
+
});
|
|
51
|
+
if (!content) {
|
|
52
|
+
return exportsMap;
|
|
53
|
+
}
|
|
54
|
+
var packageJson = JSON.parse(content);
|
|
55
|
+
var exports = packageJson.exports;
|
|
56
|
+
if (!exports || (0, _typeof2.default)(exports) !== 'object') {
|
|
57
|
+
return exportsMap;
|
|
58
|
+
}
|
|
59
|
+
for (var _i = 0, _Object$entries = Object.entries(exports); _i < _Object$entries.length; _i++) {
|
|
60
|
+
var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
|
|
61
|
+
exportPath = _Object$entries$_i[0],
|
|
62
|
+
exportValue = _Object$entries$_i[1];
|
|
63
|
+
// Handle both simple string values and conditional exports objects
|
|
64
|
+
var resolvedPath = null;
|
|
65
|
+
if (typeof exportValue === 'string') {
|
|
66
|
+
resolvedPath = exportValue;
|
|
67
|
+
} else if ((0, _typeof2.default)(exportValue) === 'object' && exportValue !== null) {
|
|
68
|
+
// Handle conditional exports like { "import": "./...", "require": "./..." }
|
|
69
|
+
// Prefer "import" or "default" or first available
|
|
70
|
+
var condExports = exportValue;
|
|
71
|
+
resolvedPath = condExports['import'] || condExports['default'] || Object.values(condExports)[0];
|
|
72
|
+
}
|
|
73
|
+
if (resolvedPath && typeof resolvedPath === 'string') {
|
|
74
|
+
// Resolve the path relative to the package directory
|
|
75
|
+
var absolutePath = (0, _fileSystem.resolveImportPath)({
|
|
76
|
+
basedir: packageDir,
|
|
77
|
+
importPath: resolvedPath,
|
|
78
|
+
fs: fs
|
|
79
|
+
});
|
|
80
|
+
if (absolutePath) {
|
|
81
|
+
exportsMap.set(exportPath, absolutePath);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} catch (_unused2) {
|
|
86
|
+
// Ignore parsing errors
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Cache even empty maps to avoid re-reading invalid/missing exports repeatedly.
|
|
90
|
+
fs.cache.packageExportsByDir.set(packageDir, {
|
|
91
|
+
packageJsonMtimeMs: currentMtimeMs,
|
|
92
|
+
exportsMap: exportsMap
|
|
93
|
+
});
|
|
94
|
+
return exportsMap;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Find a matching export entry for a given source file path.
|
|
99
|
+
* Returns the export path (e.g., "./controllers/analytics") or null if not found.
|
|
100
|
+
*/
|
|
101
|
+
function findExportForSourceFile(_ref2) {
|
|
102
|
+
var sourceFilePath = _ref2.sourceFilePath,
|
|
103
|
+
exportsMap = _ref2.exportsMap;
|
|
104
|
+
var _iterator = _createForOfIteratorHelper(exportsMap),
|
|
105
|
+
_step;
|
|
106
|
+
try {
|
|
107
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
108
|
+
var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
|
|
109
|
+
exportPath = _step$value[0],
|
|
110
|
+
resolvedPath = _step$value[1];
|
|
111
|
+
if (resolvedPath === sourceFilePath) {
|
|
112
|
+
return exportPath;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} catch (err) {
|
|
116
|
+
_iterator.e(err);
|
|
117
|
+
} finally {
|
|
118
|
+
_iterator.f();
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Extract the package name and subpath from an import specifier.
|
|
125
|
+
* Returns null if the import is not a scoped package import.
|
|
126
|
+
*/
|
|
127
|
+
function extractPackageNameFromImport(moduleSpecifier) {
|
|
128
|
+
var match = moduleSpecifier.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);
|
|
129
|
+
if (!match) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
packageName: match[1],
|
|
134
|
+
subPath: match[2] || ''
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Resolve a cross-package import to its package directory and export info.
|
|
140
|
+
* Returns null if the package is not in the target folder or cannot be resolved.
|
|
141
|
+
*/
|
|
142
|
+
function resolveCrossPackageImport(_ref3) {
|
|
143
|
+
var moduleSpecifier = _ref3.moduleSpecifier,
|
|
144
|
+
workspaceRoot = _ref3.workspaceRoot,
|
|
145
|
+
fs = _ref3.fs;
|
|
146
|
+
// Only handle @atlassian/* scoped packages
|
|
147
|
+
var parsed = extractPackageNameFromImport(moduleSpecifier);
|
|
148
|
+
if (!parsed) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
var packageName = parsed.packageName,
|
|
152
|
+
subPath = parsed.subPath;
|
|
153
|
+
|
|
154
|
+
// Check if package is in target folder
|
|
155
|
+
var packageDir = (0, _packageRegistry.findPackageInRegistry)({
|
|
156
|
+
packageName: packageName,
|
|
157
|
+
workspaceRoot: workspaceRoot,
|
|
158
|
+
fs: fs
|
|
159
|
+
});
|
|
160
|
+
if (!packageDir) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Parse package.json exports
|
|
165
|
+
var exportsMap = parsePackageExports({
|
|
166
|
+
packageDir: packageDir,
|
|
167
|
+
fs: fs
|
|
168
|
+
});
|
|
169
|
+
if (exportsMap.size === 0) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Determine the export path (e.g., '.' or './utils')
|
|
174
|
+
var exportPath = subPath ? '.' + subPath : '.';
|
|
175
|
+
var entryFilePath = exportsMap.get(exportPath);
|
|
176
|
+
if (!entryFilePath) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
packageName: packageName,
|
|
181
|
+
packageDir: packageDir,
|
|
182
|
+
exportPath: exportPath,
|
|
183
|
+
entryFilePath: entryFilePath
|
|
184
|
+
};
|
|
185
|
+
}
|