knip 5.22.2 → 5.22.3
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/WorkspaceWorker.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/plugins/graphql-codegen/index.js +5 -0
- package/dist/util/{type.d.ts → has-strictly-ns-references.d.ts} +1 -1
- package/dist/util/has-strictly-ns-references.js +95 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/util/type.js +0 -55
|
@@ -32,7 +32,7 @@ export declare class WorkspaceWorker {
|
|
|
32
32
|
isStrict: boolean;
|
|
33
33
|
rootIgnore: Configuration['ignore'];
|
|
34
34
|
negatedWorkspacePatterns: string[];
|
|
35
|
-
enabledPluginsMap: Record<"
|
|
35
|
+
enabledPluginsMap: Record<"angular" | "astro" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "drizzle" | "eleventy" | "eslint" | "gatsby" | "githubActions" | "graphqlCodegen" | "husky" | "jest" | "lefthook" | "linthtml" | "lintStaged" | "lockfileLint" | "lostPixel" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "netlify" | "next" | "nodeTestRunner" | "npmPackageJsonLint" | "nx" | "nyc" | "oclif" | "playwright" | "playwrightCt" | "postcss" | "prettier" | "releaseIt" | "remark" | "remix" | "rollup" | "semanticRelease" | "sentry" | "simpleGitHooks" | "sizeLimit" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vercelOg" | "vite" | "vitest" | "vue" | "webdriverIo" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie", boolean>;
|
|
36
36
|
enabledPlugins: PluginName[];
|
|
37
37
|
enabledPluginsInAncestors: string[];
|
|
38
38
|
cache: CacheConsultant<CacheItem>;
|
|
@@ -52,7 +52,7 @@ export declare class WorkspaceWorker {
|
|
|
52
52
|
entryFilePatterns: Set<string>;
|
|
53
53
|
productionEntryFilePatterns: Set<string>;
|
|
54
54
|
referencedDependencies: ReferencedDependencies;
|
|
55
|
-
enabledPlugins: ("
|
|
55
|
+
enabledPlugins: ("angular" | "astro" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cucumber" | "cypress" | "drizzle" | "eleventy" | "eslint" | "gatsby" | "githubActions" | "graphqlCodegen" | "husky" | "jest" | "lefthook" | "linthtml" | "lintStaged" | "lockfileLint" | "lostPixel" | "markdownlint" | "mocha" | "moonrepo" | "msw" | "netlify" | "next" | "nodeTestRunner" | "npmPackageJsonLint" | "nx" | "nyc" | "oclif" | "playwright" | "playwrightCt" | "postcss" | "prettier" | "releaseIt" | "remark" | "remix" | "rollup" | "semanticRelease" | "sentry" | "simpleGitHooks" | "sizeLimit" | "storybook" | "stryker" | "stylelint" | "svelte" | "syncpack" | "tailwind" | "tsup" | "typedoc" | "typescript" | "unbuild" | "unocss" | "vercelOg" | "vite" | "vitest" | "vue" | "webdriverIo" | "webpack" | "wireit" | "wrangler" | "xo" | "yorkie")[];
|
|
56
56
|
}>;
|
|
57
57
|
onDispose(): void;
|
|
58
58
|
}
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import { isFile } from './util/fs.js';
|
|
|
17
17
|
import { _glob, negate } from './util/glob.js';
|
|
18
18
|
import { getGitIgnoredFn } from './util/globby.js';
|
|
19
19
|
import { getHandler } from './util/handle-dependency.js';
|
|
20
|
+
import { getHasStrictlyNsReferences, getType } from './util/has-strictly-ns-references.js';
|
|
20
21
|
import { getIsIdentifierReferencedHandler } from './util/is-identifier-referenced.js';
|
|
21
22
|
import { getEntryPathFromManifest, getPackageNameFromModuleSpecifier } from './util/modules.js';
|
|
22
23
|
import { dirname, join, toPosix } from './util/path.js';
|
|
@@ -25,7 +26,6 @@ import { getShouldIgnoreHandler } from './util/tag.js';
|
|
|
25
26
|
import { augmentWorkspace, getToSourcePathHandler } from './util/to-source-path.js';
|
|
26
27
|
import { createAndPrintTrace, printTrace } from './util/trace.js';
|
|
27
28
|
import { loadTSConfig } from './util/tsconfig-loader.js';
|
|
28
|
-
import { getHasStrictlyNsReferences, getType } from './util/type.js';
|
|
29
29
|
export const main = async (unresolvedConfiguration) => {
|
|
30
30
|
const { cwd, tsConfigFile, gitignore, isStrict, isProduction, isShowProgress, isIncludeEntryExports, isIncludeLibs, isIsolateWorkspaces, isDebug, isWatch, tags, isFix, fixTypes, isRemoveFiles, } = unresolvedConfiguration;
|
|
31
31
|
debugLogObject('*', 'Unresolved configuration (from CLI arguments)', unresolvedConfiguration);
|
|
@@ -369,14 +369,14 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
369
369
|
continue;
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
|
-
const [
|
|
372
|
+
const [hasStrictlyNsRefs, namespace] = getHasStrictlyNsReferences(graph, importsForExport, identifier);
|
|
373
373
|
const isType = ['enum', 'type', 'interface'].includes(exportedItem.type);
|
|
374
|
-
if (
|
|
374
|
+
if (hasStrictlyNsRefs && ((!report.nsTypes && isType) || !(report.nsExports || isType)))
|
|
375
375
|
continue;
|
|
376
376
|
if (!isExportedItemReferenced(exportedItem)) {
|
|
377
377
|
if (!isSkipLibs && principal?.hasExternalReferences(filePath, exportedItem))
|
|
378
378
|
continue;
|
|
379
|
-
const type = getType(
|
|
379
|
+
const type = getType(hasStrictlyNsRefs, isType);
|
|
380
380
|
const isIssueAdded = collector.addIssue({
|
|
381
381
|
type,
|
|
382
382
|
filePath,
|
|
@@ -36,6 +36,11 @@ const resolveConfig = config => {
|
|
|
36
36
|
.map(plugin => `@graphql-codegen/${plugin}`);
|
|
37
37
|
const nestedPlugins = configurationOutput
|
|
38
38
|
.flatMap(configOutput => (configOutput.plugins ? configOutput.plugins : []))
|
|
39
|
+
.flatMap(plugin => {
|
|
40
|
+
if (typeof plugin === 'object')
|
|
41
|
+
return Object.keys(plugin);
|
|
42
|
+
return [plugin];
|
|
43
|
+
})
|
|
39
44
|
.flatMap(plugin => {
|
|
40
45
|
if (typeof plugin !== 'string')
|
|
41
46
|
return [];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { DependencyGraph, ImportDetails } from '../types/dependency-graph.js';
|
|
2
|
-
export declare const getHasStrictlyNsReferences: (graph: DependencyGraph, importsForExport: ImportDetails | undefined) => [boolean, string?];
|
|
2
|
+
export declare const getHasStrictlyNsReferences: (graph: DependencyGraph, importsForExport: ImportDetails | undefined, id: string) => [boolean, string?];
|
|
3
3
|
export declare const getType: (hasOnlyNsReference: boolean, isType: boolean) => "exports" | "types" | "nsExports" | "nsTypes";
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { IMPORT_STAR } from '../constants.js';
|
|
2
|
+
export const getHasStrictlyNsReferences = (graph, importsForExport, id) => {
|
|
3
|
+
if (!importsForExport)
|
|
4
|
+
return [false];
|
|
5
|
+
let namespace;
|
|
6
|
+
for (const ns of importsForExport.importedNs.keys()) {
|
|
7
|
+
const hasNs = importsForExport.refs.has(ns);
|
|
8
|
+
if (!hasNs)
|
|
9
|
+
return [false, ns];
|
|
10
|
+
for (const id of importsForExport.refs)
|
|
11
|
+
if (id.startsWith(`${ns}.`))
|
|
12
|
+
return [false, ns];
|
|
13
|
+
const byFilePaths = importsForExport.reExportedNs.get(ns);
|
|
14
|
+
if (byFilePaths) {
|
|
15
|
+
for (const filePath of byFilePaths) {
|
|
16
|
+
const file = graph.get(filePath);
|
|
17
|
+
if (file?.imported) {
|
|
18
|
+
const hasStrictlyNsReferences = getHasStrictlyNsReferences(graph, file.imported, id);
|
|
19
|
+
if (hasStrictlyNsReferences[0] === false)
|
|
20
|
+
return hasStrictlyNsReferences;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const reExportedAs = importsForExport.reExportedAs.get(ns);
|
|
25
|
+
if (reExportedAs) {
|
|
26
|
+
for (const byFilePaths of reExportedAs.values()) {
|
|
27
|
+
for (const filePath of byFilePaths) {
|
|
28
|
+
const file = graph.get(filePath);
|
|
29
|
+
if (file?.imported) {
|
|
30
|
+
const hasStrictlyNsReferences = getHasStrictlyNsReferences(graph, file.imported, id);
|
|
31
|
+
if (hasStrictlyNsReferences[0] === false)
|
|
32
|
+
return hasStrictlyNsReferences;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
namespace = ns;
|
|
38
|
+
}
|
|
39
|
+
const byFilePaths = importsForExport.reExported.get(id);
|
|
40
|
+
if (byFilePaths) {
|
|
41
|
+
for (const filePath of byFilePaths) {
|
|
42
|
+
const file = graph.get(filePath);
|
|
43
|
+
if (file?.imported) {
|
|
44
|
+
const hasStrictlyNsReferences = getHasStrictlyNsReferences(graph, file.imported, id);
|
|
45
|
+
if (hasStrictlyNsReferences[0] === false)
|
|
46
|
+
return hasStrictlyNsReferences;
|
|
47
|
+
namespace = hasStrictlyNsReferences[1];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
{
|
|
52
|
+
const byFilePaths = importsForExport.reExported.get(IMPORT_STAR);
|
|
53
|
+
if (byFilePaths) {
|
|
54
|
+
for (const filePath of byFilePaths) {
|
|
55
|
+
const file = graph.get(filePath);
|
|
56
|
+
if (file?.imported) {
|
|
57
|
+
const hasStrictlyNsReferences = getHasStrictlyNsReferences(graph, file.imported, id);
|
|
58
|
+
if (hasStrictlyNsReferences[0] === false)
|
|
59
|
+
return hasStrictlyNsReferences;
|
|
60
|
+
namespace = hasStrictlyNsReferences[1];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const [identifier, ...rest] = id.split('.');
|
|
66
|
+
const reExportedAs = importsForExport.reExportedAs.get(identifier);
|
|
67
|
+
if (reExportedAs) {
|
|
68
|
+
for (const [alias, filePaths] of reExportedAs.entries()) {
|
|
69
|
+
for (const filePath of filePaths) {
|
|
70
|
+
const file = graph.get(filePath);
|
|
71
|
+
if (file?.imported) {
|
|
72
|
+
const hasStrictlyNsReferences = getHasStrictlyNsReferences(graph, file.imported, [alias, ...rest].join('.'));
|
|
73
|
+
if (hasStrictlyNsReferences[0] === false)
|
|
74
|
+
return hasStrictlyNsReferences;
|
|
75
|
+
namespace = hasStrictlyNsReferences[1];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const [ns, filePaths] of importsForExport.reExportedNs.entries()) {
|
|
81
|
+
for (const filePath of filePaths) {
|
|
82
|
+
const file = graph.get(filePath);
|
|
83
|
+
if (file?.imported) {
|
|
84
|
+
const hasStrictlyNsReferences = getHasStrictlyNsReferences(graph, file.imported, `${ns}.${id}`);
|
|
85
|
+
if (hasStrictlyNsReferences[0] === false)
|
|
86
|
+
return hasStrictlyNsReferences;
|
|
87
|
+
namespace = hasStrictlyNsReferences[1];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (namespace)
|
|
92
|
+
return [true, namespace];
|
|
93
|
+
return [false];
|
|
94
|
+
};
|
|
95
|
+
export const getType = (hasOnlyNsReference, isType) => hasOnlyNsReference ? (isType ? 'nsTypes' : 'nsExports') : isType ? 'types' : 'exports';
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.22.
|
|
1
|
+
export declare const version = "5.22.3";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.22.
|
|
1
|
+
export const version = '5.22.3';
|
package/package.json
CHANGED
package/dist/util/type.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { IMPORT_STAR } from '../constants.js';
|
|
2
|
-
export const getHasStrictlyNsReferences = (graph, importsForExport) => {
|
|
3
|
-
if (!importsForExport)
|
|
4
|
-
return [false];
|
|
5
|
-
if (importsForExport.importedNs.size === 0 && !importsForExport.reExported.has(IMPORT_STAR)) {
|
|
6
|
-
return [false];
|
|
7
|
-
}
|
|
8
|
-
let namespace;
|
|
9
|
-
for (const ns of importsForExport.importedNs.keys()) {
|
|
10
|
-
const hasNs = importsForExport.refs.has(ns);
|
|
11
|
-
if (!hasNs)
|
|
12
|
-
return [false, ns];
|
|
13
|
-
for (const id of importsForExport.refs)
|
|
14
|
-
if (id.startsWith(`${ns}.`))
|
|
15
|
-
return [false, ns];
|
|
16
|
-
const byFilePaths = importsForExport.reExportedNs.get(ns);
|
|
17
|
-
if (byFilePaths) {
|
|
18
|
-
for (const filePath of byFilePaths) {
|
|
19
|
-
const file = graph.get(filePath);
|
|
20
|
-
if (file?.imported) {
|
|
21
|
-
const hasStrictlyNsReferences = getHasStrictlyNsReferences(graph, file.imported);
|
|
22
|
-
if (hasStrictlyNsReferences[0] === false)
|
|
23
|
-
return hasStrictlyNsReferences;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
const reExportedAs = importsForExport.reExportedAs.get(ns);
|
|
28
|
-
if (reExportedAs) {
|
|
29
|
-
for (const byFilePaths of reExportedAs.values()) {
|
|
30
|
-
for (const filePath of byFilePaths) {
|
|
31
|
-
const file = graph.get(filePath);
|
|
32
|
-
if (file?.imported) {
|
|
33
|
-
const hasStrictlyNsReferences = getHasStrictlyNsReferences(graph, file.imported);
|
|
34
|
-
if (hasStrictlyNsReferences[0] === false)
|
|
35
|
-
return hasStrictlyNsReferences;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
namespace = ns;
|
|
41
|
-
}
|
|
42
|
-
const byFilePaths = importsForExport.reExported.get(IMPORT_STAR);
|
|
43
|
-
if (byFilePaths) {
|
|
44
|
-
for (const filePath of byFilePaths) {
|
|
45
|
-
const file = graph.get(filePath);
|
|
46
|
-
if (file?.imported) {
|
|
47
|
-
const hasStrictlyNsReferences = getHasStrictlyNsReferences(graph, file.imported);
|
|
48
|
-
if (hasStrictlyNsReferences[0] === false)
|
|
49
|
-
return hasStrictlyNsReferences;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return [true, namespace];
|
|
54
|
-
};
|
|
55
|
-
export const getType = (hasOnlyNsReference, isType) => hasOnlyNsReference ? (isType ? 'nsTypes' : 'nsExports') : isType ? 'types' : 'exports';
|