knip 0.0.0-angular.0 → 0.0.0-pep.0
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/README.md +23 -1
- package/dist/ConfigurationChief.d.ts +1 -1
- package/dist/ConfigurationChief.js +15 -16
- package/dist/ConfigurationValidator.d.ts +69 -0
- package/dist/ConfigurationValidator.js +2 -1
- package/dist/DependencyDeputy.d.ts +4 -5
- package/dist/DependencyDeputy.js +15 -13
- package/dist/PrincipalFactory.d.ts +3 -0
- package/dist/PrincipalFactory.js +10 -6
- package/dist/ProjectPrincipal.js +10 -5
- package/dist/WorkspaceWorker.d.ts +11 -9
- package/dist/WorkspaceWorker.js +30 -59
- package/dist/binaries/index.js +1 -1
- package/dist/binaries/resolvers/c8.js +2 -1
- package/dist/binaries/resolvers/dotenv.js +2 -1
- package/dist/binaries/resolvers/fallback.js +2 -1
- package/dist/binaries/resolvers/index.d.ts +1 -0
- package/dist/binaries/resolvers/index.js +1 -0
- package/dist/binaries/resolvers/nodemon.js +2 -1
- package/dist/binaries/resolvers/npx.js +2 -1
- package/dist/binaries/resolvers/nx.d.ts +2 -0
- package/dist/binaries/resolvers/nx.js +9 -0
- package/dist/binaries/resolvers/pnpm.js +1 -1
- package/dist/binaries/resolvers/rollup.js +2 -1
- package/dist/binaries/resolvers/yarn.js +1 -1
- package/dist/binaries/util.d.ts +0 -3
- package/dist/binaries/util.js +1 -3
- package/dist/cli.js +2 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -4
- package/dist/index.js +86 -65
- package/dist/manifest/index.d.ts +2 -2
- package/dist/manifest/index.js +6 -6
- package/dist/plugins/ava/index.d.ts +1 -1
- package/dist/plugins/ava/index.js +23 -5
- package/dist/plugins/ava/types.d.ts +1 -0
- package/dist/plugins/babel/index.js +3 -1
- package/dist/plugins/capacitor/index.js +3 -1
- package/dist/plugins/changesets/index.js +3 -1
- package/dist/plugins/commitizen/index.js +3 -1
- package/dist/plugins/commitlint/index.js +3 -1
- package/dist/plugins/cspell/index.js +3 -1
- package/dist/plugins/cypress/index.d.ts +2 -1
- package/dist/plugins/cypress/index.js +6 -0
- package/dist/plugins/drizzle/index.d.ts +6 -0
- package/dist/plugins/drizzle/index.js +16 -0
- package/dist/plugins/drizzle/types.d.ts +3 -0
- package/dist/plugins/drizzle/types.js +1 -0
- package/dist/plugins/eslint/index.js +3 -1
- package/dist/plugins/gatsby/index.js +5 -1
- package/dist/plugins/github-actions/index.js +3 -1
- package/dist/plugins/husky/index.js +3 -1
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.js +3 -0
- package/dist/plugins/jest/index.d.ts +1 -1
- package/dist/plugins/jest/index.js +18 -6
- package/dist/plugins/lefthook/index.js +4 -2
- package/dist/plugins/lint-staged/index.js +3 -1
- package/dist/plugins/markdownlint/index.js +3 -1
- package/dist/plugins/mocha/index.d.ts +1 -0
- package/dist/plugins/mocha/index.js +10 -6
- package/dist/plugins/next/index.d.ts +2 -1
- package/dist/plugins/next/index.js +16 -4
- package/dist/plugins/node-test-runner/index.d.ts +6 -0
- package/dist/plugins/node-test-runner/index.js +17 -0
- package/dist/plugins/npm-package-json-lint/index.js +3 -1
- package/dist/plugins/nx/index.js +3 -1
- package/dist/plugins/nyc/index.js +3 -1
- package/dist/plugins/playwright/index.d.ts +3 -1
- package/dist/plugins/playwright/index.js +13 -2
- package/dist/plugins/playwright-ct/index.d.ts +7 -0
- package/dist/plugins/playwright-ct/index.js +16 -0
- package/dist/plugins/postcss/index.js +8 -6
- package/dist/plugins/prettier/index.js +3 -1
- package/dist/plugins/release-it/index.js +3 -1
- package/dist/plugins/remark/index.js +9 -3
- package/dist/plugins/remix/index.d.ts +2 -1
- package/dist/plugins/remix/index.js +10 -0
- package/dist/plugins/rollup/index.d.ts +2 -1
- package/dist/plugins/rollup/index.js +7 -0
- package/dist/plugins/semantic-release/index.js +3 -1
- package/dist/plugins/sentry/index.d.ts +2 -1
- package/dist/plugins/sentry/index.js +7 -0
- package/dist/plugins/storybook/index.js +7 -3
- package/dist/plugins/stryker/index.js +9 -8
- package/dist/plugins/stylelint/index.js +3 -1
- package/dist/plugins/svelte/index.d.ts +2 -1
- package/dist/plugins/svelte/index.js +6 -0
- package/dist/plugins/typedoc/index.js +3 -1
- package/dist/plugins/typescript/index.js +6 -8
- package/dist/plugins/vite/index.js +2 -2
- package/dist/plugins/vitest/index.d.ts +3 -3
- package/dist/plugins/vitest/index.js +17 -12
- package/dist/plugins/vitest/types.d.ts +2 -0
- package/dist/plugins/webpack/index.js +3 -1
- package/dist/reporters/compact.js +1 -1
- package/dist/reporters/json.js +1 -1
- package/dist/types/config.d.ts +6 -4
- package/dist/types/config.js +1 -1
- package/dist/types/exports.d.ts +1 -1
- package/dist/types/issues.d.ts +1 -0
- package/dist/types/plugins.d.ts +3 -3
- package/dist/types/workspace.d.ts +1 -1
- package/dist/typescript/ast-helpers.d.ts +2 -2
- package/dist/typescript/ast-helpers.js +11 -3
- package/dist/typescript/getImportsAndExports.js +7 -6
- package/dist/typescript/resolveModuleNames.js +19 -1
- package/dist/typescript/visitors/imports/index.js +2 -2
- package/dist/typescript/visitors/imports/{requireResolveCall.js → propertyAccessCall.js} +2 -2
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +2 -0
- package/dist/util/compilers.d.ts +10 -0
- package/dist/util/modules.d.ts +1 -0
- package/dist/util/modules.js +1 -0
- package/dist/util/plugin.d.ts +6 -0
- package/dist/util/plugin.js +13 -0
- package/dist/util/protocols.d.ts +9 -0
- package/dist/util/protocols.js +9 -0
- package/dist/util/tsconfig-loader.d.ts +4 -1
- package/dist/util/tsconfig-loader.js +4 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -13
- package/schema.json +12 -0
- /package/dist/typescript/visitors/imports/{requireResolveCall.d.ts → propertyAccessCall.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -253,6 +253,7 @@ Knip contains a growing list of plugins:
|
|
|
253
253
|
- [commitlint][plugin-commitlint]
|
|
254
254
|
- [cspell][plugin-cspell]
|
|
255
255
|
- [Cypress][plugin-cypress]
|
|
256
|
+
- [Drizzle][plugin-drizzle]
|
|
256
257
|
- [ESLint][plugin-eslint]
|
|
257
258
|
- [Gatsby][plugin-gatsby]
|
|
258
259
|
- [GitHub Actions][plugin-github-actions]
|
|
@@ -263,10 +264,12 @@ Knip contains a growing list of plugins:
|
|
|
263
264
|
- [markdownlint][plugin-markdownlint]
|
|
264
265
|
- [Mocha][plugin-mocha]
|
|
265
266
|
- [Next.js][plugin-next]
|
|
267
|
+
- [Node.js Test Runner][plugin-node-test-runner]
|
|
266
268
|
- [npm-package-json-lint][plugin-npm-package-json-lint]
|
|
267
269
|
- [Nx][plugin-nx]
|
|
268
270
|
- [nyc][plugin-nyc]
|
|
269
271
|
- [Playwright][plugin-playwright]
|
|
272
|
+
- [Playwright for components][plugin-playwright-ct]
|
|
270
273
|
- [PostCSS][plugin-postcss]
|
|
271
274
|
- [Prettier][plugin-prettier]
|
|
272
275
|
- [Release It][plugin-release-it]
|
|
@@ -321,6 +324,21 @@ has them at `e2e-tests/*.spec.ts`. Here's how to configure this:
|
|
|
321
324
|
}
|
|
322
325
|
```
|
|
323
326
|
|
|
327
|
+
When overriding any plugin's configuration, the options object is fully replaced. Look at the plugin's page to find the
|
|
328
|
+
default configuration and use that as a basis. Here's another example to override the test file pattern for Vitest:
|
|
329
|
+
|
|
330
|
+
```json
|
|
331
|
+
{
|
|
332
|
+
"vitest": {
|
|
333
|
+
"config": ["vitest.config.ts"],
|
|
334
|
+
"entry": ["**/*.vitest.ts"]
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
This plugin configuration can be set on root and workspace level. If set on root level, it can be disabled on workspace
|
|
340
|
+
level by setting it to `false` there.
|
|
341
|
+
|
|
324
342
|
#### Multi-project repositories
|
|
325
343
|
|
|
326
344
|
Some repositories have a single `package.json`, but consist of multiple projects with configuration files across the
|
|
@@ -663,6 +681,7 @@ Knip takes the following JSDoc/TSDoc tags into account:
|
|
|
663
681
|
--include-entry-exports Include entry files when reporting unused exports
|
|
664
682
|
-n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)
|
|
665
683
|
--preprocessor Preprocess the results before providing it to the reporter(s), can be repeated
|
|
684
|
+
--preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)
|
|
666
685
|
--reporter Select reporter: symbols, compact, codeowners, json, can be repeated (default: symbols)
|
|
667
686
|
--reporter-options Pass extra options to the reporter (as JSON string, see example)
|
|
668
687
|
--no-config-hints Suppress configuration hints
|
|
@@ -800,7 +819,7 @@ Special thanks to the wonderful people who have contributed to this project:
|
|
|
800
819
|
[7]: #jsdoc-tags
|
|
801
820
|
[8]: https://labs.openai.com/s/xZQACaLepaKya0PRUPtIN5dC
|
|
802
821
|
[9]: ./assets/cow-with-orange-scissors-van-gogh-style.webp
|
|
803
|
-
[10]: https://discord.gg/
|
|
822
|
+
[10]: https://discord.gg/r5uXTtbTpc
|
|
804
823
|
[11]: https://twitter.com/webprolific
|
|
805
824
|
[12]: https://fosstodon.org/@webpro
|
|
806
825
|
[13]: https://github.com/webpro/knip/issues
|
|
@@ -873,6 +892,7 @@ Special thanks to the wonderful people who have contributed to this project:
|
|
|
873
892
|
[plugin-commitlint]: ./src/plugins/commitlint
|
|
874
893
|
[plugin-cspell]: ./src/plugins/cspell
|
|
875
894
|
[plugin-cypress]: ./src/plugins/cypress
|
|
895
|
+
[plugin-drizzle]: ./src/plugins/drizzle
|
|
876
896
|
[plugin-eslint]: ./src/plugins/eslint
|
|
877
897
|
[plugin-gatsby]: ./src/plugins/gatsby
|
|
878
898
|
[plugin-github-actions]: ./src/plugins/github-actions
|
|
@@ -883,10 +903,12 @@ Special thanks to the wonderful people who have contributed to this project:
|
|
|
883
903
|
[plugin-markdownlint]: ./src/plugins/markdownlint
|
|
884
904
|
[plugin-mocha]: ./src/plugins/mocha
|
|
885
905
|
[plugin-next]: ./src/plugins/next
|
|
906
|
+
[plugin-node-test-runner]: ./src/plugins/node-test-runner
|
|
886
907
|
[plugin-npm-package-json-lint]: ./src/plugins/npm-package-json-lint
|
|
887
908
|
[plugin-nx]: ./src/plugins/nx
|
|
888
909
|
[plugin-nyc]: ./src/plugins/nyc
|
|
889
910
|
[plugin-playwright]: ./src/plugins/playwright
|
|
911
|
+
[plugin-playwright-ct]: ./src/plugins/playwright-ct
|
|
890
912
|
[plugin-postcss]: ./src/plugins/postcss
|
|
891
913
|
[plugin-prettier]: ./src/plugins/prettier
|
|
892
914
|
[plugin-release-it]: ./src/plugins/release-it
|
|
@@ -15,7 +15,7 @@ import { _dirGlob } from './util/glob.js';
|
|
|
15
15
|
import { _load } from './util/loader.js';
|
|
16
16
|
import { getKeysByValue } from './util/object.js';
|
|
17
17
|
import { join, relative, toPosix } from './util/path.js';
|
|
18
|
-
import { toCamelCase } from './util/plugin.js';
|
|
18
|
+
import { normalizePluginConfig, toCamelCase } from './util/plugin.js';
|
|
19
19
|
import { byPathDepth } from './util/workspace.js';
|
|
20
20
|
const { config: rawConfigArg, workspace: rawWorkspaceArg, include = [], exclude = [], dependencies = false, exports = false, } = parsedArgValues;
|
|
21
21
|
const workspaceArg = rawWorkspaceArg ? toPosix(rawWorkspaceArg).replace(/^\.\//, '').replace(/\/$/, '') : undefined;
|
|
@@ -116,6 +116,13 @@ export class ConfigurationChief {
|
|
|
116
116
|
const { syncCompilers, asyncCompilers } = rawLocalConfig;
|
|
117
117
|
const extensions = [...Object.keys(syncCompilers ?? {}), ...Object.keys(asyncCompilers ?? {})];
|
|
118
118
|
const defaultWorkspaceConfig = getDefaultWorkspaceConfig(extensions);
|
|
119
|
+
const rootPluginConfigs = {};
|
|
120
|
+
for (const [name, pluginConfig] of Object.entries(rawLocalConfig)) {
|
|
121
|
+
const pluginName = toCamelCase(name);
|
|
122
|
+
if (PLUGIN_NAMES.includes(pluginName)) {
|
|
123
|
+
rootPluginConfigs[pluginName] = normalizePluginConfig(pluginConfig);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
119
126
|
const workspaces = Object.entries(initialWorkspaces)
|
|
120
127
|
.filter(([workspaceName]) => !ignoreWorkspaces.includes(workspaceName))
|
|
121
128
|
.reduce((workspaces, workspace) => {
|
|
@@ -131,23 +138,15 @@ export class ConfigurationChief {
|
|
|
131
138
|
ignoreBinaries: arrayify(workspaceConfig.ignoreBinaries),
|
|
132
139
|
ignoreDependencies: arrayify(workspaceConfig.ignoreDependencies),
|
|
133
140
|
};
|
|
141
|
+
for (const [name, pluginConfig] of Object.entries(rootPluginConfigs)) {
|
|
142
|
+
const pluginName = toCamelCase(name);
|
|
143
|
+
if (pluginConfig)
|
|
144
|
+
workspaces[workspaceName][pluginName] = pluginConfig;
|
|
145
|
+
}
|
|
134
146
|
for (const [name, pluginConfig] of Object.entries(workspaceConfig)) {
|
|
135
147
|
const pluginName = toCamelCase(name);
|
|
136
148
|
if (PLUGIN_NAMES.includes(pluginName)) {
|
|
137
|
-
|
|
138
|
-
workspaces[workspaceName][pluginName] = false;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
const isObject = typeof pluginConfig !== 'string' && !Array.isArray(pluginConfig);
|
|
142
|
-
const config = isObject ? arrayify(pluginConfig.config) : pluginConfig ? arrayify(pluginConfig) : null;
|
|
143
|
-
const entry = isObject && 'entry' in pluginConfig ? arrayify(pluginConfig.entry) : null;
|
|
144
|
-
const project = isObject && 'project' in pluginConfig ? arrayify(pluginConfig.project) : entry;
|
|
145
|
-
workspaces[workspaceName][pluginName] = {
|
|
146
|
-
config,
|
|
147
|
-
entry,
|
|
148
|
-
project,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
149
|
+
workspaces[workspaceName][pluginName] = normalizePluginConfig(pluginConfig);
|
|
151
150
|
}
|
|
152
151
|
}
|
|
153
152
|
return workspaces;
|
|
@@ -233,7 +232,7 @@ export class ConfigurationChief {
|
|
|
233
232
|
: this.availableWorkspaceNames;
|
|
234
233
|
return workspaceNames.sort(byPathDepth).map((name) => ({
|
|
235
234
|
name,
|
|
236
|
-
pkgName: this.manifestWorkspaces.get(name) ?? this.manifest?.name
|
|
235
|
+
pkgName: this.manifestWorkspaces.get(name) ?? this.manifest?.name ?? `NOT_FOUND_${name}`,
|
|
237
236
|
dir: join(this.cwd, name),
|
|
238
237
|
config: this.getConfigForWorkspace(name),
|
|
239
238
|
ancestors: this.availableWorkspaceNames.reduce(getAncestors(name), []),
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export declare const pluginSchema: z.ZodUnion<[z.ZodLiteral<false>, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
3
|
+
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
4
|
+
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
5
|
+
project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
config?: string | string[] | undefined;
|
|
8
|
+
entry?: string | string[] | undefined;
|
|
9
|
+
project?: string | string[] | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
config?: string | string[] | undefined;
|
|
12
|
+
entry?: string | string[] | undefined;
|
|
13
|
+
project?: string | string[] | undefined;
|
|
14
|
+
}>]>;
|
|
2
15
|
export declare const ConfigurationValidator: z.ZodObject<{
|
|
3
16
|
exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
4
17
|
rules: z.ZodOptional<z.ZodRecord<z.ZodUnion<[z.ZodLiteral<"files">, z.ZodLiteral<"dependencies">, z.ZodLiteral<"devDependencies">, z.ZodLiteral<"unlisted">, z.ZodLiteral<"binaries">, z.ZodLiteral<"unresolved">, z.ZodLiteral<"exports">, z.ZodLiteral<"types">, z.ZodLiteral<"nsExports">, z.ZodLiteral<"nsTypes">, z.ZodLiteral<"duplicates">, z.ZodLiteral<"enumMembers">, z.ZodLiteral<"classMembers">]>, z.ZodEnum<["error", "warn", "off"]>>>;
|
|
@@ -268,6 +281,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
268
281
|
entry?: string | string[] | undefined;
|
|
269
282
|
project?: string | string[] | undefined;
|
|
270
283
|
}>]>>;
|
|
284
|
+
'node-test-runner': z.ZodOptional<z.ZodUnion<[z.ZodLiteral<false>, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
285
|
+
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
286
|
+
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
287
|
+
project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
288
|
+
}, "strip", z.ZodTypeAny, {
|
|
289
|
+
config?: string | string[] | undefined;
|
|
290
|
+
entry?: string | string[] | undefined;
|
|
291
|
+
project?: string | string[] | undefined;
|
|
292
|
+
}, {
|
|
293
|
+
config?: string | string[] | undefined;
|
|
294
|
+
entry?: string | string[] | undefined;
|
|
295
|
+
project?: string | string[] | undefined;
|
|
296
|
+
}>]>>;
|
|
271
297
|
'npm-package-json-lint': z.ZodOptional<z.ZodUnion<[z.ZodLiteral<false>, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
272
298
|
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
273
299
|
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
@@ -643,6 +669,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
643
669
|
entry?: string | string[] | undefined;
|
|
644
670
|
project?: string | string[] | undefined;
|
|
645
671
|
} | undefined;
|
|
672
|
+
'node-test-runner'?: string | false | string[] | {
|
|
673
|
+
config?: string | string[] | undefined;
|
|
674
|
+
entry?: string | string[] | undefined;
|
|
675
|
+
project?: string | string[] | undefined;
|
|
676
|
+
} | undefined;
|
|
646
677
|
'npm-package-json-lint'?: string | false | string[] | {
|
|
647
678
|
config?: string | string[] | undefined;
|
|
648
679
|
entry?: string | string[] | undefined;
|
|
@@ -850,6 +881,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
850
881
|
entry?: string | string[] | undefined;
|
|
851
882
|
project?: string | string[] | undefined;
|
|
852
883
|
} | undefined;
|
|
884
|
+
'node-test-runner'?: string | false | string[] | {
|
|
885
|
+
config?: string | string[] | undefined;
|
|
886
|
+
entry?: string | string[] | undefined;
|
|
887
|
+
project?: string | string[] | undefined;
|
|
888
|
+
} | undefined;
|
|
853
889
|
'npm-package-json-lint'?: string | false | string[] | {
|
|
854
890
|
config?: string | string[] | undefined;
|
|
855
891
|
entry?: string | string[] | undefined;
|
|
@@ -1203,6 +1239,19 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1203
1239
|
entry?: string | string[] | undefined;
|
|
1204
1240
|
project?: string | string[] | undefined;
|
|
1205
1241
|
}>]>>;
|
|
1242
|
+
'node-test-runner': z.ZodOptional<z.ZodUnion<[z.ZodLiteral<false>, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
1243
|
+
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1244
|
+
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1245
|
+
project: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1246
|
+
}, "strip", z.ZodTypeAny, {
|
|
1247
|
+
config?: string | string[] | undefined;
|
|
1248
|
+
entry?: string | string[] | undefined;
|
|
1249
|
+
project?: string | string[] | undefined;
|
|
1250
|
+
}, {
|
|
1251
|
+
config?: string | string[] | undefined;
|
|
1252
|
+
entry?: string | string[] | undefined;
|
|
1253
|
+
project?: string | string[] | undefined;
|
|
1254
|
+
}>]>>;
|
|
1206
1255
|
'npm-package-json-lint': z.ZodOptional<z.ZodUnion<[z.ZodLiteral<false>, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodObject<{
|
|
1207
1256
|
config: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
1208
1257
|
entry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
@@ -1593,6 +1642,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1593
1642
|
entry?: string | string[] | undefined;
|
|
1594
1643
|
project?: string | string[] | undefined;
|
|
1595
1644
|
} | undefined;
|
|
1645
|
+
'node-test-runner'?: string | false | string[] | {
|
|
1646
|
+
config?: string | string[] | undefined;
|
|
1647
|
+
entry?: string | string[] | undefined;
|
|
1648
|
+
project?: string | string[] | undefined;
|
|
1649
|
+
} | undefined;
|
|
1596
1650
|
'npm-package-json-lint'?: string | false | string[] | {
|
|
1597
1651
|
config?: string | string[] | undefined;
|
|
1598
1652
|
entry?: string | string[] | undefined;
|
|
@@ -1794,6 +1848,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1794
1848
|
entry?: string | string[] | undefined;
|
|
1795
1849
|
project?: string | string[] | undefined;
|
|
1796
1850
|
} | undefined;
|
|
1851
|
+
'node-test-runner'?: string | false | string[] | {
|
|
1852
|
+
config?: string | string[] | undefined;
|
|
1853
|
+
entry?: string | string[] | undefined;
|
|
1854
|
+
project?: string | string[] | undefined;
|
|
1855
|
+
} | undefined;
|
|
1797
1856
|
'npm-package-json-lint'?: string | false | string[] | {
|
|
1798
1857
|
config?: string | string[] | undefined;
|
|
1799
1858
|
entry?: string | string[] | undefined;
|
|
@@ -2016,6 +2075,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
2016
2075
|
entry?: string | string[] | undefined;
|
|
2017
2076
|
project?: string | string[] | undefined;
|
|
2018
2077
|
} | undefined;
|
|
2078
|
+
'node-test-runner'?: string | false | string[] | {
|
|
2079
|
+
config?: string | string[] | undefined;
|
|
2080
|
+
entry?: string | string[] | undefined;
|
|
2081
|
+
project?: string | string[] | undefined;
|
|
2082
|
+
} | undefined;
|
|
2019
2083
|
'npm-package-json-lint'?: string | false | string[] | {
|
|
2020
2084
|
config?: string | string[] | undefined;
|
|
2021
2085
|
entry?: string | string[] | undefined;
|
|
@@ -2217,6 +2281,11 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
2217
2281
|
entry?: string | string[] | undefined;
|
|
2218
2282
|
project?: string | string[] | undefined;
|
|
2219
2283
|
} | undefined;
|
|
2284
|
+
'node-test-runner'?: string | false | string[] | {
|
|
2285
|
+
config?: string | string[] | undefined;
|
|
2286
|
+
entry?: string | string[] | undefined;
|
|
2287
|
+
project?: string | string[] | undefined;
|
|
2288
|
+
} | undefined;
|
|
2220
2289
|
'npm-package-json-lint'?: string | false | string[] | {
|
|
2221
2290
|
config?: string | string[] | undefined;
|
|
2222
2291
|
entry?: string | string[] | undefined;
|
|
@@ -50,7 +50,7 @@ const reportConfigSchema = z.object({
|
|
|
50
50
|
include: z.array(z.string()).optional(),
|
|
51
51
|
exclude: z.array(z.string()).optional(),
|
|
52
52
|
});
|
|
53
|
-
const pluginSchema = z.union([
|
|
53
|
+
export const pluginSchema = z.union([
|
|
54
54
|
z.literal(false),
|
|
55
55
|
globSchema,
|
|
56
56
|
z.object({
|
|
@@ -79,6 +79,7 @@ const pluginsSchema = z.object({
|
|
|
79
79
|
markdownlint: pluginSchema,
|
|
80
80
|
mocha: pluginSchema,
|
|
81
81
|
next: pluginSchema,
|
|
82
|
+
'node-test-runner': pluginSchema,
|
|
82
83
|
'npm-package-json-lint': pluginSchema,
|
|
83
84
|
nx: pluginSchema,
|
|
84
85
|
nyc: pluginSchema,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="npmcli__package-json" />
|
|
2
2
|
import type { Workspace } from './ConfigurationChief.js';
|
|
3
3
|
import type { ConfigurationHints, Issue } from './types/issues.js';
|
|
4
|
-
import type { WorkspaceManifests } from './types/workspace.js';
|
|
5
|
-
import type { PeerDependencies, InstalledBinaries } from './types/workspace.js';
|
|
4
|
+
import type { WorkspaceManifests, HostDependencies, InstalledBinaries } from './types/workspace.js';
|
|
6
5
|
import type { PackageJson } from '@npmcli/package-json';
|
|
7
6
|
type Options = {
|
|
8
7
|
isStrict: boolean;
|
|
@@ -12,7 +11,7 @@ export declare class DependencyDeputy {
|
|
|
12
11
|
_manifests: WorkspaceManifests;
|
|
13
12
|
referencedDependencies: Map<string, Set<string>>;
|
|
14
13
|
referencedBinaries: Map<string, Set<string>>;
|
|
15
|
-
|
|
14
|
+
hostDependencies: Map<string, HostDependencies>;
|
|
16
15
|
installedBinaries: Map<string, InstalledBinaries>;
|
|
17
16
|
ignoreBinaries: string[];
|
|
18
17
|
ignoreDependencies: string[];
|
|
@@ -45,8 +44,8 @@ export declare class DependencyDeputy {
|
|
|
45
44
|
getInstalledBinaries(workspaceName: string): InstalledBinaries | undefined;
|
|
46
45
|
addReferencedDependency(workspaceName: string, packageName: string): void;
|
|
47
46
|
addReferencedBinary(workspaceName: string, binaryName: string): void;
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
addHostDependencies(workspaceName: string, hostDependencies: HostDependencies): void;
|
|
48
|
+
getHostDependenciesFor(workspaceName: string, dependency: string): string[];
|
|
50
49
|
getPeerDependencies(workspaceName: string): string[];
|
|
51
50
|
getOptionalPeerDependencies(workspaceName: string): string[];
|
|
52
51
|
maybeAddReferencedExternalDependency(workspace: Workspace, packageName: string): boolean;
|
package/dist/DependencyDeputy.js
CHANGED
|
@@ -6,7 +6,7 @@ export class DependencyDeputy {
|
|
|
6
6
|
_manifests = new Map();
|
|
7
7
|
referencedDependencies;
|
|
8
8
|
referencedBinaries;
|
|
9
|
-
|
|
9
|
+
hostDependencies;
|
|
10
10
|
installedBinaries;
|
|
11
11
|
ignoreBinaries = [];
|
|
12
12
|
ignoreDependencies = [];
|
|
@@ -14,7 +14,7 @@ export class DependencyDeputy {
|
|
|
14
14
|
this.isStrict = isStrict;
|
|
15
15
|
this.referencedDependencies = new Map();
|
|
16
16
|
this.referencedBinaries = new Map();
|
|
17
|
-
this.
|
|
17
|
+
this.hostDependencies = new Map();
|
|
18
18
|
this.installedBinaries = new Map();
|
|
19
19
|
}
|
|
20
20
|
addWorkspace({ name, dir, manifestPath, manifest, ignoreDependencies, ignoreBinaries, }) {
|
|
@@ -79,11 +79,11 @@ export class DependencyDeputy {
|
|
|
79
79
|
}
|
|
80
80
|
this.referencedBinaries.get(workspaceName)?.add(binaryName);
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
this.
|
|
82
|
+
addHostDependencies(workspaceName, hostDependencies) {
|
|
83
|
+
this.hostDependencies.set(workspaceName, hostDependencies);
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
return Array.from(this.
|
|
85
|
+
getHostDependenciesFor(workspaceName, dependency) {
|
|
86
|
+
return Array.from(this.hostDependencies.get(workspaceName)?.get(dependency) ?? []);
|
|
87
87
|
}
|
|
88
88
|
getPeerDependencies(workspaceName) {
|
|
89
89
|
const manifest = this._manifests.get(workspaceName);
|
|
@@ -179,17 +179,19 @@ export class DependencyDeputy {
|
|
|
179
179
|
const typedPackageName = getPackageFromDefinitelyTyped(typedDependency);
|
|
180
180
|
if (IGNORE_DEFINITELY_TYPED.includes(typedPackageName))
|
|
181
181
|
return true;
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
const hostDependencies = [
|
|
183
|
+
...this.getHostDependenciesFor(workspaceName, dependency),
|
|
184
|
+
...this.getHostDependenciesFor(workspaceName, typedPackageName),
|
|
185
|
+
];
|
|
186
|
+
if (hostDependencies.length)
|
|
187
|
+
return !!hostDependencies.find(host => isReferencedDependency(host, true));
|
|
186
188
|
if (!referencedDependencies)
|
|
187
189
|
return false;
|
|
188
190
|
return referencedDependencies.has(typedPackageName);
|
|
189
191
|
}
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
return
|
|
192
|
+
const hostDependencies = this.getHostDependenciesFor(workspaceName, dependency);
|
|
193
|
+
hostDependencies.forEach(dep => (!peerDepRecs[dep] ? (peerDepRecs[dep] = 1) : peerDepRecs[dep]++));
|
|
194
|
+
return hostDependencies.some(peerDependency => isReferencedDependency(peerDependency, true));
|
|
193
195
|
};
|
|
194
196
|
const isNotReferencedDependency = (dependency) => !isReferencedDependency(dependency);
|
|
195
197
|
const pd = this.getProductionDependencies(workspaceName);
|
|
@@ -6,6 +6,7 @@ type Principal = {
|
|
|
6
6
|
principal: ProjectPrincipal;
|
|
7
7
|
cwds: Set<string>;
|
|
8
8
|
pathKeys: Set<string>;
|
|
9
|
+
pkgNames: Set<string>;
|
|
9
10
|
};
|
|
10
11
|
type Principals = Set<Principal>;
|
|
11
12
|
type Options = {
|
|
@@ -13,6 +14,7 @@ type Options = {
|
|
|
13
14
|
compilerOptions: ts.CompilerOptions;
|
|
14
15
|
paths: Paths;
|
|
15
16
|
compilers: [SyncCompilers, AsyncCompilers];
|
|
17
|
+
pkgName: string;
|
|
16
18
|
};
|
|
17
19
|
export declare class PrincipalFactory {
|
|
18
20
|
principals: Principals;
|
|
@@ -21,5 +23,6 @@ export declare class PrincipalFactory {
|
|
|
21
23
|
private linkPrincipal;
|
|
22
24
|
private addNewPrincipal;
|
|
23
25
|
getPrincipals(): ProjectPrincipal[];
|
|
26
|
+
getPrincipalByPackageName(packageName: string): ProjectPrincipal | undefined;
|
|
24
27
|
}
|
|
25
28
|
export {};
|
package/dist/PrincipalFactory.js
CHANGED
|
@@ -12,11 +12,11 @@ const mergePaths = (cwd, compilerOptions, paths = {}) => {
|
|
|
12
12
|
export class PrincipalFactory {
|
|
13
13
|
principals = new Set();
|
|
14
14
|
getPrincipal(options) {
|
|
15
|
-
const { cwd, compilerOptions, paths } = options;
|
|
15
|
+
const { cwd, compilerOptions, paths, pkgName } = options;
|
|
16
16
|
options.compilerOptions = mergePaths(cwd, compilerOptions, paths);
|
|
17
17
|
const principal = this.findReusablePrincipal(compilerOptions);
|
|
18
18
|
if (principal) {
|
|
19
|
-
this.linkPrincipal(principal, cwd, compilerOptions);
|
|
19
|
+
this.linkPrincipal(principal, cwd, compilerOptions, pkgName);
|
|
20
20
|
return principal.principal;
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
@@ -35,22 +35,26 @@ export class PrincipalFactory {
|
|
|
35
35
|
});
|
|
36
36
|
return principal;
|
|
37
37
|
}
|
|
38
|
-
linkPrincipal(principal, cwd, compilerOptions) {
|
|
38
|
+
linkPrincipal(principal, cwd, compilerOptions, pkgName) {
|
|
39
39
|
const { pathsBasePath, paths } = compilerOptions;
|
|
40
40
|
if (pathsBasePath)
|
|
41
41
|
principal.principal.compilerOptions.pathsBasePath = pathsBasePath;
|
|
42
42
|
Object.keys(paths ?? {}).forEach(p => principal.pathKeys.add(p));
|
|
43
43
|
principal.principal.compilerOptions.paths = { ...principal.principal.compilerOptions.paths, ...paths };
|
|
44
44
|
principal.cwds.add(cwd);
|
|
45
|
+
principal.pkgNames.add(pkgName);
|
|
45
46
|
}
|
|
46
47
|
addNewPrincipal(options) {
|
|
47
|
-
const { cwd, compilerOptions } = options;
|
|
48
|
+
const { cwd, compilerOptions, pkgName } = options;
|
|
48
49
|
const pathKeys = new Set(Object.keys(compilerOptions?.paths ?? {}));
|
|
49
50
|
const principal = new ProjectPrincipal(options);
|
|
50
|
-
this.principals.add({ principal, cwds: new Set([cwd]), pathKeys });
|
|
51
|
+
this.principals.add({ principal, cwds: new Set([cwd]), pathKeys, pkgNames: new Set([pkgName]) });
|
|
51
52
|
return principal;
|
|
52
53
|
}
|
|
53
54
|
getPrincipals() {
|
|
54
|
-
return Array.from(this.principals
|
|
55
|
+
return Array.from(this.principals, p => p.principal).reverse();
|
|
56
|
+
}
|
|
57
|
+
getPrincipalByPackageName(packageName) {
|
|
58
|
+
return Array.from(this.principals).find(principal => principal.pkgNames.has(packageName))?.principal;
|
|
55
59
|
}
|
|
56
60
|
}
|
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getJSDocTags, isInModuleBlock } from './typescript/ast-helpers.js';
|
|
|
6
6
|
import { createHosts } from './typescript/createHosts.js';
|
|
7
7
|
import { getImportsAndExports } from './typescript/getImportsAndExports.js';
|
|
8
8
|
import { SourceFileManager } from './typescript/SourceFileManager.js';
|
|
9
|
-
import { isMaybePackageName } from './util/modules.js';
|
|
9
|
+
import { isMaybePackageName, sanitizeSpecifier } from './util/modules.js';
|
|
10
10
|
import { dirname, extname, isInNodeModules, join } from './util/path.js';
|
|
11
11
|
import { timerify } from './util/Performance.js';
|
|
12
12
|
const baseCompilerOptions = {
|
|
@@ -107,7 +107,7 @@ export class ProjectPrincipal {
|
|
|
107
107
|
return Array.from(this.projectPaths).filter(filePath => !sourceFiles.has(filePath));
|
|
108
108
|
}
|
|
109
109
|
analyzeSourceFile(filePath, { skipTypeOnly }) {
|
|
110
|
-
const sourceFile = this.backend.
|
|
110
|
+
const sourceFile = this.backend.fileManager.getSourceFile(filePath);
|
|
111
111
|
if (!sourceFile)
|
|
112
112
|
throw new Error(`Unable to find ${filePath}`);
|
|
113
113
|
const skipExports = this.skipExportsAnalysis.has(filePath);
|
|
@@ -128,7 +128,7 @@ export class ProjectPrincipal {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
|
-
const sanitizedSpecifier = specifier
|
|
131
|
+
const sanitizedSpecifier = sanitizeSpecifier(specifier);
|
|
132
132
|
if (isMaybePackageName(sanitizedSpecifier)) {
|
|
133
133
|
external.add(sanitizedSpecifier);
|
|
134
134
|
}
|
|
@@ -178,7 +178,7 @@ export class ProjectPrincipal {
|
|
|
178
178
|
findUnusedMembers(filePath, members) {
|
|
179
179
|
return members
|
|
180
180
|
.filter(member => {
|
|
181
|
-
if (getJSDocTags(member.node).
|
|
181
|
+
if (getJSDocTags(member.node).has('@public'))
|
|
182
182
|
return false;
|
|
183
183
|
const referencedSymbols = this.findReferences(filePath, member.pos);
|
|
184
184
|
const files = referencedSymbols
|
|
@@ -192,6 +192,11 @@ export class ProjectPrincipal {
|
|
|
192
192
|
.map(member => member.identifier);
|
|
193
193
|
}
|
|
194
194
|
findReferences(filePath, pos) {
|
|
195
|
-
|
|
195
|
+
try {
|
|
196
|
+
return this.backend.lsFindReferences(filePath, pos) ?? [];
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
return [];
|
|
200
|
+
}
|
|
196
201
|
}
|
|
197
202
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Configuration, PluginName, WorkspaceConfiguration } from './types/config.js';
|
|
2
2
|
import type { PackageJsonWithPlugins } from './types/plugins.js';
|
|
3
|
-
import type { InstalledBinaries,
|
|
3
|
+
import type { InstalledBinaries, HostDependencies } from './types/workspace.js';
|
|
4
4
|
type WorkspaceManagerOptions = {
|
|
5
5
|
name: string;
|
|
6
6
|
dir: string;
|
|
@@ -28,29 +28,31 @@ export declare class WorkspaceWorker {
|
|
|
28
28
|
enabled: Record<PluginName, boolean>;
|
|
29
29
|
enabledPlugins: PluginName[];
|
|
30
30
|
referencedDependencies: ReferencedDependencies;
|
|
31
|
-
|
|
31
|
+
hostDependencies: HostDependencies;
|
|
32
32
|
installedBinaries: InstalledBinaries;
|
|
33
|
+
entryFilePatterns: Set<string>;
|
|
34
|
+
productionEntryFilePatterns: Set<string>;
|
|
33
35
|
constructor({ name, dir, cwd, config, manifest, isProduction, isStrict, rootIgnore, negatedWorkspacePatterns, enabledPluginsInAncestors, }: WorkspaceManagerOptions);
|
|
34
36
|
init(): Promise<void>;
|
|
35
37
|
private setEnabledPlugins;
|
|
36
38
|
private initReferencedDependencies;
|
|
37
39
|
private getConfigForPlugin;
|
|
38
40
|
getEntryFilePatterns(): string[];
|
|
39
|
-
getProjectFilePatterns(): string[];
|
|
40
|
-
getPluginEntryFilePatterns(isIncludeProductionEntryFiles?: boolean): string[];
|
|
41
|
+
getProjectFilePatterns(testFilePatterns: string[]): string[];
|
|
41
42
|
getPluginProjectFilePatterns(): string[];
|
|
42
43
|
getPluginConfigPatterns(): string[];
|
|
43
|
-
getProductionEntryFilePatterns(): string[];
|
|
44
|
-
getProductionProjectFilePatterns(): string[];
|
|
45
|
-
getProductionPluginEntryFilePatterns(): string[];
|
|
44
|
+
getProductionEntryFilePatterns(negatedTestFilePatterns: string[]): string[];
|
|
45
|
+
getProductionProjectFilePatterns(negatedTestFilePatterns: string[]): string[];
|
|
46
46
|
private getConfigurationFilePatterns;
|
|
47
47
|
getIgnorePatterns(): string[];
|
|
48
48
|
private findDependenciesByPlugins;
|
|
49
49
|
findAllDependencies(): Promise<{
|
|
50
|
-
|
|
50
|
+
hostDependencies: HostDependencies;
|
|
51
51
|
installedBinaries: InstalledBinaries;
|
|
52
52
|
referencedDependencies: ReferencedDependencies;
|
|
53
|
-
enabledPlugins: ("angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "typedoc" | "typescript" | "vite" | "vitest" | "webpack" | "githubActions" | "lintStaged" | "npmPackageJsonLint" | "releaseIt" | "semanticRelease" | "svelte")[];
|
|
53
|
+
enabledPlugins: ("angular" | "ava" | "babel" | "capacitor" | "changesets" | "commitizen" | "commitlint" | "cspell" | "cypress" | "eslint" | "gatsby" | "husky" | "jest" | "lefthook" | "markdownlint" | "mocha" | "next" | "nx" | "nyc" | "playwright" | "postcss" | "prettier" | "remark" | "remix" | "rollup" | "sentry" | "storybook" | "stryker" | "stylelint" | "tailwind" | "typedoc" | "typescript" | "vite" | "vitest" | "webpack" | "drizzle" | "githubActions" | "lintStaged" | "nodeTestRunner" | "npmPackageJsonLint" | "playwrightCt" | "releaseIt" | "semanticRelease" | "svelte")[];
|
|
54
|
+
entryFilePatterns: string[];
|
|
55
|
+
productionEntryFilePatterns: string[];
|
|
54
56
|
}>;
|
|
55
57
|
}
|
|
56
58
|
export {};
|