knip 5.70.0 → 5.70.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/typescript/pragmas/custom.js +1 -1
- package/dist/typescript/visitors/dynamic-imports/jsDocType.js +23 -9
- package/dist/typescript/visitors/dynamic-imports/requireCall.js +7 -4
- package/dist/typescript/visitors/imports/reExportDeclaration.js +4 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ export const collectCustomImports = (sourceFile) => {
|
|
|
17
17
|
const isLocal = isInternal(id) || isAbsolute(id);
|
|
18
18
|
const modifiers = isLocal ? IMPORT_MODIFIERS.ENTRY : IMPORT_MODIFIERS.NONE;
|
|
19
19
|
const offset = match[0].length - match[2].length;
|
|
20
|
-
const specifier = isLocal ? id : getEnvSpecifier(id);
|
|
20
|
+
const specifier = isLocal || id === 'node' ? id : getEnvSpecifier(id);
|
|
21
21
|
importNodes.push({ specifier, identifier: undefined, pos: comment.pos + match.index + offset, modifiers });
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { IMPORT_MODIFIERS } from '../../../constants.js';
|
|
2
|
+
import { IMPORT_MODIFIERS, IMPORT_STAR } from '../../../constants.js';
|
|
3
3
|
import { importVisitor as visit } from '../index.js';
|
|
4
4
|
const supportsJSDocImportTag = 'isJSDocImportTag' in ts;
|
|
5
5
|
const getImportSpecifiers = (node) => {
|
|
@@ -12,19 +12,33 @@ const getImportSpecifiers = (node) => {
|
|
|
12
12
|
imports.push({
|
|
13
13
|
specifier: importClause.literal.text,
|
|
14
14
|
identifier,
|
|
15
|
-
pos: importClause.literal.pos,
|
|
15
|
+
pos: node.qualifier?.getStart() ?? importClause.literal.pos,
|
|
16
16
|
modifiers: IMPORT_MODIFIERS.NONE,
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
if (supportsJSDocImportTag && ts.isJSDocImportTag(node) && ts.isStringLiteralLike(node.moduleSpecifier)) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
if (node.importClause?.namedBindings && ts.isNamedImportBindings(node.importClause.namedBindings)) {
|
|
22
|
+
const bindings = node.importClause.namedBindings;
|
|
23
|
+
if (ts.isNamespaceImport(bindings)) {
|
|
24
|
+
imports.push({
|
|
25
|
+
specifier: node.moduleSpecifier.text,
|
|
26
|
+
identifier: IMPORT_STAR,
|
|
27
|
+
pos: bindings.name.getStart(),
|
|
28
|
+
modifiers: IMPORT_MODIFIERS.TYPE_ONLY,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
for (const element of bindings.elements) {
|
|
33
|
+
imports.push({
|
|
34
|
+
specifier: node.moduleSpecifier.text,
|
|
35
|
+
identifier: String((element.propertyName ?? element.name).escapedText),
|
|
36
|
+
pos: element.name.getStart(),
|
|
37
|
+
modifiers: IMPORT_MODIFIERS.TYPE_ONLY,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
28
42
|
}
|
|
29
43
|
ts.forEachChild(node, visit);
|
|
30
44
|
}
|
|
@@ -15,7 +15,7 @@ export default visit(() => true, node => {
|
|
|
15
15
|
});
|
|
16
16
|
if (propertyAccessExpression) {
|
|
17
17
|
const identifier = String(propertyAccessExpression.name.escapedText);
|
|
18
|
-
return { identifier, specifier, pos: propertyAccessExpression.name.
|
|
18
|
+
return { identifier, specifier, pos: propertyAccessExpression.name.getStart(), modifiers };
|
|
19
19
|
}
|
|
20
20
|
const variableDeclaration = node.parent;
|
|
21
21
|
if (ts.isVariableDeclaration(variableDeclaration) &&
|
|
@@ -28,7 +28,7 @@ export default visit(() => true, node => {
|
|
|
28
28
|
alias,
|
|
29
29
|
symbol: isTLA ? variableDeclaration.symbol : undefined,
|
|
30
30
|
specifier,
|
|
31
|
-
pos:
|
|
31
|
+
pos: variableDeclaration.name.getStart(),
|
|
32
32
|
modifiers,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
@@ -38,7 +38,7 @@ export default visit(() => true, node => {
|
|
|
38
38
|
const identifier = (element.propertyName ?? element.name).getText();
|
|
39
39
|
const alias = element.propertyName ? element.name.getText() : undefined;
|
|
40
40
|
const symbol = isTLA ? element.symbol : undefined;
|
|
41
|
-
return { identifier, specifier, alias, symbol, pos: element.
|
|
41
|
+
return { identifier, specifier, alias, symbol, pos: element.name.getStart(), modifiers };
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
return { identifier: 'default', specifier, pos: node.arguments[0].pos, modifiers };
|
|
@@ -53,7 +53,10 @@ export default visit(() => true, node => {
|
|
|
53
53
|
modifiers: IMPORT_MODIFIERS.RE_EXPORT,
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
if (ts.isCallExpression(node.parent)) {
|
|
57
|
+
return { identifier: 'default', specifier, pos: node.getEnd(), modifiers };
|
|
58
|
+
}
|
|
59
|
+
return { identifier: 'default', specifier, pos: node.getStart(), modifiers };
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
}
|
|
@@ -8,7 +8,7 @@ export default visit(() => true, node => {
|
|
|
8
8
|
return {
|
|
9
9
|
identifier: IMPORT_STAR,
|
|
10
10
|
specifier: node.moduleSpecifier.text,
|
|
11
|
-
pos: node.
|
|
11
|
+
pos: node.moduleSpecifier.getStart() - 7,
|
|
12
12
|
modifiers: IMPORT_MODIFIERS.RE_EXPORT,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
@@ -17,7 +17,7 @@ export default visit(() => true, node => {
|
|
|
17
17
|
identifier: IMPORT_STAR,
|
|
18
18
|
namespace: String(node.exportClause.name.text),
|
|
19
19
|
specifier: node.moduleSpecifier.text,
|
|
20
|
-
pos: node.exportClause.name.
|
|
20
|
+
pos: node.exportClause.name.getStart(),
|
|
21
21
|
modifiers: IMPORT_MODIFIERS.RE_EXPORT,
|
|
22
22
|
};
|
|
23
23
|
}
|
|
@@ -28,14 +28,14 @@ export default visit(() => true, node => {
|
|
|
28
28
|
identifier: String(element.propertyName.text),
|
|
29
29
|
alias: String(element.name.text),
|
|
30
30
|
specifier: specifier.text,
|
|
31
|
-
pos: element.
|
|
31
|
+
pos: element.propertyName.getStart(),
|
|
32
32
|
modifiers: IMPORT_MODIFIERS.RE_EXPORT,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
return {
|
|
36
36
|
identifier: (element.propertyName ?? element.name).getText(),
|
|
37
37
|
specifier: specifier.text,
|
|
38
|
-
pos: element.
|
|
38
|
+
pos: element.name.getStart(),
|
|
39
39
|
modifiers: IMPORT_MODIFIERS.RE_EXPORT,
|
|
40
40
|
};
|
|
41
41
|
});
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.70.
|
|
1
|
+
export declare const version = "5.70.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.70.
|
|
1
|
+
export const version = '5.70.1';
|