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.
- package/README.md +907 -0
- package/dist/ConfigurationChief.d.ts +53 -0
- package/dist/ConfigurationChief.js +297 -0
- package/dist/ConfigurationValidator.d.ts +2325 -0
- package/dist/ConfigurationValidator.js +119 -0
- package/dist/ConsoleStreamer.d.ts +12 -0
- package/dist/ConsoleStreamer.js +34 -0
- package/dist/DependencyDeputy.d.ts +64 -0
- package/dist/DependencyDeputy.js +254 -0
- package/dist/IssueCollector.d.ts +27 -0
- package/dist/IssueCollector.js +52 -0
- package/dist/PrincipalFactory.d.ts +25 -0
- package/dist/PrincipalFactory.js +56 -0
- package/dist/ProjectPrincipal.d.ts +64 -0
- package/dist/ProjectPrincipal.js +197 -0
- package/dist/WorkspaceWorker.d.ts +56 -0
- package/dist/WorkspaceWorker.js +244 -0
- package/dist/binaries/bash-parser.d.ts +6 -0
- package/dist/binaries/bash-parser.js +58 -0
- package/dist/binaries/index.d.ts +2 -0
- package/dist/binaries/index.js +18 -0
- package/dist/binaries/resolvers/c8.d.ts +2 -0
- package/dist/binaries/resolvers/c8.js +10 -0
- package/dist/binaries/resolvers/dotenv.d.ts +2 -0
- package/dist/binaries/resolvers/dotenv.js +6 -0
- package/dist/binaries/resolvers/fallback.d.ts +2 -0
- package/dist/binaries/resolvers/fallback.js +22 -0
- package/dist/binaries/resolvers/index.d.ts +8 -0
- package/dist/binaries/resolvers/index.js +8 -0
- package/dist/binaries/resolvers/node.d.ts +2 -0
- package/dist/binaries/resolvers/node.js +10 -0
- package/dist/binaries/resolvers/nodemon.d.ts +2 -0
- package/dist/binaries/resolvers/nodemon.js +15 -0
- package/dist/binaries/resolvers/npx.d.ts +2 -0
- package/dist/binaries/resolvers/npx.js +20 -0
- package/dist/binaries/resolvers/pnpm.d.ts +2 -0
- package/dist/binaries/resolvers/pnpm.js +63 -0
- package/dist/binaries/resolvers/rollup.d.ts +2 -0
- package/dist/binaries/resolvers/rollup.js +11 -0
- package/dist/binaries/resolvers/yarn.d.ts +2 -0
- package/dist/binaries/resolvers/yarn.js +48 -0
- package/dist/binaries/types.d.ts +15 -0
- package/dist/binaries/types.js +1 -0
- package/dist/binaries/util.d.ts +8 -0
- package/dist/binaries/util.js +33 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +72 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.js +90 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +334 -0
- package/dist/issues/initializers.d.ts +4 -0
- package/dist/issues/initializers.js +11 -0
- package/dist/manifest/helpers.d.ts +7 -0
- package/dist/manifest/helpers.js +16 -0
- package/dist/manifest/index.d.ts +16 -0
- package/dist/manifest/index.js +56 -0
- package/dist/plugins/_template/index.d.ts +9 -0
- package/dist/plugins/_template/index.js +14 -0
- package/dist/plugins/_template/types.d.ts +3 -0
- package/dist/plugins/_template/types.js +1 -0
- package/dist/plugins/angular/index.d.ts +6 -0
- package/dist/plugins/angular/index.js +36 -0
- package/dist/plugins/angular/types.d.ts +745 -0
- package/dist/plugins/angular/types.js +1 -0
- package/dist/plugins/ava/index.d.ts +7 -0
- package/dist/plugins/ava/index.js +20 -0
- package/dist/plugins/ava/types.d.ts +4 -0
- package/dist/plugins/ava/types.js +1 -0
- package/dist/plugins/babel/helpers.d.ts +15 -0
- package/dist/plugins/babel/helpers.js +34 -0
- package/dist/plugins/babel/index.d.ts +8 -0
- package/dist/plugins/babel/index.js +30 -0
- package/dist/plugins/babel/types.d.ts +9 -0
- package/dist/plugins/babel/types.js +1 -0
- package/dist/plugins/capacitor/index.d.ts +6 -0
- package/dist/plugins/capacitor/index.js +11 -0
- package/dist/plugins/capacitor/types.d.ts +3 -0
- package/dist/plugins/capacitor/types.js +1 -0
- package/dist/plugins/changesets/index.d.ts +6 -0
- package/dist/plugins/changesets/index.js +15 -0
- package/dist/plugins/commitizen/index.d.ts +6 -0
- package/dist/plugins/commitizen/index.js +14 -0
- package/dist/plugins/commitizen/types.d.ts +3 -0
- package/dist/plugins/commitizen/types.js +1 -0
- package/dist/plugins/commitlint/index.d.ts +6 -0
- package/dist/plugins/commitlint/index.js +18 -0
- package/dist/plugins/cspell/index.d.ts +6 -0
- package/dist/plugins/cspell/index.js +17 -0
- package/dist/plugins/cspell/types.d.ts +3 -0
- package/dist/plugins/cspell/types.js +1 -0
- package/dist/plugins/cypress/index.d.ts +5 -0
- package/dist/plugins/cypress/index.js +10 -0
- package/dist/plugins/eslint/fallback.d.ts +1 -0
- package/dist/plugins/eslint/fallback.js +13 -0
- package/dist/plugins/eslint/helpers.d.ts +14 -0
- package/dist/plugins/eslint/helpers.js +83 -0
- package/dist/plugins/eslint/index.d.ts +7 -0
- package/dist/plugins/eslint/index.js +15 -0
- package/dist/plugins/eslint/types.d.ts +27 -0
- package/dist/plugins/eslint/types.js +1 -0
- package/dist/plugins/gatsby/index.d.ts +7 -0
- package/dist/plugins/gatsby/index.js +30 -0
- package/dist/plugins/gatsby/types.d.ts +15 -0
- package/dist/plugins/gatsby/types.js +1 -0
- package/dist/plugins/github-actions/index.d.ts +6 -0
- package/dist/plugins/github-actions/index.js +21 -0
- package/dist/plugins/husky/index.d.ts +6 -0
- package/dist/plugins/husky/index.js +19 -0
- package/dist/plugins/index.d.ts +41 -0
- package/dist/plugins/index.js +41 -0
- package/dist/plugins/jest/index.d.ts +7 -0
- package/dist/plugins/jest/index.js +68 -0
- package/dist/plugins/lefthook/index.d.ts +6 -0
- package/dist/plugins/lefthook/index.js +28 -0
- package/dist/plugins/lint-staged/index.d.ts +6 -0
- package/dist/plugins/lint-staged/index.js +32 -0
- package/dist/plugins/lint-staged/types.d.ts +5 -0
- package/dist/plugins/lint-staged/types.js +1 -0
- package/dist/plugins/markdownlint/helpers.d.ts +1 -0
- package/dist/plugins/markdownlint/helpers.js +6 -0
- package/dist/plugins/markdownlint/index.d.ts +6 -0
- package/dist/plugins/markdownlint/index.js +19 -0
- package/dist/plugins/markdownlint/types.d.ts +3 -0
- package/dist/plugins/markdownlint/types.js +1 -0
- package/dist/plugins/mocha/index.d.ts +6 -0
- package/dist/plugins/mocha/index.js +15 -0
- package/dist/plugins/next/index.d.ts +6 -0
- package/dist/plugins/next/index.js +11 -0
- package/dist/plugins/npm-package-json-lint/index.d.ts +6 -0
- package/dist/plugins/npm-package-json-lint/index.js +13 -0
- package/dist/plugins/npm-package-json-lint/types.d.ts +3 -0
- package/dist/plugins/npm-package-json-lint/types.js +1 -0
- package/dist/plugins/nx/index.d.ts +6 -0
- package/dist/plugins/nx/index.js +24 -0
- package/dist/plugins/nx/types.d.ts +11 -0
- package/dist/plugins/nx/types.js +1 -0
- package/dist/plugins/nyc/index.d.ts +6 -0
- package/dist/plugins/nyc/index.js +11 -0
- package/dist/plugins/playwright/index.d.ts +5 -0
- package/dist/plugins/playwright/index.js +5 -0
- package/dist/plugins/postcss/index.d.ts +6 -0
- package/dist/plugins/postcss/index.js +23 -0
- package/dist/plugins/postcss/types.d.ts +3 -0
- package/dist/plugins/postcss/types.js +1 -0
- package/dist/plugins/prettier/index.d.ts +6 -0
- package/dist/plugins/prettier/index.js +20 -0
- package/dist/plugins/release-it/index.d.ts +6 -0
- package/dist/plugins/release-it/index.js +30 -0
- package/dist/plugins/release-it/types.d.ts +10 -0
- package/dist/plugins/release-it/types.js +1 -0
- package/dist/plugins/remark/index.d.ts +6 -0
- package/dist/plugins/remark/index.js +18 -0
- package/dist/plugins/remix/index.d.ts +6 -0
- package/dist/plugins/remix/index.js +11 -0
- package/dist/plugins/rollup/index.d.ts +5 -0
- package/dist/plugins/rollup/index.js +5 -0
- package/dist/plugins/semantic-release/index.d.ts +6 -0
- package/dist/plugins/semantic-release/index.js +17 -0
- package/dist/plugins/semantic-release/types.d.ts +3 -0
- package/dist/plugins/semantic-release/types.js +1 -0
- package/dist/plugins/sentry/index.d.ts +5 -0
- package/dist/plugins/sentry/index.js +5 -0
- package/dist/plugins/storybook/index.d.ts +8 -0
- package/dist/plugins/storybook/index.js +19 -0
- package/dist/plugins/storybook/types.d.ts +11 -0
- package/dist/plugins/storybook/types.js +1 -0
- package/dist/plugins/stryker/index.d.ts +6 -0
- package/dist/plugins/stryker/index.js +17 -0
- package/dist/plugins/stryker/types.d.ts +5 -0
- package/dist/plugins/stryker/types.js +1 -0
- package/dist/plugins/stylelint/index.d.ts +6 -0
- package/dist/plugins/stylelint/index.js +22 -0
- package/dist/plugins/stylelint/types.d.ts +4 -0
- package/dist/plugins/stylelint/types.js +1 -0
- package/dist/plugins/svelte/index.d.ts +7 -0
- package/dist/plugins/svelte/index.js +9 -0
- package/dist/plugins/tailwind/index.d.ts +5 -0
- package/dist/plugins/tailwind/index.js +5 -0
- package/dist/plugins/typedoc/index.d.ts +6 -0
- package/dist/plugins/typedoc/index.js +22 -0
- package/dist/plugins/typedoc/types.d.ts +3 -0
- package/dist/plugins/typedoc/types.js +1 -0
- package/dist/plugins/typescript/index.d.ts +7 -0
- package/dist/plugins/typescript/index.js +42 -0
- package/dist/plugins/vite/index.d.ts +6 -0
- package/dist/plugins/vite/index.js +12 -0
- package/dist/plugins/vite/types.d.ts +4 -0
- package/dist/plugins/vite/types.js +1 -0
- package/dist/plugins/vitest/helpers.d.ts +6 -0
- package/dist/plugins/vitest/helpers.js +22 -0
- package/dist/plugins/vitest/index.d.ts +9 -0
- package/dist/plugins/vitest/index.js +25 -0
- package/dist/plugins/vitest/types.d.ts +11 -0
- package/dist/plugins/vitest/types.js +1 -0
- package/dist/plugins/webpack/index.d.ts +6 -0
- package/dist/plugins/webpack/index.js +82 -0
- package/dist/plugins/webpack/types.d.ts +10 -0
- package/dist/plugins/webpack/types.js +1 -0
- package/dist/reporters/codeowners.d.ts +3 -0
- package/dist/reporters/codeowners.js +62 -0
- package/dist/reporters/compact.d.ts +3 -0
- package/dist/reporters/compact.js +36 -0
- package/dist/reporters/index.d.ts +7 -0
- package/dist/reporters/index.js +10 -0
- package/dist/reporters/json.d.ts +3 -0
- package/dist/reporters/json.js +67 -0
- package/dist/reporters/symbols.d.ts +3 -0
- package/dist/reporters/symbols.js +54 -0
- package/dist/reporters/util.d.ts +15 -0
- package/dist/reporters/util.js +17 -0
- package/dist/types/cli.d.ts +10 -0
- package/dist/types/cli.js +1 -0
- package/dist/types/compilers.d.ts +6 -0
- package/dist/types/compilers.js +1 -0
- package/dist/types/config.d.ts +39 -0
- package/dist/types/config.js +3 -0
- package/dist/types/exports.d.ts +20 -0
- package/dist/types/exports.js +1 -0
- package/dist/types/imports.d.ts +13 -0
- package/dist/types/imports.js +1 -0
- package/dist/types/issues.d.ts +62 -0
- package/dist/types/issues.js +10 -0
- package/dist/types/plugins.d.ts +19 -0
- package/dist/types/plugins.js +1 -0
- package/dist/types/workspace.d.ts +17 -0
- package/dist/types/workspace.js +1 -0
- package/dist/typescript/SourceFile.d.ts +18 -0
- package/dist/typescript/SourceFile.js +1 -0
- package/dist/typescript/SourceFileManager.d.ts +13 -0
- package/dist/typescript/SourceFileManager.js +57 -0
- package/dist/typescript/ast-helpers.d.ts +27 -0
- package/dist/typescript/ast-helpers.js +101 -0
- package/dist/typescript/createHosts.d.ts +15 -0
- package/dist/typescript/createHosts.js +39 -0
- package/dist/typescript/getImportsAndExports.d.ts +29 -0
- package/dist/typescript/getImportsAndExports.js +159 -0
- package/dist/typescript/resolveModuleNames.d.ts +2 -0
- package/dist/typescript/resolveModuleNames.js +27 -0
- package/dist/typescript/sys.d.ts +35 -0
- package/dist/typescript/sys.js +16 -0
- package/dist/typescript/utils.d.ts +2 -0
- package/dist/typescript/utils.js +9 -0
- package/dist/typescript/visitors/exports/exportAssignment.d.ts +3 -0
- package/dist/typescript/visitors/exports/exportAssignment.js +9 -0
- package/dist/typescript/visitors/exports/exportDeclaration.d.ts +3 -0
- package/dist/typescript/visitors/exports/exportDeclaration.js +13 -0
- package/dist/typescript/visitors/exports/exportKeyword.d.ts +3 -0
- package/dist/typescript/visitors/exports/exportKeyword.js +77 -0
- package/dist/typescript/visitors/exports/index.d.ts +3 -0
- package/dist/typescript/visitors/exports/index.js +7 -0
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.d.ts +3 -0
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +31 -0
- package/dist/typescript/visitors/helpers.d.ts +4 -0
- package/dist/typescript/visitors/helpers.js +10 -0
- package/dist/typescript/visitors/imports/importCall.d.ts +3 -0
- package/dist/typescript/visitors/imports/importCall.js +11 -0
- package/dist/typescript/visitors/imports/importDeclaration.d.ts +3 -0
- package/dist/typescript/visitors/imports/importDeclaration.js +32 -0
- package/dist/typescript/visitors/imports/importEqualsDeclaration.d.ts +3 -0
- package/dist/typescript/visitors/imports/importEqualsDeclaration.js +11 -0
- package/dist/typescript/visitors/imports/index.d.ts +3 -0
- package/dist/typescript/visitors/imports/index.js +18 -0
- package/dist/typescript/visitors/imports/jsDocType.d.ts +3 -0
- package/dist/typescript/visitors/imports/jsDocType.js +11 -0
- package/dist/typescript/visitors/imports/reExportDeclaration.d.ts +3 -0
- package/dist/typescript/visitors/imports/reExportDeclaration.js +21 -0
- package/dist/typescript/visitors/imports/requireCall.d.ts +3 -0
- package/dist/typescript/visitors/imports/requireCall.js +45 -0
- package/dist/typescript/visitors/imports/requireResolveCall.d.ts +3 -0
- package/dist/typescript/visitors/imports/requireResolveCall.js +12 -0
- package/dist/typescript/visitors/index.d.ts +10 -0
- package/dist/typescript/visitors/index.js +16 -0
- package/dist/typescript/visitors/scripts/execa.d.ts +3 -0
- package/dist/typescript/visitors/scripts/execa.js +18 -0
- package/dist/typescript/visitors/scripts/index.d.ts +3 -0
- package/dist/typescript/visitors/scripts/index.js +5 -0
- package/dist/typescript/visitors/scripts/zx.d.ts +3 -0
- package/dist/typescript/visitors/scripts/zx.js +8 -0
- package/dist/util/Performance.d.ts +23 -0
- package/dist/util/Performance.js +80 -0
- package/dist/util/array.d.ts +2 -0
- package/dist/util/array.js +2 -0
- package/dist/util/cli-arguments.d.ts +28 -0
- package/dist/util/cli-arguments.js +83 -0
- package/dist/util/compilers.d.ts +426 -0
- package/dist/util/compilers.js +20 -0
- package/dist/util/debug.d.ts +3 -0
- package/dist/util/debug.js +34 -0
- package/dist/util/errors.d.ts +12 -0
- package/dist/util/errors.js +14 -0
- package/dist/util/fs.d.ts +7 -0
- package/dist/util/fs.js +42 -0
- package/dist/util/get-included-issue-types.d.ts +16 -0
- package/dist/util/get-included-issue-types.js +37 -0
- package/dist/util/git.d.ts +1 -0
- package/dist/util/git.js +20 -0
- package/dist/util/glob.d.ts +19 -0
- package/dist/util/glob.js +59 -0
- package/dist/util/loader.d.ts +1 -0
- package/dist/util/loader.js +31 -0
- package/dist/util/map.d.ts +1 -0
- package/dist/util/map.js +6 -0
- package/dist/util/modules.d.ts +8 -0
- package/dist/util/modules.js +52 -0
- package/dist/util/object.d.ts +3 -0
- package/dist/util/object.js +37 -0
- package/dist/util/path.d.ts +11 -0
- package/dist/util/path.js +13 -0
- package/dist/util/plugin.d.ts +3 -0
- package/dist/util/plugin.js +14 -0
- package/dist/util/register.d.ts +1 -0
- package/dist/util/register.js +14 -0
- package/dist/util/reporter.d.ts +3 -0
- package/dist/util/reporter.js +16 -0
- package/dist/util/require.d.ts +5 -0
- package/dist/util/require.js +34 -0
- package/dist/util/tsconfig-loader.d.ts +2 -0
- package/dist/util/tsconfig-loader.js +11 -0
- package/dist/util/workspace.d.ts +1 -0
- package/dist/util/workspace.js +11 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/license +12 -0
- package/package.json +150 -0
- package/schema.json +403 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getTitle, logTitle, logIssueLine, logIssueSet } from './util.js';
|
|
2
|
+
const logIssueRecord = (issues) => {
|
|
3
|
+
const sortedByFilePath = issues.sort((a, b) => (a.filePath > b.filePath ? 1 : -1));
|
|
4
|
+
sortedByFilePath.forEach(logIssueLine);
|
|
5
|
+
};
|
|
6
|
+
export default ({ report, issues, isShowProgress }) => {
|
|
7
|
+
const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
|
|
8
|
+
let totalIssues = 0;
|
|
9
|
+
for (const [reportType, isReportType] of Object.entries(report)) {
|
|
10
|
+
if (isReportType) {
|
|
11
|
+
const title = reportMultipleGroups && getTitle(reportType);
|
|
12
|
+
const isSet = issues[reportType] instanceof Set;
|
|
13
|
+
const issuesForType = isSet
|
|
14
|
+
? Array.from(issues[reportType])
|
|
15
|
+
: reportType === 'duplicates'
|
|
16
|
+
? Object.values(issues[reportType]).map(Object.values).flat()
|
|
17
|
+
: Object.values(issues[reportType]).map(issues => {
|
|
18
|
+
const items = Object.values(issues);
|
|
19
|
+
return { ...items[0], symbols: items.map(issue => issue.symbol) };
|
|
20
|
+
});
|
|
21
|
+
if (issuesForType.length > 0) {
|
|
22
|
+
title && logTitle(title, issuesForType.length);
|
|
23
|
+
if (isSet) {
|
|
24
|
+
logIssueSet(Array.from(issues[reportType]));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
logIssueRecord(issuesForType);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
totalIssues = totalIssues + issuesForType.length;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (totalIssues === 0 && isShowProgress) {
|
|
34
|
+
console.log('✂️ Excellent, Knip found no issues.');
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
symbols: ({ report, issues, configurationHints, noConfigHints, isShowProgress }: import("../index.js").ReporterOptions) => void;
|
|
3
|
+
compact: ({ report, issues, isShowProgress }: import("../index.js").ReporterOptions) => void;
|
|
4
|
+
codeowners: ({ report, issues, isShowProgress, options }: import("../index.js").ReporterOptions) => void;
|
|
5
|
+
json: ({ report, issues, options }: import("../index.js").ReporterOptions) => Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { OwnershipEngine } from '@snyk/github-codeowners/dist/lib/ownership/index.js';
|
|
2
|
+
import { isFile } from '../util/fs.js';
|
|
3
|
+
import { relative, resolve } from '../util/path.js';
|
|
4
|
+
const mergeTypes = (type) => type === 'exports' || type === 'nsExports' ? 'exports' : type === 'types' || type === 'nsTypes' ? 'types' : type;
|
|
5
|
+
export default async ({ report, issues, options }) => {
|
|
6
|
+
let opts = {};
|
|
7
|
+
try {
|
|
8
|
+
opts = options ? JSON.parse(options) : opts;
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
console.error(error);
|
|
12
|
+
}
|
|
13
|
+
const json = {};
|
|
14
|
+
const codeownersFilePath = resolve(opts.codeowners ?? '.github/CODEOWNERS');
|
|
15
|
+
const codeownersEngine = isFile(codeownersFilePath) && OwnershipEngine.FromCodeownersFile(codeownersFilePath);
|
|
16
|
+
const flatten = (issues) => Object.values(issues).map(Object.values).flat();
|
|
17
|
+
const initRow = (filePath) => {
|
|
18
|
+
const file = relative(filePath);
|
|
19
|
+
const row = {
|
|
20
|
+
file,
|
|
21
|
+
...(codeownersEngine && { owners: codeownersEngine.calcFileOwnership(file) }),
|
|
22
|
+
...(report.files && { files: false }),
|
|
23
|
+
...(report.dependencies && { dependencies: [] }),
|
|
24
|
+
...(report.devDependencies && { devDependencies: [] }),
|
|
25
|
+
...(report.optionalPeerDependencies && { optionalPeerDependencies: [] }),
|
|
26
|
+
...(report.unlisted && { unlisted: [] }),
|
|
27
|
+
...(report.unresolved && { unresolved: [] }),
|
|
28
|
+
...((report.exports || report.nsExports) && { exports: [] }),
|
|
29
|
+
...((report.types || report.nsTypes) && { types: [] }),
|
|
30
|
+
...(report.enumMembers && { enumMembers: {} }),
|
|
31
|
+
...(report.classMembers && { classMembers: {} }),
|
|
32
|
+
...(report.duplicates && { duplicates: [] }),
|
|
33
|
+
};
|
|
34
|
+
return row;
|
|
35
|
+
};
|
|
36
|
+
for (const [reportType, isReportType] of Object.entries(report)) {
|
|
37
|
+
if (isReportType) {
|
|
38
|
+
if (reportType === 'files') {
|
|
39
|
+
Array.from(issues[reportType]).forEach(filePath => {
|
|
40
|
+
json[filePath] = json[filePath] ?? initRow(filePath);
|
|
41
|
+
json[filePath][reportType] = true;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const type = mergeTypes(reportType);
|
|
46
|
+
flatten(issues[reportType]).forEach(issue => {
|
|
47
|
+
const { filePath, symbol, symbols, parentSymbol } = issue;
|
|
48
|
+
json[filePath] = json[filePath] ?? initRow(filePath);
|
|
49
|
+
if (type === 'duplicates') {
|
|
50
|
+
symbols && json[filePath][type]?.push(symbols);
|
|
51
|
+
}
|
|
52
|
+
else if (type === 'enumMembers' || type === 'classMembers') {
|
|
53
|
+
const item = json[filePath][type];
|
|
54
|
+
if (parentSymbol && item) {
|
|
55
|
+
item[parentSymbol] = item[parentSymbol] ?? [];
|
|
56
|
+
item[parentSymbol].push(symbol);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
json[filePath][type]?.push(symbol);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
console.log(JSON.stringify(Object.values(json)));
|
|
67
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import EasyTable from 'easy-table';
|
|
3
|
+
import { ROOT_WORKSPACE_NAME } from '../constants.js';
|
|
4
|
+
import { relative } from '../util/path.js';
|
|
5
|
+
import { getTitle, logTitle, logIssueSet, identity } from './util.js';
|
|
6
|
+
const TRUNCATE_WIDTH = 40;
|
|
7
|
+
const truncate = (text) => (text.length > TRUNCATE_WIDTH ? text.slice(0, TRUNCATE_WIDTH - 3) + '...' : text);
|
|
8
|
+
const logIssueRecord = (issues) => {
|
|
9
|
+
const table = new EasyTable();
|
|
10
|
+
issues.forEach(issue => {
|
|
11
|
+
const print = issue.severity === 'warn' ? chalk.grey : identity;
|
|
12
|
+
table.cell('symbol', print(issue.symbols ? truncate(issue.symbols.join(', ')) : issue.symbol));
|
|
13
|
+
issue.parentSymbol && table.cell('parentSymbol', print(issue.parentSymbol));
|
|
14
|
+
issue.symbolType && table.cell('symbolType', print(issue.symbolType));
|
|
15
|
+
table.cell('filePath', print(relative(issue.filePath)));
|
|
16
|
+
table.newRow();
|
|
17
|
+
});
|
|
18
|
+
console.log(table.sort(['filePath', 'parentSymbol', 'symbol']).print().trim());
|
|
19
|
+
};
|
|
20
|
+
export default ({ report, issues, configurationHints, noConfigHints, isShowProgress }) => {
|
|
21
|
+
const reportMultipleGroups = Object.values(report).filter(Boolean).length > 1;
|
|
22
|
+
let totalIssues = 0;
|
|
23
|
+
for (const [reportType, isReportType] of Object.entries(report)) {
|
|
24
|
+
if (isReportType) {
|
|
25
|
+
const title = reportMultipleGroups && getTitle(reportType);
|
|
26
|
+
const isSet = issues[reportType] instanceof Set;
|
|
27
|
+
const issuesForType = isSet
|
|
28
|
+
? Array.from(issues[reportType])
|
|
29
|
+
: Object.values(issues[reportType]).map(Object.values).flat();
|
|
30
|
+
if (issuesForType.length > 0) {
|
|
31
|
+
title && logTitle(title, issuesForType.length);
|
|
32
|
+
if (isSet) {
|
|
33
|
+
logIssueSet(issuesForType);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
logIssueRecord(issuesForType);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
totalIssues = totalIssues + issuesForType.length;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (!noConfigHints && configurationHints.size > 0) {
|
|
43
|
+
logTitle('Configuration issues', configurationHints.size);
|
|
44
|
+
configurationHints.forEach(hint => {
|
|
45
|
+
const { type, workspaceName, identifier } = hint;
|
|
46
|
+
const message = `Unused item in ${type}`;
|
|
47
|
+
const workspace = workspaceName && workspaceName !== ROOT_WORKSPACE_NAME ? ` (workspace: ${workspaceName})` : ``;
|
|
48
|
+
console.warn(chalk.grey(`${message}${workspace}:`), identifier);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (totalIssues === 0 && isShowProgress) {
|
|
52
|
+
console.log('✂️ Excellent, Knip found no issues.');
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ISSUE_TYPE_TITLE } from '../constants.js';
|
|
2
|
+
import type { IssueSeverity } from '../types/issues.js';
|
|
3
|
+
export declare const identity: (text: string) => string;
|
|
4
|
+
export declare const getTitle: (reportType: keyof typeof ISSUE_TYPE_TITLE) => string;
|
|
5
|
+
export declare const logTitle: (title: string, count: number) => void;
|
|
6
|
+
type LogIssueLine = {
|
|
7
|
+
owner?: string;
|
|
8
|
+
filePath: string;
|
|
9
|
+
symbols?: string[];
|
|
10
|
+
parentSymbol?: string;
|
|
11
|
+
severity?: IssueSeverity;
|
|
12
|
+
};
|
|
13
|
+
export declare const logIssueLine: ({ owner, filePath, symbols, parentSymbol, severity }: LogIssueLine) => void;
|
|
14
|
+
export declare const logIssueSet: (issues: string[]) => void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { ISSUE_TYPE_TITLE } from '../constants.js';
|
|
3
|
+
import { toRelative, relative } from '../util/path.js';
|
|
4
|
+
export const identity = (text) => text;
|
|
5
|
+
export const getTitle = (reportType) => {
|
|
6
|
+
return ISSUE_TYPE_TITLE[reportType];
|
|
7
|
+
};
|
|
8
|
+
export const logTitle = (title, count) => console.log(`${chalk.bold.yellow.underline(title)} (${count})`);
|
|
9
|
+
export const logIssueLine = ({ owner, filePath, symbols, parentSymbol, severity }) => {
|
|
10
|
+
const symbol = symbols ? `: ${symbols.join(', ')}` : '';
|
|
11
|
+
const parent = parentSymbol ? ` (${parentSymbol})` : '';
|
|
12
|
+
const print = severity === 'warn' ? chalk.grey : identity;
|
|
13
|
+
console.log(`${owner ? `${chalk.cyan(owner)} ` : ''}${print(`${relative(filePath)}${symbol}${parent}`)}`);
|
|
14
|
+
};
|
|
15
|
+
export const logIssueSet = (issues) => {
|
|
16
|
+
issues.sort().forEach(value => console.log(toRelative(value)));
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type FileExtension = string;
|
|
2
|
+
export type SyncCompilerFn = (source: string, path: string) => string;
|
|
3
|
+
export type AsyncCompilerFn = (source: string, path: string) => Promise<string>;
|
|
4
|
+
export type SyncCompilers = Map<FileExtension, SyncCompilerFn>;
|
|
5
|
+
export type AsyncCompilers = Map<FileExtension, AsyncCompilerFn>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ConfigurationValidator } from '../ConfigurationValidator.js';
|
|
3
|
+
import * as Plugins from '../plugins/index.js';
|
|
4
|
+
import type { Rules } from './issues.js';
|
|
5
|
+
import type { SyncCompilers, AsyncCompilers } from '../types/compilers.js';
|
|
6
|
+
export type RawConfiguration = z.infer<typeof ConfigurationValidator>;
|
|
7
|
+
type NormalizedGlob = string[];
|
|
8
|
+
export type PluginName = keyof typeof Plugins;
|
|
9
|
+
export type PluginConfiguration = {
|
|
10
|
+
config: NormalizedGlob | null;
|
|
11
|
+
entry: NormalizedGlob | null;
|
|
12
|
+
project: NormalizedGlob | null;
|
|
13
|
+
} | false;
|
|
14
|
+
type PluginsConfiguration = Record<PluginName, PluginConfiguration>;
|
|
15
|
+
interface BaseWorkspaceConfiguration {
|
|
16
|
+
entry: NormalizedGlob;
|
|
17
|
+
project: NormalizedGlob;
|
|
18
|
+
paths: Record<string, string[]>;
|
|
19
|
+
ignore: NormalizedGlob;
|
|
20
|
+
ignoreBinaries: string[];
|
|
21
|
+
ignoreDependencies: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface WorkspaceConfiguration extends BaseWorkspaceConfiguration, Partial<PluginsConfiguration> {
|
|
24
|
+
}
|
|
25
|
+
type IgnorableExport = 'class' | 'enum' | 'function' | 'interface' | 'member' | 'type';
|
|
26
|
+
export interface Configuration {
|
|
27
|
+
rules: Rules;
|
|
28
|
+
include: string[];
|
|
29
|
+
exclude: string[];
|
|
30
|
+
ignore: NormalizedGlob;
|
|
31
|
+
ignoreBinaries: string[];
|
|
32
|
+
ignoreDependencies: string[];
|
|
33
|
+
ignoreExportsUsedInFile: boolean | Partial<Record<IgnorableExport, boolean>>;
|
|
34
|
+
ignoreWorkspaces: string[];
|
|
35
|
+
workspaces: Record<string, WorkspaceConfiguration>;
|
|
36
|
+
syncCompilers: SyncCompilers;
|
|
37
|
+
asyncCompilers: AsyncCompilers;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import type { SymbolType } from './issues.js';
|
|
3
|
+
type FilePath = string;
|
|
4
|
+
type Identifier = string;
|
|
5
|
+
export type ExportItem = {
|
|
6
|
+
node: ts.Node;
|
|
7
|
+
pos: number;
|
|
8
|
+
type: SymbolType;
|
|
9
|
+
members?: ExportItemMember[];
|
|
10
|
+
jsDocTags?: string[];
|
|
11
|
+
};
|
|
12
|
+
export type ExportItemMember = {
|
|
13
|
+
node: ts.Node;
|
|
14
|
+
identifier: Identifier;
|
|
15
|
+
pos: number;
|
|
16
|
+
type: SymbolType;
|
|
17
|
+
};
|
|
18
|
+
export type ExportItems = Map<string, Required<ExportItem>>;
|
|
19
|
+
export type Exports = Map<FilePath, ExportItems>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type FilePath = string;
|
|
2
|
+
type Specifier = string;
|
|
3
|
+
type Identifier = string;
|
|
4
|
+
type ImportItems = Set<Identifier>;
|
|
5
|
+
export type ImportedModule = {
|
|
6
|
+
specifier: Specifier;
|
|
7
|
+
symbols: ImportItems;
|
|
8
|
+
isStar: boolean;
|
|
9
|
+
isReExport: boolean;
|
|
10
|
+
isReExportedBy: Set<string>;
|
|
11
|
+
};
|
|
12
|
+
export type Imports = Map<FilePath, ImportedModule>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare enum SymbolType {
|
|
2
|
+
TYPE = "type",
|
|
3
|
+
INTERFACE = "interface",
|
|
4
|
+
ENUM = "enum",
|
|
5
|
+
FUNCTION = "function",
|
|
6
|
+
CLASS = "class",
|
|
7
|
+
MEMBER = "member",
|
|
8
|
+
UNKNOWN = "unknown"
|
|
9
|
+
}
|
|
10
|
+
export type Issue = {
|
|
11
|
+
type: SymbolIssueType;
|
|
12
|
+
filePath: string;
|
|
13
|
+
symbol: string;
|
|
14
|
+
symbols?: string[];
|
|
15
|
+
symbolType?: SymbolType;
|
|
16
|
+
parentSymbol?: string;
|
|
17
|
+
severity?: IssueSeverity;
|
|
18
|
+
};
|
|
19
|
+
export type IssueSet = Set<string>;
|
|
20
|
+
export type IssueRecords = Record<string, Record<string, Issue>>;
|
|
21
|
+
export type Issues = {
|
|
22
|
+
files: IssueSet;
|
|
23
|
+
dependencies: IssueRecords;
|
|
24
|
+
devDependencies: IssueRecords;
|
|
25
|
+
optionalPeerDependencies: IssueRecords;
|
|
26
|
+
unlisted: IssueRecords;
|
|
27
|
+
binaries: IssueRecords;
|
|
28
|
+
unresolved: IssueRecords;
|
|
29
|
+
exports: IssueRecords;
|
|
30
|
+
types: IssueRecords;
|
|
31
|
+
nsExports: IssueRecords;
|
|
32
|
+
nsTypes: IssueRecords;
|
|
33
|
+
duplicates: IssueRecords;
|
|
34
|
+
enumMembers: IssueRecords;
|
|
35
|
+
classMembers: IssueRecords;
|
|
36
|
+
};
|
|
37
|
+
export type IssueType = keyof Issues;
|
|
38
|
+
export type SymbolIssueType = Exclude<IssueType, 'files'>;
|
|
39
|
+
export type Report = {
|
|
40
|
+
[key in keyof Issues]: boolean;
|
|
41
|
+
};
|
|
42
|
+
export type Counters = Record<IssueType | 'processed' | 'total', number>;
|
|
43
|
+
export type ReporterOptions = {
|
|
44
|
+
report: Report;
|
|
45
|
+
issues: Issues;
|
|
46
|
+
configurationHints: ConfigurationHints;
|
|
47
|
+
noConfigHints: boolean;
|
|
48
|
+
cwd: string;
|
|
49
|
+
isProduction: boolean;
|
|
50
|
+
isShowProgress: boolean;
|
|
51
|
+
options: string;
|
|
52
|
+
};
|
|
53
|
+
export type Reporter = (options: ReporterOptions) => void;
|
|
54
|
+
export type Preprocessor = (options: ReporterOptions) => ReporterOptions;
|
|
55
|
+
export type IssueSeverity = 'error' | 'warn' | 'off';
|
|
56
|
+
export type Rules = Record<IssueType, IssueSeverity>;
|
|
57
|
+
export type ConfigurationHints = Set<ConfigurationHint>;
|
|
58
|
+
export type ConfigurationHint = {
|
|
59
|
+
type: 'ignoreBinaries' | 'ignoreDependencies' | 'ignoreWorkspaces';
|
|
60
|
+
identifier: string;
|
|
61
|
+
workspaceName?: string;
|
|
62
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var SymbolType;
|
|
2
|
+
(function (SymbolType) {
|
|
3
|
+
SymbolType["TYPE"] = "type";
|
|
4
|
+
SymbolType["INTERFACE"] = "interface";
|
|
5
|
+
SymbolType["ENUM"] = "enum";
|
|
6
|
+
SymbolType["FUNCTION"] = "function";
|
|
7
|
+
SymbolType["CLASS"] = "class";
|
|
8
|
+
SymbolType["MEMBER"] = "member";
|
|
9
|
+
SymbolType["UNKNOWN"] = "unknown";
|
|
10
|
+
})(SymbolType || (SymbolType = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="npmcli__package-json" />
|
|
2
|
+
import type { PluginConfiguration, WorkspaceConfiguration } from './config.js';
|
|
3
|
+
import type { PackageJson } from '@npmcli/package-json';
|
|
4
|
+
export type PackageJsonWithPlugins = PackageJson & Record<string, unknown>;
|
|
5
|
+
type IsPluginEnabledCallbackOptions = {
|
|
6
|
+
cwd: string;
|
|
7
|
+
manifest: PackageJson;
|
|
8
|
+
dependencies: Set<string>;
|
|
9
|
+
config: WorkspaceConfiguration;
|
|
10
|
+
};
|
|
11
|
+
export type IsPluginEnabledCallback = (options: IsPluginEnabledCallbackOptions) => boolean | Promise<boolean>;
|
|
12
|
+
type GenericPluginCallbackOptions = {
|
|
13
|
+
cwd: string;
|
|
14
|
+
manifest: PackageJsonWithPlugins;
|
|
15
|
+
config: PluginConfiguration;
|
|
16
|
+
isProduction: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type GenericPluginCallback = (configFilePath: string, options: GenericPluginCallbackOptions) => Promise<string[]> | string[];
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type WorkspaceManifest = {
|
|
2
|
+
workspaceDir: string;
|
|
3
|
+
manifestPath: string;
|
|
4
|
+
scripts: string[];
|
|
5
|
+
dependencies: string[];
|
|
6
|
+
peerDependencies: string[];
|
|
7
|
+
optionalPeerDependencies: string[];
|
|
8
|
+
optionalDependencies: string[];
|
|
9
|
+
devDependencies: string[];
|
|
10
|
+
allDependencies: string[];
|
|
11
|
+
ignoreDependencies: string[];
|
|
12
|
+
ignoreBinaries: string[];
|
|
13
|
+
};
|
|
14
|
+
export type WorkspaceManifests = Map<string, WorkspaceManifest>;
|
|
15
|
+
export type PeerDependencies = Map<string, Set<string>>;
|
|
16
|
+
export type InstalledBinaries = Map<string, Set<string>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
type SymbolTable = Map<string, ts.Symbol>;
|
|
3
|
+
type SymbolWithExports = ts.Symbol & {
|
|
4
|
+
exports?: SymbolTable;
|
|
5
|
+
};
|
|
6
|
+
type PragmaMap = {
|
|
7
|
+
arguments: {
|
|
8
|
+
factory: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export interface BoundSourceFile extends ts.SourceFile {
|
|
12
|
+
symbol?: SymbolWithExports;
|
|
13
|
+
resolvedModules?: ts.ModeAwareCache<ts.ResolvedModuleWithFailedLookupLocations>;
|
|
14
|
+
locals?: SymbolTable;
|
|
15
|
+
scriptKind?: ts.ScriptKind;
|
|
16
|
+
pragmas?: Map<string, PragmaMap | PragmaMap[]>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import type { SyncCompilers, AsyncCompilers } from '../types/compilers.js';
|
|
3
|
+
export declare class SourceFileManager {
|
|
4
|
+
sourceFileCache: Map<string, ts.SourceFile | undefined>;
|
|
5
|
+
snapshotCache: Map<string, ts.IScriptSnapshot | undefined>;
|
|
6
|
+
syncCompilers?: SyncCompilers;
|
|
7
|
+
asyncCompilers?: AsyncCompilers;
|
|
8
|
+
installCompilers(compilers: [SyncCompilers, AsyncCompilers]): void;
|
|
9
|
+
createSourceFile(filePath: string, contents: string): ts.SourceFile;
|
|
10
|
+
getSourceFile(filePath: string): ts.SourceFile | undefined;
|
|
11
|
+
getSnapshot(filePath: string): ts.IScriptSnapshot | undefined;
|
|
12
|
+
compileAndAddSourceFile(filePath: string): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { debugLog } from '../util/debug.js';
|
|
3
|
+
import { extname, isInternal } from '../util/path.js';
|
|
4
|
+
export class SourceFileManager {
|
|
5
|
+
sourceFileCache = new Map();
|
|
6
|
+
snapshotCache = new Map();
|
|
7
|
+
syncCompilers;
|
|
8
|
+
asyncCompilers;
|
|
9
|
+
installCompilers(compilers) {
|
|
10
|
+
this.syncCompilers = compilers[0];
|
|
11
|
+
this.asyncCompilers = compilers[1];
|
|
12
|
+
}
|
|
13
|
+
createSourceFile(filePath, contents) {
|
|
14
|
+
const setParentNodes = isInternal(filePath);
|
|
15
|
+
const sourceFile = ts.createSourceFile(filePath, contents, ts.ScriptTarget.Latest, setParentNodes);
|
|
16
|
+
this.sourceFileCache.set(filePath, sourceFile);
|
|
17
|
+
return sourceFile;
|
|
18
|
+
}
|
|
19
|
+
getSourceFile(filePath) {
|
|
20
|
+
if (this.sourceFileCache.has(filePath))
|
|
21
|
+
return this.sourceFileCache.get(filePath);
|
|
22
|
+
const contents = ts.sys.readFile(filePath);
|
|
23
|
+
if (typeof contents !== 'string') {
|
|
24
|
+
if (isInternal(filePath))
|
|
25
|
+
throw new Error(`Unable to read ${filePath}`);
|
|
26
|
+
return this.createSourceFile(filePath, '');
|
|
27
|
+
}
|
|
28
|
+
const ext = extname(filePath);
|
|
29
|
+
const compiler = this.syncCompilers?.get(ext);
|
|
30
|
+
const compiled = compiler ? compiler(contents, filePath) : contents;
|
|
31
|
+
if (compiler)
|
|
32
|
+
debugLog(`Compiled ${filePath}`);
|
|
33
|
+
return this.createSourceFile(filePath, compiled);
|
|
34
|
+
}
|
|
35
|
+
getSnapshot(filePath) {
|
|
36
|
+
if (this.snapshotCache.has(filePath))
|
|
37
|
+
return this.snapshotCache.get(filePath);
|
|
38
|
+
const sourceFile = this.getSourceFile(filePath);
|
|
39
|
+
if (!sourceFile)
|
|
40
|
+
return undefined;
|
|
41
|
+
const snapshot = ts.ScriptSnapshot.fromString(sourceFile.text);
|
|
42
|
+
this.snapshotCache.set(filePath, snapshot);
|
|
43
|
+
return snapshot;
|
|
44
|
+
}
|
|
45
|
+
async compileAndAddSourceFile(filePath) {
|
|
46
|
+
const contents = ts.sys.readFile(filePath);
|
|
47
|
+
if (typeof contents !== 'string')
|
|
48
|
+
throw new Error(`Unable to read ${filePath}`);
|
|
49
|
+
const ext = extname(filePath);
|
|
50
|
+
const compiler = this.asyncCompilers?.get(ext);
|
|
51
|
+
if (compiler) {
|
|
52
|
+
const compiled = await compiler(contents, filePath);
|
|
53
|
+
debugLog(`Compiled ${filePath}`);
|
|
54
|
+
this.createSourceFile(filePath, compiled);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
interface ValidImportTypeNode extends ts.ImportTypeNode {
|
|
3
|
+
argument: ts.LiteralTypeNode & {
|
|
4
|
+
literal: ts.StringLiteral;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export declare function isValidImportTypeNode(node: ts.Node): node is ValidImportTypeNode;
|
|
8
|
+
export declare function isPrivateMember(node: ts.MethodDeclaration | ts.PropertyDeclaration): boolean;
|
|
9
|
+
export declare function isDefaultImport(node: ts.ImportDeclaration | ts.ImportEqualsDeclaration | ts.ExportDeclaration): boolean;
|
|
10
|
+
export declare function isAccessExpression(node: ts.Node): node is ts.PropertyAccessExpression | ts.ElementAccessExpression;
|
|
11
|
+
export declare function isImportCall(node: ts.Node): node is ts.ImportCall;
|
|
12
|
+
export declare function isRequireCall(callExpression: ts.Node): callExpression is ts.CallExpression;
|
|
13
|
+
export declare function isRequireResolveCall(node: ts.Node): node is ts.CallExpression;
|
|
14
|
+
export declare function getAccessExpressionName(node: ts.PropertyAccessExpression | ts.ElementAccessExpression): string;
|
|
15
|
+
type LiteralLikeElementAccessExpression = ts.ElementAccessExpression & ts.Declaration & {
|
|
16
|
+
readonly argumentExpression: ts.StringLiteralLike | ts.NumericLiteral;
|
|
17
|
+
};
|
|
18
|
+
export declare function isModuleExportsAccessExpression(node: ts.Node): node is LiteralLikeElementAccessExpression & {
|
|
19
|
+
expression: ts.Identifier;
|
|
20
|
+
};
|
|
21
|
+
export declare function stripQuotes(name: string): string;
|
|
22
|
+
export declare function findAncestor<T>(node: ts.Node | undefined, callback: (element: ts.Node) => boolean | 'STOP'): T | undefined;
|
|
23
|
+
export declare function findDescendants<T>(node: ts.Node | undefined, callback: (element: ts.Node) => boolean | 'STOP'): T[];
|
|
24
|
+
export declare const isDeclarationFileExtension: (extension: string) => boolean;
|
|
25
|
+
export declare const isInModuleBlock: (node: ts.Node) => boolean;
|
|
26
|
+
export declare const getJSDocTags: (node: ts.Node) => string[];
|
|
27
|
+
export {};
|