knip 6.0.4 → 6.0.5
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/graph/analyze.js +2 -2
- package/dist/plugins/nx/index.js +1 -1
- package/dist/types/module-graph.d.ts +1 -1
- package/dist/typescript/get-imports-and-exports.js +2 -2
- package/dist/typescript/visitors/helpers.js +14 -1
- package/dist/util/tag.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/graph/analyze.js
CHANGED
|
@@ -60,7 +60,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
60
60
|
if (isIgnored &&
|
|
61
61
|
(isReferenced || isReferencedInUsedExport(exportedItem, filePath, isIncludeEntryExports))) {
|
|
62
62
|
for (const tagName of exportedItem.jsDocTags) {
|
|
63
|
-
if (options.tags[1].includes(tagName
|
|
63
|
+
if (options.tags[1].includes(tagName)) {
|
|
64
64
|
collector.addTagHint({ type: 'tag', filePath, identifier, tagName });
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -114,7 +114,7 @@ export const analyze = async ({ analyzedFiles, counselor, chief, collector, depu
|
|
|
114
114
|
}
|
|
115
115
|
else if (isIgnored) {
|
|
116
116
|
for (const tagName of exportedItem.jsDocTags) {
|
|
117
|
-
if (options.tags[1].includes(tagName
|
|
117
|
+
if (options.tags[1].includes(tagName)) {
|
|
118
118
|
collector.addTagHint({ type: 'tag', filePath, identifier: id, tagName });
|
|
119
119
|
}
|
|
120
120
|
}
|
package/dist/plugins/nx/index.js
CHANGED
|
@@ -45,7 +45,7 @@ const resolveConfig = async (localConfig, options) => {
|
|
|
45
45
|
commands = [target.options.command];
|
|
46
46
|
else if (target.options?.commands)
|
|
47
47
|
commands = target.options.commands.map(commandConfig => typeof commandConfig === 'string' ? commandConfig : commandConfig.command);
|
|
48
|
-
const cwd = target.options?.cwd ? join(options.cwd, target.options.cwd) :
|
|
48
|
+
const cwd = target.options?.cwd ? join(options.cwd, target.options.cwd) : options.cwd;
|
|
49
49
|
return options.getInputsFromScripts(commands, { cwd });
|
|
50
50
|
});
|
|
51
51
|
const configInputs = targets.flatMap(target => {
|
|
@@ -11,7 +11,7 @@ import { walkAST } from "./visitors/walk.js";
|
|
|
11
11
|
const jsDocImportRe = /import\(\s*['"]([^'"]+)['"]\s*\)(?:\.(\w+))?/g;
|
|
12
12
|
const jsDocImportTagRe = /@import\s+(?:\{[^}]*\}|\*\s+as\s+\w+)\s+from\s+['"]([^'"]+)['"]/g;
|
|
13
13
|
const jsxImportSourceRe = /@jsxImportSource\s+(\S+)/;
|
|
14
|
-
const referenceTypesRe =
|
|
14
|
+
const referenceTypesRe = /\s*<reference\s+types\s*=\s*"([^"]+)"\s*\/>/;
|
|
15
15
|
const envRe = /@(?:vitest|jest)-environment\s+(\S+)/g;
|
|
16
16
|
const getImportsAndExports = (filePath, sourceText, resolveModule, options, ignoreExportsUsedInFile, skipExportsForFile, visitor, pluginCtx, cachedParseResult) => {
|
|
17
17
|
const skipExports = skipExportsForFile || !options.isReportExports;
|
|
@@ -303,7 +303,7 @@ const getImportsAndExports = (filePath, sourceText, resolveModule, options, igno
|
|
|
303
303
|
addImport(id, undefined, undefined, undefined, comment.start + results.index, modifiers);
|
|
304
304
|
}
|
|
305
305
|
if (comment.type === 'Line') {
|
|
306
|
-
const refMatch =
|
|
306
|
+
const refMatch = comment.value.match(referenceTypesRe);
|
|
307
307
|
if (refMatch) {
|
|
308
308
|
addImport(refMatch[1], undefined, undefined, undefined, comment.start, IMPORT_FLAGS.TYPE_ONLY);
|
|
309
309
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseSync, rawTransferSupported, } from 'oxc-parser';
|
|
2
2
|
import { DEFAULT_EXTENSIONS, FIX_FLAGS, SYMBOL_TYPE } from "../../constants.js";
|
|
3
3
|
import { extname } from "../../util/path.js";
|
|
4
|
+
import { EMPTY_TAGS } from "./jsdoc.js";
|
|
4
5
|
const defaultParseOptions = {
|
|
5
6
|
sourceType: 'unambiguous',
|
|
6
7
|
experimentalRawTransfer: rawTransferSupported(),
|
|
@@ -57,6 +58,18 @@ export function extractNamespaceMembers(decl, options, lineStarts, getJSDocTags,
|
|
|
57
58
|
const members = [];
|
|
58
59
|
const addMember = (name, pos, stmtStart, stmtEnd) => {
|
|
59
60
|
const fullName = prefix ? `${prefix}.${name}` : name;
|
|
61
|
+
const tags = getJSDocTags(stmtStart);
|
|
62
|
+
const existing = members.find(m => m.identifier === fullName);
|
|
63
|
+
if (existing) {
|
|
64
|
+
if (tags.size) {
|
|
65
|
+
if (existing.jsDocTags === EMPTY_TAGS)
|
|
66
|
+
existing.jsDocTags = new Set(tags);
|
|
67
|
+
else
|
|
68
|
+
for (const t of tags)
|
|
69
|
+
existing.jsDocTags.add(t);
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
60
73
|
const { line, col } = getLineAndCol(lineStarts, pos);
|
|
61
74
|
const fix = options.isFixExports
|
|
62
75
|
? [stmtStart, stmtEnd, FIX_FLAGS.OBJECT_BINDING | FIX_FLAGS.WITH_NEWLINE]
|
|
@@ -69,7 +82,7 @@ export function extractNamespaceMembers(decl, options, lineStarts, getJSDocTags,
|
|
|
69
82
|
col,
|
|
70
83
|
fix,
|
|
71
84
|
hasRefsInFile: false,
|
|
72
|
-
jsDocTags:
|
|
85
|
+
jsDocTags: tags,
|
|
73
86
|
flags: 0,
|
|
74
87
|
});
|
|
75
88
|
};
|
package/dist/util/tag.js
CHANGED
|
@@ -4,11 +4,11 @@ export const splitTags = (rawTags) => {
|
|
|
4
4
|
return tags.reduce(([incl, excl], tag) => {
|
|
5
5
|
const match = tag.match(/[a-zA-Z]+/);
|
|
6
6
|
if (match)
|
|
7
|
-
(tag.startsWith('-') ? excl : incl).push(match[0]);
|
|
7
|
+
(tag.startsWith('-') ? excl : incl).push(`@${match[0]}`);
|
|
8
8
|
return [incl, excl];
|
|
9
9
|
}, [[], []]);
|
|
10
10
|
};
|
|
11
|
-
const hasTag = (tags, jsDocTags) => tags.some(tag => jsDocTags.has(
|
|
11
|
+
const hasTag = (tags, jsDocTags) => tags.some(tag => jsDocTags.has(tag));
|
|
12
12
|
export const shouldIgnore = (jsDocTags, tags) => {
|
|
13
13
|
const [includeJSDocTags, excludeJSDocTags] = tags;
|
|
14
14
|
if (includeJSDocTags.length > 0 && !hasTag(includeJSDocTags, jsDocTags))
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.0.
|
|
1
|
+
export declare const version = "6.0.5";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '6.0.
|
|
1
|
+
export const version = '6.0.5';
|