knip 0.0.0-angular.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.
Files changed (326) hide show
  1. package/README.md +907 -0
  2. package/dist/ConfigurationChief.d.ts +53 -0
  3. package/dist/ConfigurationChief.js +297 -0
  4. package/dist/ConfigurationValidator.d.ts +2325 -0
  5. package/dist/ConfigurationValidator.js +119 -0
  6. package/dist/ConsoleStreamer.d.ts +12 -0
  7. package/dist/ConsoleStreamer.js +34 -0
  8. package/dist/DependencyDeputy.d.ts +64 -0
  9. package/dist/DependencyDeputy.js +254 -0
  10. package/dist/IssueCollector.d.ts +27 -0
  11. package/dist/IssueCollector.js +52 -0
  12. package/dist/PrincipalFactory.d.ts +25 -0
  13. package/dist/PrincipalFactory.js +56 -0
  14. package/dist/ProjectPrincipal.d.ts +64 -0
  15. package/dist/ProjectPrincipal.js +197 -0
  16. package/dist/WorkspaceWorker.d.ts +56 -0
  17. package/dist/WorkspaceWorker.js +244 -0
  18. package/dist/binaries/bash-parser.d.ts +6 -0
  19. package/dist/binaries/bash-parser.js +58 -0
  20. package/dist/binaries/index.d.ts +2 -0
  21. package/dist/binaries/index.js +18 -0
  22. package/dist/binaries/resolvers/c8.d.ts +2 -0
  23. package/dist/binaries/resolvers/c8.js +10 -0
  24. package/dist/binaries/resolvers/dotenv.d.ts +2 -0
  25. package/dist/binaries/resolvers/dotenv.js +6 -0
  26. package/dist/binaries/resolvers/fallback.d.ts +2 -0
  27. package/dist/binaries/resolvers/fallback.js +22 -0
  28. package/dist/binaries/resolvers/index.d.ts +8 -0
  29. package/dist/binaries/resolvers/index.js +8 -0
  30. package/dist/binaries/resolvers/node.d.ts +2 -0
  31. package/dist/binaries/resolvers/node.js +10 -0
  32. package/dist/binaries/resolvers/nodemon.d.ts +2 -0
  33. package/dist/binaries/resolvers/nodemon.js +15 -0
  34. package/dist/binaries/resolvers/npx.d.ts +2 -0
  35. package/dist/binaries/resolvers/npx.js +20 -0
  36. package/dist/binaries/resolvers/pnpm.d.ts +2 -0
  37. package/dist/binaries/resolvers/pnpm.js +63 -0
  38. package/dist/binaries/resolvers/rollup.d.ts +2 -0
  39. package/dist/binaries/resolvers/rollup.js +11 -0
  40. package/dist/binaries/resolvers/yarn.d.ts +2 -0
  41. package/dist/binaries/resolvers/yarn.js +48 -0
  42. package/dist/binaries/types.d.ts +15 -0
  43. package/dist/binaries/types.js +1 -0
  44. package/dist/binaries/util.d.ts +8 -0
  45. package/dist/binaries/util.js +33 -0
  46. package/dist/cli.d.ts +2 -0
  47. package/dist/cli.js +72 -0
  48. package/dist/constants.d.ts +12 -0
  49. package/dist/constants.js +90 -0
  50. package/dist/index.d.ts +10 -0
  51. package/dist/index.js +334 -0
  52. package/dist/issues/initializers.d.ts +4 -0
  53. package/dist/issues/initializers.js +11 -0
  54. package/dist/manifest/helpers.d.ts +7 -0
  55. package/dist/manifest/helpers.js +16 -0
  56. package/dist/manifest/index.d.ts +16 -0
  57. package/dist/manifest/index.js +56 -0
  58. package/dist/plugins/_template/index.d.ts +9 -0
  59. package/dist/plugins/_template/index.js +14 -0
  60. package/dist/plugins/_template/types.d.ts +3 -0
  61. package/dist/plugins/_template/types.js +1 -0
  62. package/dist/plugins/angular/index.d.ts +6 -0
  63. package/dist/plugins/angular/index.js +36 -0
  64. package/dist/plugins/angular/types.d.ts +745 -0
  65. package/dist/plugins/angular/types.js +1 -0
  66. package/dist/plugins/ava/index.d.ts +7 -0
  67. package/dist/plugins/ava/index.js +20 -0
  68. package/dist/plugins/ava/types.d.ts +4 -0
  69. package/dist/plugins/ava/types.js +1 -0
  70. package/dist/plugins/babel/helpers.d.ts +15 -0
  71. package/dist/plugins/babel/helpers.js +34 -0
  72. package/dist/plugins/babel/index.d.ts +8 -0
  73. package/dist/plugins/babel/index.js +30 -0
  74. package/dist/plugins/babel/types.d.ts +9 -0
  75. package/dist/plugins/babel/types.js +1 -0
  76. package/dist/plugins/capacitor/index.d.ts +6 -0
  77. package/dist/plugins/capacitor/index.js +11 -0
  78. package/dist/plugins/capacitor/types.d.ts +3 -0
  79. package/dist/plugins/capacitor/types.js +1 -0
  80. package/dist/plugins/changesets/index.d.ts +6 -0
  81. package/dist/plugins/changesets/index.js +15 -0
  82. package/dist/plugins/commitizen/index.d.ts +6 -0
  83. package/dist/plugins/commitizen/index.js +14 -0
  84. package/dist/plugins/commitizen/types.d.ts +3 -0
  85. package/dist/plugins/commitizen/types.js +1 -0
  86. package/dist/plugins/commitlint/index.d.ts +6 -0
  87. package/dist/plugins/commitlint/index.js +18 -0
  88. package/dist/plugins/cspell/index.d.ts +6 -0
  89. package/dist/plugins/cspell/index.js +17 -0
  90. package/dist/plugins/cspell/types.d.ts +3 -0
  91. package/dist/plugins/cspell/types.js +1 -0
  92. package/dist/plugins/cypress/index.d.ts +5 -0
  93. package/dist/plugins/cypress/index.js +10 -0
  94. package/dist/plugins/eslint/fallback.d.ts +1 -0
  95. package/dist/plugins/eslint/fallback.js +13 -0
  96. package/dist/plugins/eslint/helpers.d.ts +14 -0
  97. package/dist/plugins/eslint/helpers.js +83 -0
  98. package/dist/plugins/eslint/index.d.ts +7 -0
  99. package/dist/plugins/eslint/index.js +15 -0
  100. package/dist/plugins/eslint/types.d.ts +27 -0
  101. package/dist/plugins/eslint/types.js +1 -0
  102. package/dist/plugins/gatsby/index.d.ts +7 -0
  103. package/dist/plugins/gatsby/index.js +30 -0
  104. package/dist/plugins/gatsby/types.d.ts +15 -0
  105. package/dist/plugins/gatsby/types.js +1 -0
  106. package/dist/plugins/github-actions/index.d.ts +6 -0
  107. package/dist/plugins/github-actions/index.js +21 -0
  108. package/dist/plugins/husky/index.d.ts +6 -0
  109. package/dist/plugins/husky/index.js +19 -0
  110. package/dist/plugins/index.d.ts +41 -0
  111. package/dist/plugins/index.js +41 -0
  112. package/dist/plugins/jest/index.d.ts +7 -0
  113. package/dist/plugins/jest/index.js +68 -0
  114. package/dist/plugins/lefthook/index.d.ts +6 -0
  115. package/dist/plugins/lefthook/index.js +28 -0
  116. package/dist/plugins/lint-staged/index.d.ts +6 -0
  117. package/dist/plugins/lint-staged/index.js +32 -0
  118. package/dist/plugins/lint-staged/types.d.ts +5 -0
  119. package/dist/plugins/lint-staged/types.js +1 -0
  120. package/dist/plugins/markdownlint/helpers.d.ts +1 -0
  121. package/dist/plugins/markdownlint/helpers.js +6 -0
  122. package/dist/plugins/markdownlint/index.d.ts +6 -0
  123. package/dist/plugins/markdownlint/index.js +19 -0
  124. package/dist/plugins/markdownlint/types.d.ts +3 -0
  125. package/dist/plugins/markdownlint/types.js +1 -0
  126. package/dist/plugins/mocha/index.d.ts +6 -0
  127. package/dist/plugins/mocha/index.js +15 -0
  128. package/dist/plugins/next/index.d.ts +6 -0
  129. package/dist/plugins/next/index.js +11 -0
  130. package/dist/plugins/npm-package-json-lint/index.d.ts +6 -0
  131. package/dist/plugins/npm-package-json-lint/index.js +13 -0
  132. package/dist/plugins/npm-package-json-lint/types.d.ts +3 -0
  133. package/dist/plugins/npm-package-json-lint/types.js +1 -0
  134. package/dist/plugins/nx/index.d.ts +6 -0
  135. package/dist/plugins/nx/index.js +24 -0
  136. package/dist/plugins/nx/types.d.ts +11 -0
  137. package/dist/plugins/nx/types.js +1 -0
  138. package/dist/plugins/nyc/index.d.ts +6 -0
  139. package/dist/plugins/nyc/index.js +11 -0
  140. package/dist/plugins/playwright/index.d.ts +5 -0
  141. package/dist/plugins/playwright/index.js +5 -0
  142. package/dist/plugins/postcss/index.d.ts +6 -0
  143. package/dist/plugins/postcss/index.js +23 -0
  144. package/dist/plugins/postcss/types.d.ts +3 -0
  145. package/dist/plugins/postcss/types.js +1 -0
  146. package/dist/plugins/prettier/index.d.ts +6 -0
  147. package/dist/plugins/prettier/index.js +20 -0
  148. package/dist/plugins/release-it/index.d.ts +6 -0
  149. package/dist/plugins/release-it/index.js +30 -0
  150. package/dist/plugins/release-it/types.d.ts +10 -0
  151. package/dist/plugins/release-it/types.js +1 -0
  152. package/dist/plugins/remark/index.d.ts +6 -0
  153. package/dist/plugins/remark/index.js +18 -0
  154. package/dist/plugins/remix/index.d.ts +6 -0
  155. package/dist/plugins/remix/index.js +11 -0
  156. package/dist/plugins/rollup/index.d.ts +5 -0
  157. package/dist/plugins/rollup/index.js +5 -0
  158. package/dist/plugins/semantic-release/index.d.ts +6 -0
  159. package/dist/plugins/semantic-release/index.js +17 -0
  160. package/dist/plugins/semantic-release/types.d.ts +3 -0
  161. package/dist/plugins/semantic-release/types.js +1 -0
  162. package/dist/plugins/sentry/index.d.ts +5 -0
  163. package/dist/plugins/sentry/index.js +5 -0
  164. package/dist/plugins/storybook/index.d.ts +8 -0
  165. package/dist/plugins/storybook/index.js +19 -0
  166. package/dist/plugins/storybook/types.d.ts +11 -0
  167. package/dist/plugins/storybook/types.js +1 -0
  168. package/dist/plugins/stryker/index.d.ts +6 -0
  169. package/dist/plugins/stryker/index.js +17 -0
  170. package/dist/plugins/stryker/types.d.ts +5 -0
  171. package/dist/plugins/stryker/types.js +1 -0
  172. package/dist/plugins/stylelint/index.d.ts +6 -0
  173. package/dist/plugins/stylelint/index.js +22 -0
  174. package/dist/plugins/stylelint/types.d.ts +4 -0
  175. package/dist/plugins/stylelint/types.js +1 -0
  176. package/dist/plugins/svelte/index.d.ts +7 -0
  177. package/dist/plugins/svelte/index.js +9 -0
  178. package/dist/plugins/tailwind/index.d.ts +5 -0
  179. package/dist/plugins/tailwind/index.js +5 -0
  180. package/dist/plugins/typedoc/index.d.ts +6 -0
  181. package/dist/plugins/typedoc/index.js +22 -0
  182. package/dist/plugins/typedoc/types.d.ts +3 -0
  183. package/dist/plugins/typedoc/types.js +1 -0
  184. package/dist/plugins/typescript/index.d.ts +7 -0
  185. package/dist/plugins/typescript/index.js +42 -0
  186. package/dist/plugins/vite/index.d.ts +6 -0
  187. package/dist/plugins/vite/index.js +12 -0
  188. package/dist/plugins/vite/types.d.ts +4 -0
  189. package/dist/plugins/vite/types.js +1 -0
  190. package/dist/plugins/vitest/helpers.d.ts +6 -0
  191. package/dist/plugins/vitest/helpers.js +22 -0
  192. package/dist/plugins/vitest/index.d.ts +9 -0
  193. package/dist/plugins/vitest/index.js +25 -0
  194. package/dist/plugins/vitest/types.d.ts +11 -0
  195. package/dist/plugins/vitest/types.js +1 -0
  196. package/dist/plugins/webpack/index.d.ts +6 -0
  197. package/dist/plugins/webpack/index.js +82 -0
  198. package/dist/plugins/webpack/types.d.ts +10 -0
  199. package/dist/plugins/webpack/types.js +1 -0
  200. package/dist/reporters/codeowners.d.ts +3 -0
  201. package/dist/reporters/codeowners.js +62 -0
  202. package/dist/reporters/compact.d.ts +3 -0
  203. package/dist/reporters/compact.js +36 -0
  204. package/dist/reporters/index.d.ts +7 -0
  205. package/dist/reporters/index.js +10 -0
  206. package/dist/reporters/json.d.ts +3 -0
  207. package/dist/reporters/json.js +67 -0
  208. package/dist/reporters/symbols.d.ts +3 -0
  209. package/dist/reporters/symbols.js +54 -0
  210. package/dist/reporters/util.d.ts +15 -0
  211. package/dist/reporters/util.js +17 -0
  212. package/dist/types/cli.d.ts +10 -0
  213. package/dist/types/cli.js +1 -0
  214. package/dist/types/compilers.d.ts +6 -0
  215. package/dist/types/compilers.js +1 -0
  216. package/dist/types/config.d.ts +39 -0
  217. package/dist/types/config.js +3 -0
  218. package/dist/types/exports.d.ts +20 -0
  219. package/dist/types/exports.js +1 -0
  220. package/dist/types/imports.d.ts +13 -0
  221. package/dist/types/imports.js +1 -0
  222. package/dist/types/issues.d.ts +62 -0
  223. package/dist/types/issues.js +10 -0
  224. package/dist/types/plugins.d.ts +19 -0
  225. package/dist/types/plugins.js +1 -0
  226. package/dist/types/workspace.d.ts +17 -0
  227. package/dist/types/workspace.js +1 -0
  228. package/dist/typescript/SourceFile.d.ts +18 -0
  229. package/dist/typescript/SourceFile.js +1 -0
  230. package/dist/typescript/SourceFileManager.d.ts +13 -0
  231. package/dist/typescript/SourceFileManager.js +57 -0
  232. package/dist/typescript/ast-helpers.d.ts +27 -0
  233. package/dist/typescript/ast-helpers.js +101 -0
  234. package/dist/typescript/createHosts.d.ts +15 -0
  235. package/dist/typescript/createHosts.js +39 -0
  236. package/dist/typescript/getImportsAndExports.d.ts +29 -0
  237. package/dist/typescript/getImportsAndExports.js +159 -0
  238. package/dist/typescript/resolveModuleNames.d.ts +2 -0
  239. package/dist/typescript/resolveModuleNames.js +27 -0
  240. package/dist/typescript/sys.d.ts +35 -0
  241. package/dist/typescript/sys.js +16 -0
  242. package/dist/typescript/utils.d.ts +2 -0
  243. package/dist/typescript/utils.js +9 -0
  244. package/dist/typescript/visitors/exports/exportAssignment.d.ts +3 -0
  245. package/dist/typescript/visitors/exports/exportAssignment.js +9 -0
  246. package/dist/typescript/visitors/exports/exportDeclaration.d.ts +3 -0
  247. package/dist/typescript/visitors/exports/exportDeclaration.js +13 -0
  248. package/dist/typescript/visitors/exports/exportKeyword.d.ts +3 -0
  249. package/dist/typescript/visitors/exports/exportKeyword.js +77 -0
  250. package/dist/typescript/visitors/exports/index.d.ts +3 -0
  251. package/dist/typescript/visitors/exports/index.js +7 -0
  252. package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +3 -0
  253. package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +31 -0
  254. package/dist/typescript/visitors/helpers.d.ts +4 -0
  255. package/dist/typescript/visitors/helpers.js +10 -0
  256. package/dist/typescript/visitors/imports/importCall.d.ts +3 -0
  257. package/dist/typescript/visitors/imports/importCall.js +11 -0
  258. package/dist/typescript/visitors/imports/importDeclaration.d.ts +3 -0
  259. package/dist/typescript/visitors/imports/importDeclaration.js +32 -0
  260. package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +3 -0
  261. package/dist/typescript/visitors/imports/importEqualsDeclaration.js +11 -0
  262. package/dist/typescript/visitors/imports/index.d.ts +3 -0
  263. package/dist/typescript/visitors/imports/index.js +18 -0
  264. package/dist/typescript/visitors/imports/jsDocType.d.ts +3 -0
  265. package/dist/typescript/visitors/imports/jsDocType.js +11 -0
  266. package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +3 -0
  267. package/dist/typescript/visitors/imports/reExportDeclaration.js +21 -0
  268. package/dist/typescript/visitors/imports/requireCall.d.ts +3 -0
  269. package/dist/typescript/visitors/imports/requireCall.js +45 -0
  270. package/dist/typescript/visitors/imports/requireResolveCall.d.ts +3 -0
  271. package/dist/typescript/visitors/imports/requireResolveCall.js +12 -0
  272. package/dist/typescript/visitors/index.d.ts +10 -0
  273. package/dist/typescript/visitors/index.js +16 -0
  274. package/dist/typescript/visitors/scripts/execa.d.ts +3 -0
  275. package/dist/typescript/visitors/scripts/execa.js +18 -0
  276. package/dist/typescript/visitors/scripts/index.d.ts +3 -0
  277. package/dist/typescript/visitors/scripts/index.js +5 -0
  278. package/dist/typescript/visitors/scripts/zx.d.ts +3 -0
  279. package/dist/typescript/visitors/scripts/zx.js +8 -0
  280. package/dist/util/Performance.d.ts +23 -0
  281. package/dist/util/Performance.js +80 -0
  282. package/dist/util/array.d.ts +2 -0
  283. package/dist/util/array.js +2 -0
  284. package/dist/util/cli-arguments.d.ts +28 -0
  285. package/dist/util/cli-arguments.js +83 -0
  286. package/dist/util/compilers.d.ts +426 -0
  287. package/dist/util/compilers.js +20 -0
  288. package/dist/util/debug.d.ts +3 -0
  289. package/dist/util/debug.js +34 -0
  290. package/dist/util/errors.d.ts +12 -0
  291. package/dist/util/errors.js +14 -0
  292. package/dist/util/fs.d.ts +7 -0
  293. package/dist/util/fs.js +42 -0
  294. package/dist/util/get-included-issue-types.d.ts +16 -0
  295. package/dist/util/get-included-issue-types.js +37 -0
  296. package/dist/util/git.d.ts +1 -0
  297. package/dist/util/git.js +20 -0
  298. package/dist/util/glob.d.ts +19 -0
  299. package/dist/util/glob.js +59 -0
  300. package/dist/util/loader.d.ts +1 -0
  301. package/dist/util/loader.js +31 -0
  302. package/dist/util/map.d.ts +1 -0
  303. package/dist/util/map.js +6 -0
  304. package/dist/util/modules.d.ts +8 -0
  305. package/dist/util/modules.js +52 -0
  306. package/dist/util/object.d.ts +3 -0
  307. package/dist/util/object.js +37 -0
  308. package/dist/util/path.d.ts +11 -0
  309. package/dist/util/path.js +13 -0
  310. package/dist/util/plugin.d.ts +3 -0
  311. package/dist/util/plugin.js +14 -0
  312. package/dist/util/register.d.ts +1 -0
  313. package/dist/util/register.js +14 -0
  314. package/dist/util/reporter.d.ts +3 -0
  315. package/dist/util/reporter.js +16 -0
  316. package/dist/util/require.d.ts +5 -0
  317. package/dist/util/require.js +34 -0
  318. package/dist/util/tsconfig-loader.d.ts +2 -0
  319. package/dist/util/tsconfig-loader.js +11 -0
  320. package/dist/util/workspace.d.ts +1 -0
  321. package/dist/util/workspace.js +11 -0
  322. package/dist/version.d.ts +1 -0
  323. package/dist/version.js +1 -0
  324. package/license +12 -0
  325. package/package.json +150 -0
  326. package/schema.json +403 -0
