eslint-plugin-fast-import 1.0.0-beta2
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/.prettierrc.json +6 -0
- package/.vscode/launch.json +39 -0
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/module/computeAnalyzedInfo.d.ts +3 -0
- package/dist/module/computeAnalyzedInfo.js +297 -0
- package/dist/module/computeAnalyzedInfo.js.map +1 -0
- package/dist/module/computeBaseInfo.d.ts +24 -0
- package/dist/module/computeBaseInfo.js +564 -0
- package/dist/module/computeBaseInfo.js.map +1 -0
- package/dist/module/computeResolvedInfo.d.ts +7 -0
- package/dist/module/computeResolvedInfo.js +361 -0
- package/dist/module/computeResolvedInfo.js.map +1 -0
- package/dist/module/module.d.ts +20 -0
- package/dist/module/module.js +224 -0
- package/dist/module/module.js.map +1 -0
- package/dist/module/util.d.ts +44 -0
- package/dist/module/util.js +67 -0
- package/dist/module/util.js.map +1 -0
- package/dist/plugin.d.ts +19 -0
- package/dist/plugin.js +57 -0
- package/dist/plugin.js.map +1 -0
- package/dist/rules/circular/circular.d.ts +2 -0
- package/dist/rules/circular/circular.js +107 -0
- package/dist/rules/circular/circular.js.map +1 -0
- package/dist/rules/entryPoint/entryPoint.d.ts +1 -0
- package/dist/rules/entryPoint/entryPoint.js +38 -0
- package/dist/rules/entryPoint/entryPoint.js.map +1 -0
- package/dist/rules/externalBarrelReexports/externalBarrelReexports.d.ts +1 -0
- package/dist/rules/externalBarrelReexports/externalBarrelReexports.js +41 -0
- package/dist/rules/externalBarrelReexports/externalBarrelReexports.js.map +1 -0
- package/dist/rules/missing/missing.d.ts +1 -0
- package/dist/rules/missing/missing.js +59 -0
- package/dist/rules/missing/missing.js.map +1 -0
- package/dist/rules/testInProd/testInProd.d.ts +1 -0
- package/dist/rules/testInProd/testInProd.js +42 -0
- package/dist/rules/testInProd/testInProd.js.map +1 -0
- package/dist/rules/unused/unused.d.ts +3 -0
- package/dist/rules/unused/unused.js +77 -0
- package/dist/rules/unused/unused.js.map +1 -0
- package/dist/rules/util.d.ts +11 -0
- package/dist/rules/util.js +107 -0
- package/dist/rules/util.js.map +1 -0
- package/dist/settings/settings.d.ts +12 -0
- package/dist/settings/settings.js +123 -0
- package/dist/settings/settings.js.map +1 -0
- package/dist/settings/typescript.d.ts +3 -0
- package/dist/settings/typescript.js +39 -0
- package/dist/settings/typescript.js.map +1 -0
- package/dist/settings/user.d.ts +45 -0
- package/dist/settings/user.js +52 -0
- package/dist/settings/user.js.map +1 -0
- package/dist/settings/util.d.ts +2 -0
- package/dist/settings/util.js +33 -0
- package/dist/settings/util.js.map +1 -0
- package/dist/types/analyzed.d.ts +120 -0
- package/dist/types/analyzed.js +2 -0
- package/dist/types/analyzed.js.map +1 -0
- package/dist/types/base.d.ts +230 -0
- package/dist/types/base.js +2 -0
- package/dist/types/base.js.map +1 -0
- package/dist/types/context.d.ts +2 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/resolved.d.ts +60 -0
- package/dist/types/resolved.js +2 -0
- package/dist/types/resolved.js.map +1 -0
- package/dist/util/code.d.ts +1 -0
- package/dist/util/code.js +6 -0
- package/dist/util/code.js.map +1 -0
- package/dist/util/error.d.ts +14 -0
- package/dist/util/error.js +19 -0
- package/dist/util/error.js.map +1 -0
- package/dist/util/files.d.ts +10 -0
- package/dist/util/files.js +122 -0
- package/dist/util/files.js.map +1 -0
- package/dist/util/logging.d.ts +5 -0
- package/dist/util/logging.js +19 -0
- package/dist/util/logging.js.map +1 -0
- package/eslint.config.mjs +85 -0
- package/jest.config.ts +10 -0
- package/package.json +49 -0
- package/tsconfig.json +31 -0
package/.prettierrc.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Debug Jest Tests",
|
|
9
|
+
"type": "node",
|
|
10
|
+
"request": "launch",
|
|
11
|
+
"runtimeArgs": [
|
|
12
|
+
"--inspect-brk",
|
|
13
|
+
"${workspaceRoot}/node_modules/.bin/jest",
|
|
14
|
+
"--runInBand"
|
|
15
|
+
],
|
|
16
|
+
"args": [
|
|
17
|
+
"src/**/*"
|
|
18
|
+
],
|
|
19
|
+
"console": "integratedTerminal",
|
|
20
|
+
"internalConsoleOptions": "neverOpen"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Debug ESLint",
|
|
24
|
+
"type": "node",
|
|
25
|
+
"request": "launch",
|
|
26
|
+
"runtimeArgs": [
|
|
27
|
+
"--inspect",
|
|
28
|
+
"${workspaceRoot}/node_modules/.bin/eslint"
|
|
29
|
+
],
|
|
30
|
+
"args": [
|
|
31
|
+
"-c",
|
|
32
|
+
"eslint.config.mjs",
|
|
33
|
+
"src/**/*"
|
|
34
|
+
],
|
|
35
|
+
"console": "integratedTerminal",
|
|
36
|
+
"internalConsoleOptions": "neverOpen"
|
|
37
|
+
},
|
|
38
|
+
]
|
|
39
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Bryan Hughes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { InternalError } from '../util/error.js';
|
|
2
|
+
export function computeAnalyzedInfo(resolvedProjectInfo) {
|
|
3
|
+
const analyzedProjectInfo = {
|
|
4
|
+
...resolvedProjectInfo,
|
|
5
|
+
files: new Map(),
|
|
6
|
+
};
|
|
7
|
+
// First we initialize each detail with placeholder data, since we need a completely initialized `analyzedInfo` object
|
|
8
|
+
// available before we can start traversing/populating analyzed info
|
|
9
|
+
for (const [filePath, fileDetails] of resolvedProjectInfo.files) {
|
|
10
|
+
if (fileDetails.fileType !== 'code') {
|
|
11
|
+
analyzedProjectInfo.files.set(filePath, {
|
|
12
|
+
fileType: 'other',
|
|
13
|
+
});
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const analyzedFileInfo = {
|
|
17
|
+
fileType: 'code',
|
|
18
|
+
lastUpdatedAt: fileDetails.lastUpdatedAt,
|
|
19
|
+
imports: [],
|
|
20
|
+
exports: [],
|
|
21
|
+
reexports: [],
|
|
22
|
+
};
|
|
23
|
+
analyzedProjectInfo.files.set(filePath, analyzedFileInfo);
|
|
24
|
+
for (const exportDetails of fileDetails.exports) {
|
|
25
|
+
analyzedFileInfo.exports.push({
|
|
26
|
+
...exportDetails,
|
|
27
|
+
importedByFiles: [],
|
|
28
|
+
barrelImportedByFiles: [],
|
|
29
|
+
reexportedByFiles: [],
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
for (const reexportDetails of fileDetails.reexports) {
|
|
33
|
+
switch (reexportDetails.reexportType) {
|
|
34
|
+
case 'single': {
|
|
35
|
+
analyzedFileInfo.reexports.push({
|
|
36
|
+
...reexportDetails,
|
|
37
|
+
// If this reexport is a builtin or thirdparty reexport, we know what the root module type is. However, if
|
|
38
|
+
// it's first party then we don't know what the type is yet. In this case, once we determine the type we'll
|
|
39
|
+
// change this value and potentially fill in other details
|
|
40
|
+
rootModuleType: reexportDetails.moduleType === 'builtin' ||
|
|
41
|
+
reexportDetails.moduleType === 'thirdParty'
|
|
42
|
+
? reexportDetails.moduleType
|
|
43
|
+
: undefined,
|
|
44
|
+
importedByFiles: [],
|
|
45
|
+
barrelImportedByFiles: [],
|
|
46
|
+
});
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case 'barrel': {
|
|
50
|
+
analyzedFileInfo.reexports.push({
|
|
51
|
+
...reexportDetails,
|
|
52
|
+
importedByFiles: [],
|
|
53
|
+
barrelImportedByFiles: [],
|
|
54
|
+
});
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
for (const importDetails of fileDetails.imports) {
|
|
60
|
+
switch (importDetails.importType) {
|
|
61
|
+
case 'single': {
|
|
62
|
+
analyzedFileInfo.imports.push({
|
|
63
|
+
...importDetails,
|
|
64
|
+
// We don't know what the type is yet, but once we determine the type we'll change this value and
|
|
65
|
+
// potentially fill in other details
|
|
66
|
+
rootModuleType: undefined,
|
|
67
|
+
});
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case 'barrel':
|
|
71
|
+
case 'dynamic': {
|
|
72
|
+
analyzedFileInfo.imports.push({
|
|
73
|
+
...importDetails,
|
|
74
|
+
});
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Now that we have placeholder values for each entry, we're ready to analyze/traverse the tree
|
|
81
|
+
for (const [filePath, fileDetails] of analyzedProjectInfo.files) {
|
|
82
|
+
// Nothing to do if this isn't a code file
|
|
83
|
+
if (fileDetails.fileType !== 'code') {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
for (const importDetails of fileDetails.imports) {
|
|
87
|
+
if (importDetails.importType === 'single') {
|
|
88
|
+
analyzeSingleImport(filePath, importDetails, analyzedProjectInfo, 'single', []);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
analyzeBarrelImport(filePath, importDetails, analyzedProjectInfo, 'barrel', []);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Now, treat reexports that are also entry points as an import, so that we can mark the relevant exports they point
|
|
95
|
+
// to as being imported too (since in reality they are)
|
|
96
|
+
for (const reexportDetails of fileDetails.reexports) {
|
|
97
|
+
if (!reexportDetails.isEntryPoint) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (reexportDetails.reexportType === 'single') {
|
|
101
|
+
analyzeSingleImport(filePath, reexportDetails, analyzedProjectInfo, 'single', []);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
analyzeBarrelImport(filePath, reexportDetails, analyzedProjectInfo, 'barrel', []);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return analyzedProjectInfo;
|
|
109
|
+
}
|
|
110
|
+
function analyzeSingleImport(originFilePath, originAnalyzedImport, analyzedProjectInfo, initialImportType,
|
|
111
|
+
// Represents files with reexports found between the origin import and root export
|
|
112
|
+
reexportFiles) {
|
|
113
|
+
if (originAnalyzedImport.moduleType !== 'firstPartyCode') {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
// Return value indicates if we've found the root export yet or not
|
|
117
|
+
function traverse(currentFile, currentImportName) {
|
|
118
|
+
// Get the file from the project info
|
|
119
|
+
const targetFileDetails = analyzedProjectInfo.files.get(currentFile);
|
|
120
|
+
if (!targetFileDetails) {
|
|
121
|
+
throw new InternalError(`File ${currentFile} is missing in project info`, {
|
|
122
|
+
filePath: originFilePath,
|
|
123
|
+
node: originAnalyzedImport.statementNode,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
// Shouldn't happen in practice, but check anyways to make TypeScript happy, plus "shouldn't happen" has a funny way
|
|
127
|
+
// of coming true sometimes
|
|
128
|
+
if (targetFileDetails.fileType !== 'code') {
|
|
129
|
+
throw new InternalError(`moduleType on consumer of ${currentFile} is "code", but file type is "${targetFileDetails.fileType}"`, {
|
|
130
|
+
filePath: originFilePath,
|
|
131
|
+
node: originAnalyzedImport.statementNode,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
// First, check if we've found the root export
|
|
135
|
+
const exportEntry = targetFileDetails.exports.find((e) => currentImportName === e.exportName);
|
|
136
|
+
if (exportEntry?.exportName === currentImportName) {
|
|
137
|
+
// Set the consumers of the export
|
|
138
|
+
exportEntry.importedByFiles.push(originFilePath);
|
|
139
|
+
exportEntry.reexportedByFiles.push(...reexportFiles);
|
|
140
|
+
// Set the root info
|
|
141
|
+
const rootModuleInfo = {
|
|
142
|
+
rootModuleType: 'firstPartyCode',
|
|
143
|
+
rootModulePath: currentFile,
|
|
144
|
+
rootExportName: exportEntry.exportName,
|
|
145
|
+
rootExportType: 'export',
|
|
146
|
+
};
|
|
147
|
+
return rootModuleInfo;
|
|
148
|
+
}
|
|
149
|
+
// Next, check if there is a single re-export that matches
|
|
150
|
+
const singleReexportEntry = targetFileDetails.reexports.find((r) => r.reexportType === 'single' && r.exportName === currentImportName);
|
|
151
|
+
if (singleReexportEntry) {
|
|
152
|
+
switch (singleReexportEntry.moduleType) {
|
|
153
|
+
case 'builtin':
|
|
154
|
+
case 'thirdParty': {
|
|
155
|
+
return {
|
|
156
|
+
rootModuleType: singleReexportEntry.moduleType,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
case 'firstPartyOther': {
|
|
160
|
+
const rootModuleInfo = {
|
|
161
|
+
rootModuleType: 'firstPartyOther',
|
|
162
|
+
rootModulePath: currentFile,
|
|
163
|
+
};
|
|
164
|
+
Object.assign(singleReexportEntry, rootModuleInfo);
|
|
165
|
+
return rootModuleInfo;
|
|
166
|
+
}
|
|
167
|
+
case 'firstPartyCode': {
|
|
168
|
+
if (!reexportFiles.includes(currentFile)) {
|
|
169
|
+
reexportFiles.push(currentFile);
|
|
170
|
+
}
|
|
171
|
+
singleReexportEntry.importedByFiles.push(originFilePath);
|
|
172
|
+
const rootModuleInfo = traverse(singleReexportEntry.resolvedModulePath, singleReexportEntry.importName);
|
|
173
|
+
if (rootModuleInfo) {
|
|
174
|
+
Object.assign(singleReexportEntry, rootModuleInfo);
|
|
175
|
+
}
|
|
176
|
+
return rootModuleInfo;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// Now check if there's a named barrel export that matches
|
|
181
|
+
const barrelReexportEntry = targetFileDetails.reexports.find((r) => r.reexportType === 'barrel' && r.exportName === currentImportName);
|
|
182
|
+
if (barrelReexportEntry) {
|
|
183
|
+
if (barrelReexportEntry.moduleType === 'firstPartyCode') {
|
|
184
|
+
if (initialImportType === 'single' && barrelReexportEntry.exportName) {
|
|
185
|
+
return {
|
|
186
|
+
rootModuleType: 'firstPartyCode',
|
|
187
|
+
rootModulePath: currentFile,
|
|
188
|
+
rootExportName: barrelReexportEntry.exportName,
|
|
189
|
+
rootExportType: 'namedBarrelReexport',
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
analyzeBarrelImport(originFilePath, barrelReexportEntry, analyzedProjectInfo, initialImportType, reexportFiles);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
if (initialImportType === 'single') {
|
|
196
|
+
if (barrelReexportEntry.moduleType === 'firstPartyOther') {
|
|
197
|
+
if (!barrelReexportEntry.resolvedModulePath) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
rootModuleType: 'firstPartyOther',
|
|
202
|
+
rootModulePath: barrelReexportEntry.resolvedModulePath,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
rootModuleType: barrelReexportEntry.moduleType,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
// This is an edge case that we just can't handle, so we pretend we didn't find it. This happens when we have:
|
|
210
|
+
//
|
|
211
|
+
// // foo.ts
|
|
212
|
+
// import { join } from './bar';
|
|
213
|
+
//
|
|
214
|
+
// // bar.ts
|
|
215
|
+
// export * from 'node:path';
|
|
216
|
+
// export * from 'node:url';
|
|
217
|
+
//
|
|
218
|
+
// Since we don't know the names of what's exported from third party/builtin modules, we can't actually know
|
|
219
|
+
// which module `join` came from
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// Finally, check and traverse all barrel re-exports. Since we don't know what barrel exports contain yet, we have
|
|
224
|
+
// to traverse all of them in a depth-first search
|
|
225
|
+
for (const reexportEntry of targetFileDetails.reexports) {
|
|
226
|
+
// Technically speaking, it's possible for the root export to exist here if, say, someone did something stupid
|
|
227
|
+
// like `import { join } from './foo'` coupled with `export * from 'node:path'`. That's really bad coding though
|
|
228
|
+
// so we're not going to support it here
|
|
229
|
+
if (reexportEntry.moduleType !== 'firstPartyCode' ||
|
|
230
|
+
reexportEntry.reexportType !== 'barrel') {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
// If we found the root export, bail early
|
|
234
|
+
const rootModuleInfo = traverse(reexportEntry.resolvedModulePath, currentImportName);
|
|
235
|
+
if (rootModuleInfo) {
|
|
236
|
+
reexportEntry.importedByFiles.push(originFilePath);
|
|
237
|
+
return rootModuleInfo;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// Finally, if we got here, we couldn't resolve the root export
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
const rootModuleInfo = traverse(originAnalyzedImport.resolvedModulePath, originAnalyzedImport.importName);
|
|
244
|
+
if (rootModuleInfo) {
|
|
245
|
+
Object.assign(originAnalyzedImport, rootModuleInfo);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function analyzeBarrelImport(originFilePath, originAnalyzedImport, analyzedProjectInfo, initialImportType,
|
|
249
|
+
// Represents files with reexports found between the origin import and root export
|
|
250
|
+
reexportFiles) {
|
|
251
|
+
if (originAnalyzedImport.moduleType !== 'firstPartyCode') {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
function traverse(currentFile) {
|
|
255
|
+
// Get the file from the project info
|
|
256
|
+
const targetFileDetails = analyzedProjectInfo.files.get(currentFile);
|
|
257
|
+
if (!targetFileDetails) {
|
|
258
|
+
throw new InternalError(`File ${currentFile} is missing in project info`, {
|
|
259
|
+
filePath: originFilePath,
|
|
260
|
+
node: originAnalyzedImport.statementNode,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
// Shouldn't happen in practice, but check anyways to make TypeScript happy, plus "shouldn't happen" has a funny way
|
|
264
|
+
// of coming true sometimes
|
|
265
|
+
if (targetFileDetails.fileType !== 'code') {
|
|
266
|
+
throw new InternalError(`moduleType on consumer of ${currentFile} is "code", but file type is "${targetFileDetails.fileType}"`, {
|
|
267
|
+
filePath: originFilePath,
|
|
268
|
+
node: originAnalyzedImport.statementNode,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
// First, mark each export as being barrel imported
|
|
272
|
+
for (const exportEntry of targetFileDetails.exports) {
|
|
273
|
+
exportEntry.barrelImportedByFiles.push(originFilePath);
|
|
274
|
+
exportEntry.reexportedByFiles.push(...reexportFiles);
|
|
275
|
+
}
|
|
276
|
+
// Now go through reexports and traverse them further)
|
|
277
|
+
for (const reexportEntry of targetFileDetails.reexports) {
|
|
278
|
+
// Nothing to do in non-first party code
|
|
279
|
+
if (reexportEntry.moduleType !== 'firstPartyCode') {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (!reexportFiles.includes(currentFile)) {
|
|
283
|
+
reexportFiles.push(currentFile);
|
|
284
|
+
}
|
|
285
|
+
if (reexportEntry.reexportType === 'barrel') {
|
|
286
|
+
reexportEntry.barrelImportedByFiles.push(originFilePath);
|
|
287
|
+
traverse(reexportEntry.resolvedModulePath);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
reexportEntry.barrelImportedByFiles.push(originFilePath);
|
|
291
|
+
analyzeSingleImport(originFilePath, reexportEntry, analyzedProjectInfo, initialImportType, reexportFiles);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
traverse(originAnalyzedImport.resolvedModulePath);
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=computeAnalyzedInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeAnalyzedInfo.js","sourceRoot":"","sources":["../../src/module/computeAnalyzedInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAajD,MAAM,UAAU,mBAAmB,CACjC,mBAAwC;IAExC,MAAM,mBAAmB,GAAwB;QAC/C,GAAG,mBAAmB;QACtB,KAAK,EAAE,IAAI,GAAG,EAAE;KACjB,CAAC;IAEF,sHAAsH;IACtH,oEAAoE;IACpE,KAAK,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,mBAAmB,CAAC,KAAK,EAAE,CAAC;QAChE,IAAI,WAAW,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;YACpC,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE;gBACtC,QAAQ,EAAE,OAAO;aAClB,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QAED,MAAM,gBAAgB,GAA4B;YAChD,QAAQ,EAAE,MAAM;YAChB,aAAa,EAAE,WAAW,CAAC,aAAa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CAAC;gBACN,aAAa,CAAC,qBAAqB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBACzD,mBAAmB,CACjB,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,CACd,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BaseProjectInfo } from '../types/base.js';
|
|
2
|
+
import { TSESTree } from '@typescript-eslint/utils';
|
|
3
|
+
import type { IgnorePattern } from '../settings/settings.js';
|
|
4
|
+
type IsEntryPointCheck = (filePath: string, symbolName: string) => boolean;
|
|
5
|
+
type ComputeBaseInfoOptions = {
|
|
6
|
+
rootDir: string;
|
|
7
|
+
alias?: Record<string, string>;
|
|
8
|
+
ignorePatterns: IgnorePattern[];
|
|
9
|
+
isEntryPointCheck?: IsEntryPointCheck;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Computes base ESM info for all source files recursively found in basePath
|
|
13
|
+
*/
|
|
14
|
+
export declare function computeBaseInfo({ rootDir, alias, ignorePatterns, isEntryPointCheck, }: ComputeBaseInfoOptions): BaseProjectInfo;
|
|
15
|
+
type ComputeFileDetailsOptions = {
|
|
16
|
+
filePath: string;
|
|
17
|
+
fileContents: string;
|
|
18
|
+
ast: TSESTree.Program;
|
|
19
|
+
isEntryPointCheck: IsEntryPointCheck;
|
|
20
|
+
};
|
|
21
|
+
export declare function addBaseInfoForFile({ filePath, fileContents, ast, isEntryPointCheck }: ComputeFileDetailsOptions, baseProjectInfo: BaseProjectInfo): void;
|
|
22
|
+
export declare function updateBaseInfoForFile({ filePath, fileContents, ast, isEntryPointCheck }: ComputeFileDetailsOptions, baseProjectInfo: BaseProjectInfo): boolean;
|
|
23
|
+
export declare function deleteBaseInfoForFile(filePath: string, baseProjectInfo: BaseProjectInfo): void;
|
|
24
|
+
export {};
|