knip 5.69.0 → 5.69.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/dist/CatalogCounselor.d.ts +1 -1
- package/dist/CatalogCounselor.js +5 -2
- package/dist/DependencyDeputy.js +10 -3
- package/dist/IssueFixer.d.ts +0 -6
- package/dist/IssueFixer.js +37 -56
- package/dist/graph/analyze.d.ts +1 -1
- package/dist/graph/analyze.js +20 -17
- package/dist/index.js +1 -2
- package/dist/plugins/next/index.js +4 -5
- package/dist/types/exports.d.ts +1 -1
- package/dist/types/issues.d.ts +2 -0
- package/dist/typescript/ast-helpers.d.ts +1 -1
- package/dist/typescript/get-imports-and-exports.js +6 -9
- package/dist/typescript/visitors/dynamic-imports/importType.js +1 -1
- package/dist/typescript/visitors/exports/exportDeclaration.js +1 -1
- package/dist/typescript/visitors/imports/importDeclaration.js +3 -3
- package/dist/typescript/visitors/imports/importEqualsDeclaration.js +1 -1
- package/dist/util/get-referenced-inputs.js +4 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -14,5 +14,5 @@ export declare class CatalogCounselor {
|
|
|
14
14
|
constructor(options: MainOptions);
|
|
15
15
|
private addReferencedCatalogEntry;
|
|
16
16
|
addWorkspace(manifest: PackageJson): void;
|
|
17
|
-
settleCatalogIssues(): Promise<Issue[]>;
|
|
17
|
+
settleCatalogIssues(options: MainOptions): Promise<Issue[]>;
|
|
18
18
|
}
|
package/dist/CatalogCounselor.js
CHANGED
|
@@ -23,7 +23,7 @@ export class CatalogCounselor {
|
|
|
23
23
|
for (const catalogEntryName of catalogReferences)
|
|
24
24
|
this.addReferencedCatalogEntry(catalogEntryName);
|
|
25
25
|
}
|
|
26
|
-
async settleCatalogIssues() {
|
|
26
|
+
async settleCatalogIssues(options) {
|
|
27
27
|
if (this.entries.size === 0)
|
|
28
28
|
return [];
|
|
29
29
|
const filePath = this.filePath;
|
|
@@ -38,7 +38,10 @@ export class CatalogCounselor {
|
|
|
38
38
|
if (!this.referencedEntries.has(entry)) {
|
|
39
39
|
const [parentSymbol, symbol] = entry.split(':');
|
|
40
40
|
const pos = peeker.getLocation(parentSymbol, symbol);
|
|
41
|
-
|
|
41
|
+
const fixes = [];
|
|
42
|
+
if (options.isFix && isYaml && pos)
|
|
43
|
+
fixes.push([pos.line, 0, 0]);
|
|
44
|
+
catalogIssues.push({ type: 'catalog', filePath, workspace, symbol, parentSymbol, fixes, ...pos });
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
}
|
package/dist/DependencyDeputy.js
CHANGED
|
@@ -213,15 +213,22 @@ export class DependencyDeputy {
|
|
|
213
213
|
const isNotReferencedDependency = (dependency) => !isReferencedDependency(dependency, false);
|
|
214
214
|
for (const symbol of this.getProductionDependencies(workspace).filter(isNotReferencedDependency)) {
|
|
215
215
|
const position = peeker.getLocation('dependencies', symbol);
|
|
216
|
-
dependencyIssues.push({ type: 'dependencies', workspace, filePath, symbol, ...position });
|
|
216
|
+
dependencyIssues.push({ type: 'dependencies', workspace, filePath, symbol, fixes: [], ...position });
|
|
217
217
|
}
|
|
218
218
|
for (const symbol of this.getDevDependencies(workspace).filter(isNotReferencedDependency)) {
|
|
219
219
|
const position = peeker.getLocation('devDependencies', symbol);
|
|
220
|
-
devDependencyIssues.push({ type: 'devDependencies', filePath, workspace, symbol, ...position });
|
|
220
|
+
devDependencyIssues.push({ type: 'devDependencies', filePath, workspace, symbol, fixes: [], ...position });
|
|
221
221
|
}
|
|
222
222
|
for (const symbol of this.getOptionalPeerDependencies(workspace).filter(d => isReferencedDependency(d))) {
|
|
223
223
|
const pos = peeker.getLocation('optionalPeerDependencies', symbol);
|
|
224
|
-
optionalPeerDependencyIssues.push({
|
|
224
|
+
optionalPeerDependencyIssues.push({
|
|
225
|
+
type: 'optionalPeerDependencies',
|
|
226
|
+
filePath,
|
|
227
|
+
workspace,
|
|
228
|
+
symbol,
|
|
229
|
+
fixes: [],
|
|
230
|
+
...pos,
|
|
231
|
+
});
|
|
225
232
|
}
|
|
226
233
|
}
|
|
227
234
|
return { dependencyIssues, devDependencyIssues, optionalPeerDependencyIssues };
|
package/dist/IssueFixer.d.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import type { Fix, Fixes } from './types/exports.js';
|
|
2
1
|
import type { Issues } from './types/issues.js';
|
|
3
2
|
import type { MainOptions } from './util/create-options.js';
|
|
4
3
|
export declare class IssueFixer {
|
|
5
4
|
options: MainOptions;
|
|
6
|
-
unusedTypeNodes: Map<string, Set<Fix>>;
|
|
7
|
-
unusedExportNodes: Map<string, Set<Fix>>;
|
|
8
5
|
constructor(options: MainOptions);
|
|
9
|
-
addUnusedTypeNode(filePath: string, fixes: Fixes | undefined): void;
|
|
10
|
-
addUnusedExportNode(filePath: string, fixes: Fixes | undefined): void;
|
|
11
6
|
fixIssues(issues: Issues): Promise<Set<string>>;
|
|
12
|
-
private markExportIssuesFixed;
|
|
13
7
|
private removeUnusedFiles;
|
|
14
8
|
private removeUnusedExports;
|
|
15
9
|
private removeUnusedDependencies;
|
package/dist/IssueFixer.js
CHANGED
|
@@ -1,33 +1,13 @@
|
|
|
1
1
|
import { readFile, rm, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { DEFAULT_CATALOG } from './util/catalog.js';
|
|
3
3
|
import { load, save } from './util/package-json.js';
|
|
4
|
-
import { extname, join
|
|
4
|
+
import { extname, join } from './util/path.js';
|
|
5
5
|
import { removeExport } from './util/remove-export.js';
|
|
6
6
|
export class IssueFixer {
|
|
7
7
|
options;
|
|
8
|
-
unusedTypeNodes = new Map();
|
|
9
|
-
unusedExportNodes = new Map();
|
|
10
8
|
constructor(options) {
|
|
11
9
|
this.options = options;
|
|
12
10
|
}
|
|
13
|
-
addUnusedTypeNode(filePath, fixes) {
|
|
14
|
-
if (!fixes || fixes.length === 0)
|
|
15
|
-
return;
|
|
16
|
-
if (this.unusedTypeNodes.has(filePath))
|
|
17
|
-
for (const fix of fixes)
|
|
18
|
-
this.unusedTypeNodes.get(filePath)?.add(fix);
|
|
19
|
-
else
|
|
20
|
-
this.unusedTypeNodes.set(filePath, new Set(fixes));
|
|
21
|
-
}
|
|
22
|
-
addUnusedExportNode(filePath, fixes) {
|
|
23
|
-
if (!fixes || fixes.length === 0)
|
|
24
|
-
return;
|
|
25
|
-
if (this.unusedExportNodes.has(filePath))
|
|
26
|
-
for (const fix of fixes)
|
|
27
|
-
this.unusedExportNodes.get(filePath)?.add(fix);
|
|
28
|
-
else
|
|
29
|
-
this.unusedExportNodes.set(filePath, new Set(fixes));
|
|
30
|
-
}
|
|
31
11
|
async fixIssues(issues) {
|
|
32
12
|
const touchedFiles = new Set();
|
|
33
13
|
await this.removeUnusedFiles(issues);
|
|
@@ -39,18 +19,6 @@ export class IssueFixer {
|
|
|
39
19
|
touchedFiles.add(filePath);
|
|
40
20
|
return touchedFiles;
|
|
41
21
|
}
|
|
42
|
-
markExportIssuesFixed(issues, filePath) {
|
|
43
|
-
const relPath = relative(this.options.cwd, filePath);
|
|
44
|
-
const types = [
|
|
45
|
-
...(this.options.isFixUnusedTypes ? ['types', 'nsTypes', 'classMembers', 'enumMembers'] : []),
|
|
46
|
-
...(this.options.isFixUnusedExports ? ['exports', 'nsExports'] : []),
|
|
47
|
-
];
|
|
48
|
-
for (const type of types) {
|
|
49
|
-
for (const id in issues[type][relPath]) {
|
|
50
|
-
issues[type][relPath][id].isFixed = true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
22
|
async removeUnusedFiles(issues) {
|
|
55
23
|
if (!this.options.isFixFiles)
|
|
56
24
|
return;
|
|
@@ -61,18 +29,33 @@ export class IssueFixer {
|
|
|
61
29
|
}
|
|
62
30
|
async removeUnusedExports(issues) {
|
|
63
31
|
const touchedFiles = new Set();
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
32
|
+
const types = [
|
|
33
|
+
...(this.options.isFixUnusedTypes ? ['types', 'nsTypes', 'classMembers', 'enumMembers'] : []),
|
|
34
|
+
...(this.options.isFixUnusedExports ? ['exports', 'nsExports'] : []),
|
|
35
|
+
];
|
|
36
|
+
if (types.length === 0)
|
|
37
|
+
return touchedFiles;
|
|
38
|
+
const allFixes = new Map();
|
|
39
|
+
for (const type of types) {
|
|
40
|
+
for (const [filePath, issueMap] of Object.entries(issues[type])) {
|
|
41
|
+
const fixes = allFixes.get(filePath) ?? [];
|
|
42
|
+
for (const issue of Object.values(issueMap))
|
|
43
|
+
fixes.push(...issue.fixes);
|
|
44
|
+
allFixes.set(filePath, fixes);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
for (const [filePath, fixes] of allFixes) {
|
|
48
|
+
const absFilePath = join(this.options.cwd, filePath);
|
|
49
|
+
const sourceFileText = fixes
|
|
50
|
+
.sort((a, b) => b[0] - a[0])
|
|
51
|
+
.reduce((text, [start, end, flags]) => removeExport({ text, start, end, flags }), await readFile(absFilePath, 'utf-8'));
|
|
52
|
+
await writeFile(absFilePath, sourceFileText);
|
|
53
|
+
touchedFiles.add(absFilePath);
|
|
54
|
+
for (const type of types) {
|
|
55
|
+
const issueMap = issues[type]?.[filePath];
|
|
56
|
+
if (issueMap)
|
|
57
|
+
for (const issue of Object.values(issueMap))
|
|
58
|
+
issue.isFixed = true;
|
|
76
59
|
}
|
|
77
60
|
}
|
|
78
61
|
return touchedFiles;
|
|
@@ -102,7 +85,7 @@ export class IssueFixer {
|
|
|
102
85
|
}
|
|
103
86
|
}
|
|
104
87
|
await save(absFilePath, pkg);
|
|
105
|
-
touchedFiles.add(
|
|
88
|
+
touchedFiles.add(absFilePath);
|
|
106
89
|
}
|
|
107
90
|
return touchedFiles;
|
|
108
91
|
}
|
|
@@ -115,15 +98,13 @@ export class IssueFixer {
|
|
|
115
98
|
if (['.yml', '.yaml'].includes(extname(filePath))) {
|
|
116
99
|
const absFilePath = join(this.options.cwd, filePath);
|
|
117
100
|
const fileContent = await readFile(absFilePath, 'utf-8');
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
await writeFile(absFilePath, fileContent.split('\n').filter(isRemove).join('\n'));
|
|
101
|
+
const issuesForFile = Object.values(issues.catalog[filePath]);
|
|
102
|
+
const takeLine = (issue) => issue.fixes.map(fix => fix[0]);
|
|
103
|
+
const remove = new Set(issuesForFile.flatMap(takeLine));
|
|
104
|
+
const keep = (_, i) => !remove.has(i + 1);
|
|
105
|
+
await writeFile(absFilePath, fileContent.split('\n').filter(keep).join('\n'));
|
|
106
|
+
for (const issue of issuesForFile)
|
|
107
|
+
issue.isFixed = true;
|
|
127
108
|
touchedFiles.add(filePath);
|
|
128
109
|
}
|
|
129
110
|
else {
|
|
@@ -146,7 +127,7 @@ export class IssueFixer {
|
|
|
146
127
|
}
|
|
147
128
|
}
|
|
148
129
|
await save(absFilePath, pkg);
|
|
149
|
-
touchedFiles.add(
|
|
130
|
+
touchedFiles.add(absFilePath);
|
|
150
131
|
}
|
|
151
132
|
}
|
|
152
133
|
return touchedFiles;
|
package/dist/graph/analyze.d.ts
CHANGED
|
@@ -21,5 +21,5 @@ interface AnalyzeOptions {
|
|
|
21
21
|
unreferencedFiles: Set<string>;
|
|
22
22
|
options: MainOptions;
|
|
23
23
|
}
|
|
24
|
-
export declare const analyze: ({ analyzedFiles, counselor, chief, collector, deputy, entryPaths, factory,
|
|
24
|
+
export declare const analyze: ({ analyzedFiles, counselor, chief, collector, deputy, entryPaths, factory, graph, streamer, unreferencedFiles, options, }: AnalyzeOptions) => Promise<() => Promise<void>>;
|
|
25
25
|
export {};
|
package/dist/graph/analyze.js
CHANGED
|
@@ -4,7 +4,7 @@ import { getPackageNameFromModuleSpecifier } from '../util/modules.js';
|
|
|
4
4
|
import { findMatch } from '../util/regex.js';
|
|
5
5
|
import { getShouldIgnoreHandler, getShouldIgnoreTagHandler } from '../util/tag.js';
|
|
6
6
|
import { createAndPrintTrace, printTrace } from '../util/trace.js';
|
|
7
|
-
export const analyze = async ({ analyzedFiles, counselor, chief, collector, deputy, entryPaths, factory,
|
|
7
|
+
export const analyze = async ({ analyzedFiles, counselor, chief, collector, deputy, entryPaths, factory, graph, streamer, unreferencedFiles, options, }) => {
|
|
8
8
|
const shouldIgnore = getShouldIgnoreHandler(options.isProduction);
|
|
9
9
|
const shouldIgnoreTags = getShouldIgnoreTagHandler(options.tags);
|
|
10
10
|
const isIdentifierReferenced = getIsIdentifierReferencedHandler(graph, entryPaths, options.isTrace);
|
|
@@ -75,7 +75,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
75
75
|
if (!isReferenced) {
|
|
76
76
|
if (isIgnored)
|
|
77
77
|
continue;
|
|
78
|
-
|
|
78
|
+
collector.addIssue({
|
|
79
79
|
type: 'enumMembers',
|
|
80
80
|
filePath,
|
|
81
81
|
workspace: workspace.name,
|
|
@@ -84,9 +84,8 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
84
84
|
pos: member.pos,
|
|
85
85
|
line: member.line,
|
|
86
86
|
col: member.col,
|
|
87
|
+
fixes: member.fix ? [member.fix] : [],
|
|
87
88
|
});
|
|
88
|
-
if (options.isFix && isIssueAdded && member.fix)
|
|
89
|
-
fixer.addUnusedTypeNode(filePath, [member.fix]);
|
|
90
89
|
}
|
|
91
90
|
else if (isIgnored) {
|
|
92
91
|
for (const tagName of exportedItem.jsDocTags) {
|
|
@@ -110,7 +109,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
110
109
|
}
|
|
111
110
|
continue;
|
|
112
111
|
}
|
|
113
|
-
|
|
112
|
+
collector.addIssue({
|
|
114
113
|
type: 'classMembers',
|
|
115
114
|
filePath,
|
|
116
115
|
workspace: workspace.name,
|
|
@@ -119,9 +118,8 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
119
118
|
pos: member.pos,
|
|
120
119
|
line: member.line,
|
|
121
120
|
col: member.col,
|
|
121
|
+
fixes: member.fix ? [member.fix] : [],
|
|
122
122
|
});
|
|
123
|
-
if (options.isFix && isIssueAdded && member.fix)
|
|
124
|
-
fixer.addUnusedTypeNode(filePath, [member.fix]);
|
|
125
123
|
}
|
|
126
124
|
}
|
|
127
125
|
continue;
|
|
@@ -138,7 +136,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
138
136
|
if (!options.isSkipLibs && principal?.hasExternalReferences(filePath, exportedItem))
|
|
139
137
|
continue;
|
|
140
138
|
const type = getType(hasStrictlyNsRefs, isType);
|
|
141
|
-
|
|
139
|
+
collector.addIssue({
|
|
142
140
|
type,
|
|
143
141
|
filePath,
|
|
144
142
|
workspace: workspace.name,
|
|
@@ -148,13 +146,8 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
148
146
|
pos: exportedItem.pos,
|
|
149
147
|
line: exportedItem.line,
|
|
150
148
|
col: exportedItem.col,
|
|
149
|
+
fixes: exportedItem.fixes,
|
|
151
150
|
});
|
|
152
|
-
if (options.isFix && isIssueAdded) {
|
|
153
|
-
if (isType)
|
|
154
|
-
fixer.addUnusedTypeNode(filePath, exportedItem.fixes);
|
|
155
|
-
else
|
|
156
|
-
fixer.addUnusedExportNode(filePath, exportedItem.fixes);
|
|
157
|
-
}
|
|
158
151
|
}
|
|
159
152
|
}
|
|
160
153
|
}
|
|
@@ -167,7 +160,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
167
160
|
for (const symbols of file.duplicates) {
|
|
168
161
|
if (symbols.length > 1) {
|
|
169
162
|
const symbol = symbols.map(s => s.symbol).join('|');
|
|
170
|
-
collector.addIssue({ type: 'duplicates', filePath, workspace: ws.name, symbol, symbols });
|
|
163
|
+
collector.addIssue({ type: 'duplicates', filePath, workspace: ws.name, symbol, symbols, fixes: [] });
|
|
171
164
|
}
|
|
172
165
|
}
|
|
173
166
|
}
|
|
@@ -185,13 +178,23 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
185
178
|
pos: extImport.pos,
|
|
186
179
|
line: extImport.line,
|
|
187
180
|
col: extImport.col,
|
|
181
|
+
fixes: [],
|
|
188
182
|
});
|
|
189
183
|
}
|
|
190
184
|
}
|
|
191
185
|
if (file.imports?.unresolved) {
|
|
192
186
|
for (const unresolvedImport of file.imports.unresolved) {
|
|
193
187
|
const { specifier, pos, line, col } = unresolvedImport;
|
|
194
|
-
collector.addIssue({
|
|
188
|
+
collector.addIssue({
|
|
189
|
+
type: 'unresolved',
|
|
190
|
+
filePath,
|
|
191
|
+
workspace: ws.name,
|
|
192
|
+
symbol: specifier,
|
|
193
|
+
pos,
|
|
194
|
+
line,
|
|
195
|
+
col,
|
|
196
|
+
fixes: [],
|
|
197
|
+
});
|
|
195
198
|
}
|
|
196
199
|
}
|
|
197
200
|
}
|
|
@@ -213,7 +216,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
213
216
|
for (const hint of configurationHints)
|
|
214
217
|
collector.addConfigurationHint(hint);
|
|
215
218
|
}
|
|
216
|
-
const catalogIssues = await counselor.settleCatalogIssues();
|
|
219
|
+
const catalogIssues = await counselor.settleCatalogIssues(options);
|
|
217
220
|
for (const issue of catalogIssues)
|
|
218
221
|
collector.addIssue(issue);
|
|
219
222
|
const unusedIgnoredWorkspaces = chief.getUnusedIgnoredWorkspaces();
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,6 @@ import { debugLogArray, debugLogObject } from './util/debug.js';
|
|
|
14
14
|
import { getGitIgnoredHandler } from './util/glob-core.js';
|
|
15
15
|
import { getWatchHandler } from './util/watch.js';
|
|
16
16
|
export const main = async (options) => {
|
|
17
|
-
const { cwd } = options;
|
|
18
17
|
debugLogObject('*', 'Unresolved configuration', options);
|
|
19
18
|
debugLogObject('*', 'Included issue types', options.includedIssueTypes);
|
|
20
19
|
const chief = new ConfigurationChief(options);
|
|
@@ -78,7 +77,7 @@ export const main = async (options) => {
|
|
|
78
77
|
if (options.isFix) {
|
|
79
78
|
const touchedFiles = await fixer.fixIssues(issues);
|
|
80
79
|
if (options.isFormat) {
|
|
81
|
-
const report = await formatly(Array.from(touchedFiles)
|
|
80
|
+
const report = await formatly(Array.from(touchedFiles));
|
|
82
81
|
if (report.ran && report.result && (report.result.runner === 'virtual' || report.result.code === 0)) {
|
|
83
82
|
debugLogArray('*', `Formatted files using ${report.formatter.name} (${report.formatter.runner})`, touchedFiles);
|
|
84
83
|
}
|
|
@@ -8,9 +8,6 @@ const config = ['next.config.{js,ts,cjs,mjs}'];
|
|
|
8
8
|
const defaultPageExtensions = ['{js,jsx,ts,tsx}'];
|
|
9
9
|
const productionEntryFilePatterns = [
|
|
10
10
|
'{instrumentation,instrumentation-client,middleware,proxy}.{js,ts}',
|
|
11
|
-
'app/global-{error,not-found}.{js,jsx,ts,tsx}',
|
|
12
|
-
'app/**/{error,layout,loading,not-found,page,template,default,forbidden,unauthorized}.{js,jsx,ts,tsx}',
|
|
13
|
-
'app/**/route.{js,jsx,ts,tsx}',
|
|
14
11
|
'app/{manifest,robots}.{js,ts}',
|
|
15
12
|
'app/**/sitemap.{js,ts}',
|
|
16
13
|
'app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
|
|
@@ -18,8 +15,10 @@ const productionEntryFilePatterns = [
|
|
|
18
15
|
'mdx-components.{js,jsx,ts,tsx}',
|
|
19
16
|
];
|
|
20
17
|
const getEntryFilePatterns = (pageExtensions = defaultPageExtensions) => {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
18
|
+
const patterns = [...productionEntryFilePatterns];
|
|
19
|
+
for (const ext of pageExtensions) {
|
|
20
|
+
patterns.push(`app/global-{error,not-found}.${ext}`, `app/**/{error,layout,loading,not-found,page,template,default,forbidden,unauthorized}.${ext}`, `app/**/route.${ext}`, `pages/**/*.${ext}`);
|
|
21
|
+
}
|
|
23
22
|
return [...patterns, ...patterns.map(pattern => `src/${pattern}`)];
|
|
24
23
|
};
|
|
25
24
|
const production = getEntryFilePatterns();
|
package/dist/types/exports.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
2
|
import type { SymbolType } from './issues.js';
|
|
3
3
|
type Identifier = string;
|
|
4
|
-
|
|
4
|
+
type ExportPosTuple = [number, number, number];
|
|
5
5
|
export type Fix = ExportPosTuple | undefined;
|
|
6
6
|
export type Fixes = Array<ExportPosTuple>;
|
|
7
7
|
export type ExportNode = {
|
package/dist/types/issues.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SYMBOL_TYPE } from '../constants.js';
|
|
2
|
+
import type { Fixes } from './exports.js';
|
|
2
3
|
export type SymbolType = (typeof SYMBOL_TYPE)[keyof typeof SYMBOL_TYPE];
|
|
3
4
|
export type IssueSymbol = {
|
|
4
5
|
symbol: string;
|
|
@@ -19,6 +20,7 @@ export type Issue = {
|
|
|
19
20
|
pos?: number;
|
|
20
21
|
line?: number;
|
|
21
22
|
col?: number;
|
|
23
|
+
fixes: Fixes;
|
|
22
24
|
isFixed?: boolean;
|
|
23
25
|
};
|
|
24
26
|
export type IssueSet = Set<string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import type { Fix } from '../types/exports.js';
|
|
3
3
|
import type { SymbolType } from '../types/issues.js';
|
|
4
|
-
export declare function isDefaultImport(node: ts.ImportDeclaration | ts.ImportEqualsDeclaration | ts.ExportDeclaration):
|
|
4
|
+
export declare function isDefaultImport(node: ts.ImportDeclaration | ts.ImportEqualsDeclaration | ts.ExportDeclaration): node is ts.ImportDeclaration;
|
|
5
5
|
export declare function isAccessExpression(node: ts.Node): node is ts.AccessExpression;
|
|
6
6
|
export declare function isImportCall(node: ts.Node): node is ts.ImportCall;
|
|
7
7
|
export declare function isRequireCall(callExpression: ts.Node): callExpression is ts.CallExpression;
|
|
@@ -135,18 +135,15 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options, i
|
|
|
135
135
|
if (module.isExternalLibraryImport) {
|
|
136
136
|
if (options.skipTypeOnly && opts.modifiers & IMPORT_MODIFIERS.TYPE_ONLY)
|
|
137
137
|
return;
|
|
138
|
-
const
|
|
139
|
-
|
|
138
|
+
const sanitizedSpecifier = sanitizeSpecifier(isInNodeModules(filePath) || isInNodeModules(opts.specifier)
|
|
139
|
+
? getPackageNameFromFilePath(opts.specifier)
|
|
140
|
+
: opts.specifier);
|
|
140
141
|
if (!isStartsLikePackageName(sanitizedSpecifier)) {
|
|
141
142
|
return;
|
|
142
143
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
const { line, character } = sourceFile.getLineAndCharacterOfPosition(opts.pos);
|
|
148
|
-
external.add({ specifier: sanitizedSpecifier, pos: opts.pos, line: line + 1, col: character + 2 });
|
|
149
|
-
}
|
|
144
|
+
const pos = node.moduleSpecifier?.getStart() ?? opts.pos;
|
|
145
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(pos);
|
|
146
|
+
external.add({ specifier: sanitizedSpecifier, pos: opts.pos, line: line + 1, col: character + 2 });
|
|
150
147
|
}
|
|
151
148
|
}
|
|
152
149
|
}
|
|
@@ -12,7 +12,7 @@ export default visit(isModule, (node, { isFixExports, isFixTypes }) => {
|
|
|
12
12
|
const identifier = String(element.name.text);
|
|
13
13
|
const propName = element.propertyName?.text;
|
|
14
14
|
const symbol = declarations?.get(propName ?? identifier)?.[0]?.symbol;
|
|
15
|
-
const pos = element.name.
|
|
15
|
+
const pos = element.name.getStart();
|
|
16
16
|
const type = element.isTypeOnly ? SYMBOL_TYPE.TYPE : nodeType;
|
|
17
17
|
const fix = (isFixExports && type !== SYMBOL_TYPE.TYPE) || (isFixTypes && type === SYMBOL_TYPE.TYPE)
|
|
18
18
|
? [element.getStart(), element.getEnd(), FIX_FLAGS.OBJECT_BINDING | FIX_FLAGS.EMPTY_DECLARATION]
|
|
@@ -15,7 +15,7 @@ export default visit(() => true, node => {
|
|
|
15
15
|
alias: String(node.importClause.name?.escapedText),
|
|
16
16
|
specifier,
|
|
17
17
|
symbol: node.importClause.symbol,
|
|
18
|
-
pos: node.
|
|
18
|
+
pos: node.importClause.name?.getStart() ?? node.getStart(),
|
|
19
19
|
modifiers: IMPORT_MODIFIERS.NONE,
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -26,7 +26,7 @@ export default visit(() => true, node => {
|
|
|
26
26
|
symbol,
|
|
27
27
|
specifier,
|
|
28
28
|
identifier: IMPORT_STAR,
|
|
29
|
-
pos:
|
|
29
|
+
pos: node.importClause.namedBindings.name.getStart(),
|
|
30
30
|
modifiers: node.importClause?.isTypeOnly ? IMPORT_MODIFIERS.TYPE_ONLY : IMPORT_MODIFIERS.NONE,
|
|
31
31
|
});
|
|
32
32
|
}
|
|
@@ -37,7 +37,7 @@ export default visit(() => true, node => {
|
|
|
37
37
|
identifier,
|
|
38
38
|
specifier,
|
|
39
39
|
symbol: element.symbol,
|
|
40
|
-
pos: element.getStart(),
|
|
40
|
+
pos: element.name.getStart(),
|
|
41
41
|
modifiers: node.importClause?.isTypeOnly ? IMPORT_MODIFIERS.TYPE_ONLY : IMPORT_MODIFIERS.NONE,
|
|
42
42
|
});
|
|
43
43
|
}
|
|
@@ -23,6 +23,7 @@ export const getReferencedInputsHandler = (deputy, chief, isGitIgnored, addIssue
|
|
|
23
23
|
workspace: workspace.name,
|
|
24
24
|
symbol: binaryName,
|
|
25
25
|
specifier,
|
|
26
|
+
fixes: [],
|
|
26
27
|
});
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
@@ -41,6 +42,7 @@ export const getReferencedInputsHandler = (deputy, chief, isGitIgnored, addIssue
|
|
|
41
42
|
workspace: inputWorkspace.name,
|
|
42
43
|
symbol: packageName ?? specifier,
|
|
43
44
|
specifier,
|
|
45
|
+
fixes: [],
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
return;
|
|
@@ -71,6 +73,7 @@ export const getReferencedInputsHandler = (deputy, chief, isGitIgnored, addIssue
|
|
|
71
73
|
workspace: workspace.name,
|
|
72
74
|
symbol: packageName ?? specifier,
|
|
73
75
|
specifier,
|
|
76
|
+
fixes: [],
|
|
74
77
|
});
|
|
75
78
|
}
|
|
76
79
|
else if (!isGitIgnored(filePath)) {
|
|
@@ -80,6 +83,7 @@ export const getReferencedInputsHandler = (deputy, chief, isGitIgnored, addIssue
|
|
|
80
83
|
filePath: containingFilePath,
|
|
81
84
|
workspace: workspace.name,
|
|
82
85
|
symbol: specifier,
|
|
86
|
+
fixes: [],
|
|
83
87
|
});
|
|
84
88
|
}
|
|
85
89
|
else {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.69.
|
|
1
|
+
export declare const version = "5.69.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.69.
|
|
1
|
+
export const version = '5.69.1';
|