@@ -0,0 +1,59 @@
1
+ import fg from 'fast-glob';
2
+ import { globby } from 'globby';
3
+ import { GLOBAL_IGNORE_PATTERNS, ROOT_WORKSPACE_NAME } from '../constants.js';
4
+ import { compact } from './array.js';
5
+ import { debugLogObject } from './debug.js';
6
+ import { join, relative } from './path.js';
7
+ import { timerify } from './Performance.js';
8
+ export const prependDirToPattern = (workingDir, pattern) => {
9
+ if (pattern.startsWith('!'))
10
+ return '!' + join(workingDir, pattern.slice(1));
11
+ return join(workingDir, pattern);
12
+ };
13
+ export const negate = (pattern) => pattern.replace(/^!?/, '!');
14
+ export const hasProductionSuffix = (pattern) => pattern.endsWith('!');
15
+ export const hasNoProductionSuffix = (pattern) => !pattern.endsWith('!');
16
+ const removeProductionSuffix = (pattern) => pattern.replace(/!$/, '');
17
+ const negatedLast = (pattern) => (pattern.startsWith('!') ? 1 : -1);
18
+ const glob = async ({ cwd, workingDir = cwd, patterns, ignore = [], gitignore = true }) => {
19
+ if (patterns.length === 0)
20
+ return [];
21
+ const relativePath = relative(cwd, workingDir);
22
+ const prepend = (pattern) => prependDirToPattern(relativePath, pattern);
23
+ const globPatterns = compact([patterns].flat().map(prepend).map(removeProductionSuffix)).sort(negatedLast);
24
+ if (globPatterns[0].startsWith('!'))
25
+ return [];
26
+ const ignorePatterns = compact([...ignore, ...GLOBAL_IGNORE_PATTERNS]);
27
+ debugLogObject(`Globbing (${relativePath || ROOT_WORKSPACE_NAME})`, { cwd, globPatterns, ignorePatterns });
28
+ return globby(globPatterns, {
29
+ cwd,
30
+ ignore: ignorePatterns,
31
+ gitignore,
32
+ absolute: true,
33
+ dot: true,
34
+ });
35
+ };
36
+ const pureGlob = async ({ cwd, patterns, ignore = [], gitignore = true }) => {
37
+ if (patterns.length === 0)
38
+ return [];
39
+ return globby(patterns, {
40
+ cwd,
41
+ ignore: [...ignore, ...GLOBAL_IGNORE_PATTERNS],
42
+ gitignore,
43
+ absolute: true,
44
+ });
45
+ };
46
+ const firstGlob = async ({ cwd, patterns }) => {
47
+ const stream = fg.stream(patterns.map(removeProductionSuffix), { cwd, ignore: GLOBAL_IGNORE_PATTERNS });
48
+ for await (const entry of stream) {
49
+ return entry;
50
+ }
51
+ };
52
+ const dirGlob = async ({ cwd, patterns }) => globby(patterns, {
53
+ cwd,
54
+ onlyDirectories: true,
55
+ });
56
+ export const _glob = timerify(glob);
57
+ export const _pureGlob = timerify(pureGlob);
58
+ export const _firstGlob = timerify(firstGlob);
59
+ export const _dirGlob = timerify(dirGlob);
@@ -0,0 +1 @@
1
+ export declare const _load: (filePath: string) => Promise<any>;
@@ -0,0 +1,31 @@
1
+ import { pathToFileURL } from 'node:url';
2
+ import { LoaderError } from './errors.js';
3
+ import { loadJSON, loadYAML, loadFile, parseJSON, parseYAML } from './fs.js';
4
+ import { extname } from './path.js';
5
+ import { timerify } from './Performance.js';
6
+ import { jiti } from './register.js';
7
+ const load = async (filePath) => {
8
+ try {
9
+ const ext = extname(filePath);
10
+ if (/rc$/.test(filePath)) {
11
+ const contents = await loadFile(filePath);
12
+ return parseYAML(contents).catch(() => parseJSON(filePath, contents));
13
+ }
14
+ if (ext === '.json' || ext === '.jsonc') {
15
+ return loadJSON(filePath);
16
+ }
17
+ if (ext === '.yaml' || ext === '.yml') {
18
+ return loadYAML(filePath);
19
+ }
20
+ if (ext === '.mjs') {
21
+ const fileUrl = pathToFileURL(filePath);
22
+ const imported = await import(fileUrl.href);
23
+ return imported.default ?? imported;
24
+ }
25
+ return jiti(filePath);
26
+ }
27
+ catch (error) {
28
+ throw new LoaderError(`Error loading ${filePath}`, { cause: error });
29
+ }
30
+ };
31
+ export const _load = timerify(load);
@@ -0,0 +1 @@
1
+ export declare const getOrSet: <K extends string, V, T extends Map<K, V>>(map: T, key: K, value: V) => NonNullable<V>;
@@ -0,0 +1,6 @@
1
+ export const getOrSet = (map, key, value) => {
2
+ if (!map.has(key)) {
3
+ map.set(key, value);
4
+ }
5
+ return map.get(key);
6
+ };
@@ -0,0 +1,8 @@
1
+ import type { PackageJson } from '@npmcli/package-json';
2
+ export declare const getPackageNameFromModuleSpecifier: (moduleSpecifier: string) => string | undefined;
3
+ export declare const getPackageNameFromFilePath: (value: string) => string;
4
+ export declare const isMaybePackageName: (specifier: string) => boolean;
5
+ export declare const isDefinitelyTyped: (packageName: string) => boolean;
6
+ export declare const getDefinitelyTypedFor: (packageName: string) => string;
7
+ export declare const getPackageFromDefinitelyTyped: (typedDependency: string) => string;
8
+ export declare const getEntryPathFromManifest: (cwd: string, dir: string, manifest: PackageJson) => Promise<string[]>;
@@ -0,0 +1,52 @@
1
+ import { _glob } from './glob.js';
2
+ import { getStringValues } from './object.js';
3
+ import { toPosix } from './path.js';
4
+ export const getPackageNameFromModuleSpecifier = (moduleSpecifier) => {
5
+ if (!isMaybePackageName(moduleSpecifier))
6
+ return;
7
+ const parts = moduleSpecifier.split('/').slice(0, 2);
8
+ return moduleSpecifier.startsWith('@') ? parts.join('/') : parts[0];
9
+ };
10
+ export const getPackageNameFromFilePath = (value) => {
11
+ const match = toPosix(value).match(/(?<=node_modules\/)(@[^/]+\/[^/]+|[^/]+)/g);
12
+ if (match)
13
+ return match[match.length - 1];
14
+ return value;
15
+ };
16
+ export const isMaybePackageName = (specifier) => /^@?[a-z0-9]/.test(specifier);
17
+ export const isDefinitelyTyped = (packageName) => packageName.startsWith('@types/');
18
+ export const getDefinitelyTypedFor = (packageName) => {
19
+ if (isDefinitelyTyped(packageName))
20
+ return packageName;
21
+ if (packageName.startsWith('@'))
22
+ return '@types/' + packageName.slice(1).replace('/', '__');
23
+ return '@types/' + packageName;
24
+ };
25
+ export const getPackageFromDefinitelyTyped = (typedDependency) => {
26
+ if (typedDependency.includes('__')) {
27
+ const [scope, packageName] = typedDependency.split('__');
28
+ return `@${scope}/${packageName}`;
29
+ }
30
+ return typedDependency;
31
+ };
32
+ export const getEntryPathFromManifest = (cwd, dir, manifest) => {
33
+ const { main, bin, exports } = manifest;
34
+ const entryPaths = new Set();
35
+ if (typeof main === 'string')
36
+ entryPaths.add(main);
37
+ if (bin) {
38
+ if (typeof bin === 'string')
39
+ entryPaths.add(bin);
40
+ if (typeof bin === 'object')
41
+ Object.values(bin).forEach(bin => entryPaths.add(bin));
42
+ }
43
+ if (exports) {
44
+ if (typeof exports === 'string') {
45
+ entryPaths.add(exports);
46
+ }
47
+ else {
48
+ getStringValues(exports).forEach(item => entryPaths.add(item));
49
+ }
50
+ }
51
+ return _glob({ cwd, workingDir: dir, patterns: Array.from(entryPaths) });
52
+ };
@@ -0,0 +1,3 @@
1
+ export declare const getValuesByKeyDeep: (obj: any, key: string) => unknown[];
2
+ export declare const getStringValues: (obj: any) => string[];
3
+ export declare const getKeysByValue: <T>(obj: T, value: unknown) => (keyof T)[];
@@ -0,0 +1,37 @@
1
+ export const getValuesByKeyDeep = (obj, key) => {
2
+ const objects = [];
3
+ if (obj && typeof obj === 'object') {
4
+ for (const i in obj) {
5
+ if (obj[i] && typeof obj[i] === 'object') {
6
+ const values = getValuesByKeyDeep(obj[i], key);
7
+ objects.push(...values);
8
+ }
9
+ else if (i === key) {
10
+ objects.push(obj[i]);
11
+ }
12
+ }
13
+ }
14
+ return objects;
15
+ };
16
+ export const getStringValues = (obj) => {
17
+ let values = [];
18
+ for (const prop in obj) {
19
+ if (obj[prop]) {
20
+ if (typeof obj[prop] === 'string') {
21
+ values.push(obj[prop]);
22
+ }
23
+ else if (typeof obj[prop] === 'object') {
24
+ values = values.concat(getStringValues(obj[prop]));
25
+ }
26
+ }
27
+ }
28
+ return values;
29
+ };
30
+ export const getKeysByValue = (obj, value) => {
31
+ const keys = [];
32
+ for (const key in obj) {
33
+ if (obj[key] === value)
34
+ keys.push(key);
35
+ }
36
+ return keys;
37
+ };
@@ -0,0 +1,11 @@
1
+ export declare const dirname: (path: string) => string;
2
+ export declare const extname: (path: string) => string;
3
+ export declare const join: (...paths: string[]) => string;
4
+ export declare const toPosix: (value: string) => string;
5
+ export declare const cwd: string;
6
+ export declare const resolve: (...paths: string[]) => string;
7
+ export declare const relative: (from: string, to?: string) => string;
8
+ export declare const isInNodeModules: (filePath: string) => boolean;
9
+ export declare const toAbsolute: (id: string, base: string) => string;
10
+ export declare const toRelative: (id: string) => string;
11
+ export declare const isInternal: (id: string) => boolean;
@@ -0,0 +1,13 @@
1
+ import path from 'node:path';
2
+ const isAbsolute = path.isAbsolute;
3
+ export const dirname = path.posix.dirname;
4
+ export const extname = path.posix.extname;
5
+ export const join = path.posix.join;
6
+ export const toPosix = (value) => value.split(path.sep).join(path.posix.sep);
7
+ export const cwd = toPosix(process.cwd());
8
+ export const resolve = (...paths) => paths.length === 1 ? path.posix.join(cwd, paths[0]) : path.posix.resolve(...paths);
9
+ export const relative = (from, to) => path.posix.relative(to ? toPosix(from) : cwd, toPosix(to ?? from));
10
+ export const isInNodeModules = (filePath) => filePath.includes('node_modules');
11
+ export const toAbsolute = (id, base) => (isAbsolute(id) ? id : join(base, id));
12
+ export const toRelative = (id) => (isAbsolute(id) ? relative(id) : id);
13
+ export const isInternal = (id) => (id.startsWith('.') || isAbsolute(id)) && !isInNodeModules(id);
@@ -0,0 +1,3 @@
1
+ export { _load as load } from './loader.js';
2
+ export declare const toCamelCase: (name: string) => string;
3
+ export declare const hasDependency: (dependencies: Set<string>, values: (string | RegExp)[]) => boolean;
@@ -0,0 +1,14 @@
1
+ export { _load as load } from './loader.js';
2
+ export const toCamelCase = (name) => name.toLowerCase().replace(/(-[a-z])/g, group => group.toUpperCase().replace('-', ''));
3
+ export const hasDependency = (dependencies, values) => values.some(value => {
4
+ if (typeof value === 'string') {
5
+ return dependencies.has(value);
6
+ }
7
+ else if (value instanceof RegExp) {
8
+ for (const dependency of dependencies) {
9
+ if (value.test(dependency))
10
+ return true;
11
+ }
12
+ }
13
+ return false;
14
+ });
@@ -0,0 +1 @@
1
+ export declare const jiti: any;
@@ -0,0 +1,14 @@
1
+ import module from 'node:module';
2
+ import createJITI from 'jiti';
3
+ import { IGNORED_FILE_EXTENSIONS, DEFAULT_EXTENSIONS } from '../constants.js';
4
+ const _extensions = module.Module._extensions;
5
+ export const jiti = createJITI(process.cwd(), { interopDefault: true, extensions: DEFAULT_EXTENSIONS });
6
+ if (!('.ts' in _extensions)) {
7
+ jiti.register();
8
+ }
9
+ const exportFilePath = (module, filePath) => {
10
+ module.exports = filePath;
11
+ };
12
+ IGNORED_FILE_EXTENSIONS.forEach(ext => {
13
+ _extensions[ext] = exportFilePath;
14
+ });
@@ -0,0 +1,3 @@
1
+ import type { ReporterOptions } from '../types/issues.js';
2
+ export declare const runPreprocessors: (data: ReporterOptions, processors?: any[]) => Promise<ReporterOptions>;
3
+ export declare const runReporters: (options: ReporterOptions) => Promise<void>;
@@ -0,0 +1,16 @@
1
+ import internalReporters from '../reporters/index.js';
2
+ import parsedArgValues from '../util/cli-arguments.js';
3
+ import { _load } from './loader.js';
4
+ import { isInternal, resolve } from './path.js';
5
+ const { preprocessor = [], reporter = ['symbols'] } = parsedArgValues;
6
+ const preprocessors = await Promise.all(preprocessor.map(proc => _load(isInternal(proc) ? resolve(proc) : proc)));
7
+ export const runPreprocessors = (data, processors = preprocessors) => processors.length === 0 ? Promise.resolve(data) : runPreprocessors(processors[0](data), processors.slice(1));
8
+ const reporters = await Promise.all(reporter.map(async (reporter) => {
9
+ return reporter in internalReporters
10
+ ? internalReporters[reporter]
11
+ : await _load(isInternal(reporter) ? resolve(reporter) : reporter);
12
+ }));
13
+ export const runReporters = async (options) => {
14
+ for (const reporter of reporters)
15
+ await reporter(options);
16
+ };
@@ -0,0 +1,5 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ export declare const _require: NodeRequire;
3
+ export declare const _resolve: (specifier: string) => string;
4
+ export declare const _tryResolve: (specifier: string, from: string) => string | undefined;
5
+ export declare const _resolveSpecifier: (dir: string, specifier: string) => string | undefined;
@@ -0,0 +1,34 @@
1
+ import { createRequire as nodeCreateRequire } from 'node:module';
2
+ import { pathToFileURL } from 'node:url';
3
+ import { debugLog } from './debug.js';
4
+ import { getPackageNameFromModuleSpecifier } from './modules.js';
5
+ import { cwd, toPosix, join } from './path.js';
6
+ import { timerify } from './Performance.js';
7
+ const createRequire = (path) => nodeCreateRequire(pathToFileURL(path ?? cwd));
8
+ const require = createRequire();
9
+ const resolve = (specifier) => toPosix(require.resolve(specifier));
10
+ const tryResolve = (specifier, from) => {
11
+ try {
12
+ return resolve(specifier);
13
+ }
14
+ catch {
15
+ debugLog(`Unable to resolve ${specifier} (from ${from})`);
16
+ }
17
+ };
18
+ const resolveSpecifier = (dir, specifier) => {
19
+ try {
20
+ const require = createRequire(join(dir, 'package.json'));
21
+ return toPosix(require.resolve(specifier));
22
+ }
23
+ catch {
24
+ const packageName = getPackageNameFromModuleSpecifier(specifier);
25
+ if (packageName) {
26
+ const relativeSpecifier = specifier.replace(packageName, '.');
27
+ return tryResolve(join(dir, relativeSpecifier), dir);
28
+ }
29
+ }
30
+ };
31
+ export const _require = timerify(require);
32
+ export const _resolve = timerify(resolve);
33
+ export const _tryResolve = timerify(tryResolve);
34
+ export const _resolveSpecifier = timerify(resolveSpecifier);
@@ -0,0 +1,2 @@
1
+ import ts from 'typescript';
2
+ export declare const loadTSConfig: (tsConfigFilePath: string) => Promise<ts.CompilerOptions>;
@@ -0,0 +1,11 @@
1
+ import ts from 'typescript';
2
+ import { isFile } from './fs.js';
3
+ import { dirname } from './path.js';
4
+ export const loadTSConfig = async (tsConfigFilePath) => {
5
+ if (isFile(tsConfigFilePath)) {
6
+ const config = ts.readConfigFile(tsConfigFilePath, ts.sys.readFile);
7
+ const parsedConfig = ts.parseJsonConfigFileContent(config.config, ts.sys, dirname(tsConfigFilePath));
8
+ return parsedConfig.options ?? {};
9
+ }
10
+ return {};
11
+ };
@@ -0,0 +1 @@
1
+ export declare const byPathDepth: (a: string, b: string) => number;
@@ -0,0 +1,11 @@
1
+ export const byPathDepth = (a, b) => {
2
+ const depthA = a.split('/');
3
+ const depthB = b.split('/');
4
+ if (depthA.length !== depthB.length)
5
+ return depthA.length - depthB.length;
6
+ if (depthA.includes('*') || depthA.includes('**'))
7
+ return -1;
8
+ if (depthB.includes('*') || depthB.includes('**'))
9
+ return 1;
10
+ return a.length - b.length;
11
+ };
@@ -0,0 +1 @@
1
+ export declare const version = "0.0.0-angular.0";
@@ -0,0 +1 @@
1
+ export const version = '0.0.0-angular.0';
package/license ADDED
@@ -0,0 +1,12 @@
1
+ ISC License (ISC)
2
+
3
+ Copyright 2022 Lars Kappert
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
6
+ provided that the above copyright notice and this permission notice appear in all copies.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
9
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
11
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
12
+ THIS SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,150 @@
1
+ {
2
+ "name": "knip",
3
+ "version": "0.0.0-angular.0",
4
+ "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
+ "homepage": "https://github.com/webpro/knip",
6
+ "repository": "github:webpro/knip",
7
+ "bugs": "https://github.com/webpro/knip/issues",
8
+ "license": "ISC",
9
+ "author": {
10
+ "name": "Lars Kappert",
11
+ "email": "lars@webpro.nl"
12
+ },
13
+ "main": "./dist/index.js",
14
+ "bin": {
15
+ "knip": "./dist/cli.js"
16
+ },
17
+ "type": "module",
18
+ "types": "./dist/index.d.ts",
19
+ "scripts": {
20
+ "knip": "node ./dist/cli.js",
21
+ "knip:production": "node ./dist/cli.js --production --strict --ignore-internal",
22
+ "lint": "eslint scripts src tests",
23
+ "lint:fix": "eslint scripts src tests --fix",
24
+ "format": "prettier scripts src tests schema.json --with-node-modules --write --config .prettierrc",
25
+ "pretest": "node rmdir.js tmp && swc src -d tmp/src && swc tests -d tmp/tests",
26
+ "test": "node --no-warnings --test tmp",
27
+ "coverage": "c8 --reporter html node --no-warnings --loader tsx --test tests/*.test.ts tests/*/*.test.ts",
28
+ "watch": "rm $(which knip); npm link && tsc --watch",
29
+ "prebuild": "node rmdir.js dist",
30
+ "build": "tsc",
31
+ "docs": "npm run docs:cli && npm run docs:plugins && npm run docs:format",
32
+ "docs:cli": "tsx ./scripts/update-cli-usage-in-readme.ts",
33
+ "docs:plugins": "tsx ./scripts/generate-plugin-docs.ts",
34
+ "docs:format": "remark README.md docs/*.md .github/*.md src/plugins/*/README.md -o",
35
+ "qa": "npm run lint && npm run build && npm run knip && npm run knip:production && npm test",
36
+ "release": "release-it",
37
+ "create-plugin": "tsx --no-warnings ./scripts/create-new-plugin.ts",
38
+ "postcreate-plugin": "prettier schema.json src/ConfigurationValidator.ts --write --config .prettierrc --log-level silent"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "schema.json"
43
+ ],
44
+ "dependencies": {
45
+ "@ericcornelissen/bash-parser": "^0.5.2",
46
+ "@npmcli/map-workspaces": "^3.0.4",
47
+ "@snyk/github-codeowners": "^1.1.0",
48
+ "chalk": "^5.2.0",
49
+ "easy-table": "^1.2.0",
50
+ "fast-glob": "^3.2.12",
51
+ "globby": "^13.1.3",
52
+ "jiti": "^1.19.3",
53
+ "js-yaml": "^4.1.0",
54
+ "micromatch": "^4.0.5",
55
+ "minimist": "^1.2.8",
56
+ "pretty-ms": "^8.0.0",
57
+ "strip-json-comments": "^5.0.0",
58
+ "summary": "^2.1.0",
59
+ "typescript": "^5.0.2",
60
+ "zod": "^3.22.2",
61
+ "zod-validation-error": "^1.5.0"
62
+ },
63
+ "devDependencies": {
64
+ "@jest/types": "29.6.3",
65
+ "@npmcli/package-json": "5.0.0",
66
+ "@release-it/bumper": "5.1.0",
67
+ "@swc/cli": "0.1.62",
68
+ "@swc/core": "1.3.84",
69
+ "@types/eslint": "8.44.2",
70
+ "@types/js-yaml": "4.0.5",
71
+ "@types/micromatch": "4.0.2",
72
+ "@types/minimist": "1.2.2",
73
+ "@types/node": "20.6.0",
74
+ "@types/npmcli__map-workspaces": "3.0.1",
75
+ "@types/webpack": "5.28.2",
76
+ "@typescript-eslint/eslint-plugin": "6.7.0",
77
+ "@typescript-eslint/parser": "6.7.0",
78
+ "c8": "8.0.1",
79
+ "eslint": "8.49.0",
80
+ "eslint-import-resolver-typescript": "3.6.0",
81
+ "eslint-plugin-import": "2.28.1",
82
+ "eslint-plugin-n": "16.1.0",
83
+ "prettier": "3.0.3",
84
+ "release-it": "16.1.5",
85
+ "remark-cli": "11.0.0",
86
+ "remark-preset-webpro": "0.0.3",
87
+ "tsx": "3.12.8",
88
+ "type-fest": "4.3.1"
89
+ },
90
+ "engines": {
91
+ "node": ">=16.17.0 <17 || >=18.6.0"
92
+ },
93
+ "engineStrict": true,
94
+ "release-it": {
95
+ "hooks": {
96
+ "before:init": [
97
+ "npm run lint",
98
+ "npm run build",
99
+ "npm run knip",
100
+ "npm run knip:production",
101
+ "npm run docs",
102
+ "npm test"
103
+ ]
104
+ },
105
+ "github": {
106
+ "release": true,
107
+ "comments": {
108
+ "submit": true
109
+ }
110
+ },
111
+ "plugins": {
112
+ "@release-it/bumper": {
113
+ "out": "{dist,src}/version.*"
114
+ }
115
+ }
116
+ },
117
+ "remarkConfig": {
118
+ "plugins": [
119
+ "preset-webpro"
120
+ ]
121
+ },
122
+ "keywords": [
123
+ "find",
124
+ "detect",
125
+ "analyze",
126
+ "scan",
127
+ "lint",
128
+ "unused",
129
+ "unreferenced",
130
+ "unresolved",
131
+ "missing",
132
+ "unimported",
133
+ "files",
134
+ "dependencies",
135
+ "devDependencies",
136
+ "exports",
137
+ "types",
138
+ "members",
139
+ "namespaces",
140
+ "duplicates",
141
+ "typescript",
142
+ "maintenance",
143
+ "class",
144
+ "enum",
145
+ "members",
146
+ "workspace",
147
+ "workspaces",
148
+ "monorepo"
149
+ ]
150
+ }