@codefast/cli 0.9.0 → 0.11.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/CHANGELOG.md +61 -0
- package/README.md +345 -151
- package/dist/arrange/command.d.ts +7 -0
- package/dist/arrange/command.js +96 -132
- package/dist/arrange/domain/ast/ast-node.d.ts +394 -0
- package/dist/arrange/domain/ast/collectors-cn.d.ts +26 -0
- package/dist/arrange/domain/ast/collectors-jsx.d.ts +8 -0
- package/dist/arrange/domain/ast/collectors-tv.d.ts +34 -0
- package/dist/arrange/domain/ast/helpers.d.ts +36 -0
- package/dist/arrange/domain/ast/helpers.js +1 -0
- package/dist/arrange/domain/ast/simplify-targets.d.ts +22 -0
- package/dist/arrange/domain/ast/simplify-targets.js +18 -23
- package/dist/arrange/domain/ast/targets.d.ts +20 -0
- package/dist/arrange/domain/ast/translator.d.ts +32 -0
- package/dist/arrange/{typescript-ast-translator.js → domain/ast/translator.js} +19 -22
- package/dist/arrange/domain/constants.d.ts +111 -0
- package/dist/arrange/domain/grouping-service.d.ts +100 -0
- package/dist/arrange/domain/grouping.d.ts +21 -0
- package/dist/arrange/domain/imports.d.ts +14 -0
- package/dist/arrange/domain/source-text-formatters.d.ts +33 -0
- package/dist/arrange/domain/tailwind-token.d.ts +24 -0
- package/dist/arrange/domain/token-classifier.d.ts +47 -0
- package/dist/arrange/domain/types.d.ts +208 -0
- package/dist/arrange/group/cli-result.d.ts +7 -0
- package/dist/arrange/group/cli-result.js +12 -0
- package/dist/arrange/group/cli-schema.d.ts +17 -0
- package/dist/arrange/group/cli-schema.js +13 -0
- package/dist/arrange/group/output.d.ts +7 -0
- package/dist/arrange/group/output.js +10 -0
- package/dist/arrange/group/suggest.d.ts +8 -0
- package/dist/arrange/inspect/cli-result.d.ts +7 -0
- package/dist/arrange/inspect/cli-result.js +8 -0
- package/dist/arrange/inspect/cli-schema.d.ts +15 -0
- package/dist/arrange/inspect/cli-schema.js +9 -0
- package/dist/arrange/inspect/domain/analyze-service.d.ts +18 -0
- package/dist/arrange/inspect/output.d.ts +7 -0
- package/dist/arrange/inspect/output.js +42 -0
- package/dist/arrange/inspect/run.d.ts +10 -0
- package/dist/arrange/{analyze.js → inspect/run.js} +2 -2
- package/dist/arrange/prepare.d.ts +13 -0
- package/dist/arrange/{workspace.js → prepare.js} +5 -8
- package/dist/arrange/regroup/cli-result.d.ts +13 -0
- package/dist/arrange/regroup/cli-result.js +23 -0
- package/dist/arrange/regroup/cli-schema.d.ts +20 -0
- package/dist/arrange/regroup/cli-schema.js +14 -0
- package/dist/arrange/regroup/output.d.ts +14 -0
- package/dist/arrange/regroup/output.js +72 -0
- package/dist/arrange/regroup/process-file.d.ts +11 -0
- package/dist/arrange/regroup/run.d.ts +11 -0
- package/dist/arrange/{sync.js → regroup/run.js} +2 -2
- package/dist/arrange/resolve-target.d.ts +10 -0
- package/dist/arrange/resolve-target.js +3 -16
- package/dist/arrange/scan-target.d.ts +7 -0
- package/dist/arrange/simplify/cli-result.d.ts +7 -0
- package/dist/arrange/simplify/cli-result.js +8 -0
- package/dist/arrange/simplify/cli-schema.d.ts +17 -0
- package/dist/arrange/simplify/cli-schema.js +11 -0
- package/dist/arrange/simplify/fold-targets.d.ts +13 -0
- package/dist/arrange/simplify/fold-targets.js +139 -0
- package/dist/arrange/simplify/output.d.ts +7 -0
- package/dist/arrange/simplify/output.js +15 -0
- package/dist/arrange/simplify/process-file.d.ts +13 -0
- package/dist/arrange/simplify/process-file.js +49 -0
- package/dist/arrange/simplify/run.d.ts +14 -0
- package/dist/arrange/simplify/run.js +38 -0
- package/dist/arrange/simplify/variant-classname-probe.d.ts +35 -0
- package/dist/arrange/simplify/variant-classname-probe.js +95 -0
- package/dist/arrange/source-parse.d.ts +7 -0
- package/dist/arrange/source-parse.js +1 -1
- package/dist/audit/command.d.ts +8 -0
- package/dist/audit/command.js +134 -211
- package/dist/audit/comments/cli-result.d.ts +13 -0
- package/dist/audit/comments/cli-result.js +22 -0
- package/dist/audit/comments/cli-schema.d.ts +19 -0
- package/dist/audit/comments/cli-schema.js +13 -0
- package/dist/audit/comments/domain/comment-content.d.ts +26 -0
- package/dist/audit/comments/domain/comment-dividers.d.ts +62 -0
- package/dist/audit/comments/domain/link-references.d.ts +40 -0
- package/dist/audit/comments/domain/since-versions.d.ts +26 -0
- package/dist/audit/comments/domain/tsdoc-syntax.d.ts +20 -0
- package/dist/audit/comments/output.d.ts +7 -0
- package/dist/audit/comments/output.js +27 -0
- package/dist/audit/comments/prepare.d.ts +16 -0
- package/dist/audit/comments/prepare.js +12 -0
- package/dist/audit/comments/run.d.ts +17 -0
- package/dist/audit/{run-comments.js → comments/run.js} +5 -5
- package/dist/audit/display-names/cli-result.d.ts +13 -0
- package/dist/audit/display-names/cli-result.js +22 -0
- package/dist/audit/display-names/cli-schema.d.ts +18 -0
- package/dist/audit/display-names/cli-schema.js +12 -0
- package/dist/audit/display-names/domain/display-names.d.ts +11 -0
- package/dist/audit/display-names/output.d.ts +7 -0
- package/dist/audit/display-names/output.js +21 -0
- package/dist/audit/display-names/prepare.d.ts +16 -0
- package/dist/audit/display-names/prepare.js +12 -0
- package/dist/audit/display-names/run.d.ts +14 -0
- package/dist/audit/{run-display-names.js → display-names/run.js} +1 -1
- package/dist/audit/domain/types.d.ts +171 -0
- package/dist/audit/imports/cli-result.d.ts +13 -0
- package/dist/audit/imports/cli-result.js +22 -0
- package/dist/audit/imports/cli-schema.d.ts +18 -0
- package/dist/audit/imports/cli-schema.js +12 -0
- package/dist/audit/imports/domain/import-policy.d.ts +34 -0
- package/dist/audit/imports/domain/import-policy.js +140 -0
- package/dist/audit/imports/output.d.ts +7 -0
- package/dist/audit/imports/output.js +21 -0
- package/dist/audit/imports/prepare.d.ts +16 -0
- package/dist/audit/imports/prepare.js +12 -0
- package/dist/audit/imports/run.d.ts +14 -0
- package/dist/audit/{run-react.js → imports/run.js} +15 -5
- package/dist/audit/links/cli-result.d.ts +13 -0
- package/dist/audit/links/cli-result.js +22 -0
- package/dist/audit/links/cli-schema.d.ts +18 -0
- package/dist/audit/links/cli-schema.js +12 -0
- package/dist/audit/links/domain/markdown-links.d.ts +44 -0
- package/dist/audit/links/output.d.ts +7 -0
- package/dist/audit/links/output.js +21 -0
- package/dist/audit/links/prepare.d.ts +16 -0
- package/dist/audit/links/prepare.js +12 -0
- package/dist/audit/links/run.d.ts +14 -0
- package/dist/audit/{run-links.js → links/run.js} +1 -1
- package/dist/audit/prepare.d.ts +31 -0
- package/dist/audit/prepare.js +11 -134
- package/dist/audit/rtl/cli-result.d.ts +13 -0
- package/dist/audit/rtl/cli-result.js +22 -0
- package/dist/audit/rtl/cli-schema.d.ts +18 -0
- package/dist/audit/rtl/cli-schema.js +12 -0
- package/dist/audit/rtl/domain/audit-file.d.ts +7 -0
- package/dist/audit/{domain → rtl/domain}/audit-file.js +2 -2
- package/dist/audit/rtl/domain/mappings.d.ts +45 -0
- package/dist/audit/rtl/domain/tokenize.d.ts +14 -0
- package/dist/audit/rtl/output.d.ts +7 -0
- package/dist/audit/rtl/output.js +21 -0
- package/dist/audit/rtl/prepare.d.ts +13 -0
- package/dist/audit/rtl/prepare.js +41 -0
- package/dist/audit/rtl/run.d.ts +14 -0
- package/dist/audit/{run.js → rtl/run.js} +1 -1
- package/dist/bin.d.ts +2 -0
- package/dist/cli.d.ts +6 -0
- package/dist/core/cli/command-pipeline.d.ts +91 -0
- package/dist/core/cli/command-pipeline.js +83 -0
- package/dist/core/cli/format-error.d.ts +7 -0
- package/dist/core/cli/global-options.d.ts +15 -0
- package/dist/core/cli/global-options.js +1 -1
- package/dist/core/cli/positional.d.ts +6 -0
- package/dist/core/cli/resolve-root.d.ts +9 -0
- package/dist/core/cli/resolve-root.js +16 -0
- package/dist/core/cli/result-handle.d.ts +13 -0
- package/dist/core/cli/result-handle.js +0 -13
- package/dist/core/config/define-config.d.ts +7 -0
- package/dist/core/config/define-config.js +8 -0
- package/dist/core/config/loader.d.ts +18 -0
- package/dist/core/config/loader.js +2 -7
- package/dist/core/config/schema.d.ts +99 -0
- package/dist/core/config/schema.js +8 -86
- package/dist/core/config/warnings.d.ts +6 -0
- package/dist/core/config.d.ts +12 -0
- package/dist/core/errors.d.ts +25 -0
- package/dist/core/exit-codes.d.ts +18 -0
- package/dist/core/filesystem/filesystem.d.ts +44 -0
- package/dist/core/filesystem/node.d.ts +7 -0
- package/dist/core/filesystem/node.js +2 -1
- package/dist/core/glob.d.ts +19 -0
- package/dist/core/logger.d.ts +9 -0
- package/dist/core/result.d.ts +30 -0
- package/dist/core/schema-parse.d.ts +9 -0
- package/dist/core/source-text-edit.d.ts +47 -0
- package/dist/core/source-text-edit.js +22 -0
- package/dist/core/verbose-diagnostics.d.ts +6 -0
- package/dist/core/workspace/ancestor-directories.d.ts +12 -0
- package/dist/core/workspace/ancestor-directories.js +30 -0
- package/dist/core/workspace/markdown-walk.d.ts +7 -0
- package/dist/core/workspace/markdown-walk.js +2 -20
- package/dist/core/workspace/package-version.d.ts +9 -0
- package/dist/core/workspace/package-version.js +8 -12
- package/dist/core/workspace/resolver.d.ts +39 -0
- package/dist/core/workspace/resolver.js +58 -75
- package/dist/core/workspace/skip-directories.d.ts +6 -0
- package/dist/core/workspace/source-walk.d.ts +16 -0
- package/dist/core/workspace/source-walk.js +2 -19
- package/dist/core/workspace/typescript-walk.d.ts +7 -0
- package/dist/core/workspace/typescript-walk.js +2 -23
- package/dist/core/workspace/walk-files.d.ts +7 -0
- package/dist/core/workspace/walk-files.js +27 -0
- package/dist/core/workspace/well-known-files.d.ts +18 -0
- package/dist/core/workspace/well-known-files.js +18 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/mirror/cli-result.d.ts +13 -0
- package/dist/mirror/cli-schema.d.ts +8 -0
- package/dist/mirror/cli-schema.js +1 -1
- package/dist/mirror/command.d.ts +7 -0
- package/dist/mirror/command.js +31 -60
- package/dist/mirror/dist-filesystem-node.d.ts +8 -0
- package/dist/mirror/{dist-filesystem-impl.js → dist-filesystem-node.js} +1 -1
- package/dist/mirror/domain/constants.d.ts +18 -0
- package/dist/mirror/domain/constants.js +0 -12
- package/dist/mirror/domain/dirent-guard.d.ts +10 -0
- package/dist/mirror/domain/dist-filesystem.d.ts +9 -0
- package/dist/mirror/domain/errors.d.ts +24 -0
- package/dist/mirror/domain/exports.d.ts +36 -0
- package/dist/mirror/domain/package-display-name.d.ts +8 -0
- package/dist/mirror/domain/path-normalizer.d.ts +6 -0
- package/dist/mirror/domain/types.d.ts +188 -0
- package/dist/mirror/output.d.ts +21 -0
- package/dist/mirror/output.js +126 -1
- package/dist/mirror/package-path.d.ts +19 -0
- package/dist/mirror/prepare.d.ts +15 -0
- package/dist/mirror/prepare.js +6 -10
- package/dist/mirror/run.d.ts +12 -0
- package/dist/mirror/{sync.js → run.js} +5 -3
- package/dist/mirror/supplement-exports.d.ts +27 -0
- package/dist/mirror/supplement-exports.js +2 -2
- package/dist/mirror/sync-workspace-package.d.ts +9 -0
- package/dist/mirror/sync-workspace-package.js +4 -4
- package/dist/mirror/write-exports.d.ts +15 -0
- package/dist/pack-slim/cli-result.d.ts +13 -0
- package/dist/pack-slim/cli-schema.d.ts +17 -0
- package/dist/pack-slim/cli-schema.js +1 -1
- package/dist/pack-slim/command.d.ts +7 -0
- package/dist/pack-slim/command.js +31 -66
- package/dist/pack-slim/domain/transform.d.ts +69 -0
- package/dist/pack-slim/domain/types.d.ts +46 -0
- package/dist/pack-slim/output.d.ts +15 -0
- package/dist/pack-slim/prepare.d.ts +21 -0
- package/dist/pack-slim/prepare.js +14 -0
- package/dist/pack-slim/run.d.ts +23 -0
- package/dist/pack-slim/{sync.js → run.js} +4 -4
- package/dist/pack-slim/working-tree.d.ts +20 -0
- package/dist/tag/cli-result.d.ts +13 -0
- package/dist/tag/cli-result.js +14 -1
- package/dist/tag/cli-schema.d.ts +8 -0
- package/dist/tag/cli-schema.js +3 -4
- package/dist/tag/command.d.ts +7 -0
- package/dist/tag/command.js +33 -60
- package/dist/tag/domain/skip-filter.d.ts +13 -0
- package/dist/tag/domain/skip-filter.js +29 -0
- package/dist/tag/domain/types.d.ts +131 -0
- package/dist/tag/domain/version-summary.d.ts +13 -0
- package/dist/tag/domain/version-summary.js +24 -0
- package/dist/tag/output.d.ts +17 -0
- package/dist/tag/output.js +6 -9
- package/dist/tag/prepare.d.ts +13 -0
- package/dist/tag/prepare.js +4 -4
- package/dist/tag/run.d.ts +10 -0
- package/dist/tag/{sync.js → run.js} +20 -50
- package/dist/tag/target/candidates.d.ts +8 -0
- package/dist/tag/{target-candidates.js → target/candidates.js} +2 -2
- package/dist/tag/target/resolve-path.d.ts +10 -0
- package/dist/tag/target/runner.d.ts +8 -0
- package/dist/tag/{target-runner.js → target/runner.js} +2 -2
- package/dist/tag/writer/since-writer.d.ts +32 -0
- package/dist/tag/writer/version-resolver.d.ts +7 -0
- package/package.json +21 -2
- package/dist/arrange/cli-schema.js +0 -34
- package/dist/arrange/output.js +0 -127
- package/dist/arrange/simplify-process-file.js +0 -30
- package/dist/arrange/simplify-sync.js +0 -30
- package/dist/audit/cli-schema.js +0 -66
- package/dist/audit/domain/react-imports.js +0 -91
- package/dist/audit/output.js +0 -213
- package/dist/mirror/sync-reporter.js +0 -124
- package/dist/mirror/sync-types.js +0 -1
- /package/dist/arrange/{suggest.js → group/suggest.js} +0 -0
- /package/dist/arrange/{domain → inspect/domain}/analyze-service.js +0 -0
- /package/dist/arrange/{process-file.js → regroup/process-file.js} +0 -0
- /package/dist/audit/{domain → comments/domain}/comment-content.js +0 -0
- /package/dist/audit/{domain → comments/domain}/comment-dividers.js +0 -0
- /package/dist/audit/{domain → comments/domain}/link-references.js +0 -0
- /package/dist/audit/{domain → comments/domain}/since-versions.js +0 -0
- /package/dist/audit/{domain → comments/domain}/tsdoc-syntax.js +0 -0
- /package/dist/audit/{domain → display-names/domain}/display-names.js +0 -0
- /package/dist/audit/{domain → links/domain}/markdown-links.js +0 -0
- /package/dist/audit/{domain → rtl/domain}/mappings.js +0 -0
- /package/dist/audit/{domain → rtl/domain}/tokenize.js +0 -0
- /package/dist/core/filesystem/{port.js → filesystem.js} +0 -0
- /package/dist/tag/{resolve-target-path.js → target/resolve-path.js} +0 -0
- /package/dist/tag/{since-writer.js → writer/since-writer.js} +0 -0
- /package/dist/tag/{version-resolver.js → writer/version-resolver.js} +0 -0
package/dist/audit/command.js
CHANGED
|
@@ -1,18 +1,134 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
1
|
import { Command } from "commander";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { runCommentAudit } from "#/audit/run
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
2
|
+
import { exitCodeForCommentAuditResult, formatCommentAuditJsonOutput } from "#/audit/comments/cli-result";
|
|
3
|
+
import { commentAuditRunRequestSchema } from "#/audit/comments/cli-schema";
|
|
4
|
+
import { presentCommentAuditResult } from "#/audit/comments/output";
|
|
5
|
+
import { prepareCommentAudit } from "#/audit/comments/prepare";
|
|
6
|
+
import { runCommentAudit } from "#/audit/comments/run";
|
|
7
|
+
import { exitCodeForDisplayNameAuditResult, formatDisplayNameAuditJsonOutput } from "#/audit/display-names/cli-result";
|
|
8
|
+
import { displayNameAuditRunRequestSchema } from "#/audit/display-names/cli-schema";
|
|
9
|
+
import { presentDisplayNameAuditResult } from "#/audit/display-names/output";
|
|
10
|
+
import { prepareDisplayNameAudit } from "#/audit/display-names/prepare";
|
|
11
|
+
import { runDisplayNameAudit } from "#/audit/display-names/run";
|
|
12
|
+
import { exitCodeForImportsAuditResult, formatImportsAuditJsonOutput } from "#/audit/imports/cli-result";
|
|
13
|
+
import { importsAuditRunRequestSchema } from "#/audit/imports/cli-schema";
|
|
14
|
+
import { presentImportsAuditResult } from "#/audit/imports/output";
|
|
15
|
+
import { prepareImportsAudit } from "#/audit/imports/prepare";
|
|
16
|
+
import { runImportsAudit } from "#/audit/imports/run";
|
|
17
|
+
import { exitCodeForLinkAuditResult, formatLinkAuditJsonOutput } from "#/audit/links/cli-result";
|
|
18
|
+
import { linkAuditRunRequestSchema } from "#/audit/links/cli-schema";
|
|
19
|
+
import { presentLinkAuditResult } from "#/audit/links/output";
|
|
20
|
+
import { prepareLinkAudit } from "#/audit/links/prepare";
|
|
21
|
+
import { runLinkAudit } from "#/audit/links/run";
|
|
22
|
+
import { exitCodeForRtlAuditResult, formatRtlAuditJsonOutput } from "#/audit/rtl/cli-result";
|
|
23
|
+
import { rtlAuditRunRequestSchema } from "#/audit/rtl/cli-schema";
|
|
24
|
+
import { presentRtlAuditResult } from "#/audit/rtl/output";
|
|
25
|
+
import { prepareRtlAudit } from "#/audit/rtl/prepare";
|
|
26
|
+
import { runRtlAudit } from "#/audit/rtl/run";
|
|
27
|
+
import { registerPipelineSubcommand } from "#/core/cli/command-pipeline";
|
|
13
28
|
import { nodeFilesystem } from "#/core/filesystem/node";
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
function baseAuditRequest(prelude, opts) {
|
|
30
|
+
return {
|
|
31
|
+
rootDir: prelude.rootDir,
|
|
32
|
+
targetPath: prelude.targetPath,
|
|
33
|
+
allowlist: prelude.allowlist,
|
|
34
|
+
json: !!opts.json,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const rtlCheck = {
|
|
38
|
+
name: "rtl",
|
|
39
|
+
description: "Report physical-direction Tailwind classes that should be logical or rtl:-paired",
|
|
40
|
+
targetHelp: "Directory or file to scan (default: audit.rtl.target from config)",
|
|
41
|
+
schema: rtlAuditRunRequestSchema,
|
|
42
|
+
prepare: prepareRtlAudit,
|
|
43
|
+
buildRequest: baseAuditRequest,
|
|
44
|
+
run: (fs, request) => runRtlAudit(fs, { rootDir: request.rootDir, targetPath: request.targetPath, allowlist: request.allowlist ?? [] }),
|
|
45
|
+
present: presentRtlAuditResult,
|
|
46
|
+
formatJson: formatRtlAuditJsonOutput,
|
|
47
|
+
exitCode: exitCodeForRtlAuditResult,
|
|
48
|
+
};
|
|
49
|
+
const linksCheck = {
|
|
50
|
+
name: "links",
|
|
51
|
+
description: "Report markdown links pointing at a missing path or an anchor the target does not offer",
|
|
52
|
+
targetHelp: "Directory or file to scan (default: the repo root)",
|
|
53
|
+
schema: linkAuditRunRequestSchema,
|
|
54
|
+
prepare: prepareLinkAudit,
|
|
55
|
+
buildRequest: baseAuditRequest,
|
|
56
|
+
run: (fs, request) => runLinkAudit(fs, { rootDir: request.rootDir, targetPath: request.targetPath, allowlist: request.allowlist ?? [] }),
|
|
57
|
+
present: presentLinkAuditResult,
|
|
58
|
+
formatJson: formatLinkAuditJsonOutput,
|
|
59
|
+
exitCode: exitCodeForLinkAuditResult,
|
|
60
|
+
};
|
|
61
|
+
const importsCheck = {
|
|
62
|
+
name: "imports",
|
|
63
|
+
description: "Report banned import forms (React by-name, Zod namespace in front-end packages, …)",
|
|
64
|
+
targetHelp: "Directory or file to scan (default: the repo root)",
|
|
65
|
+
schema: importsAuditRunRequestSchema,
|
|
66
|
+
prepare: prepareImportsAudit,
|
|
67
|
+
buildRequest: baseAuditRequest,
|
|
68
|
+
run: (fs, request) => runImportsAudit(fs, {
|
|
69
|
+
rootDir: request.rootDir,
|
|
70
|
+
targetPath: request.targetPath,
|
|
71
|
+
allowlist: request.allowlist ?? [],
|
|
72
|
+
}),
|
|
73
|
+
present: presentImportsAuditResult,
|
|
74
|
+
formatJson: formatImportsAuditJsonOutput,
|
|
75
|
+
exitCode: exitCodeForImportsAuditResult,
|
|
76
|
+
};
|
|
77
|
+
const displayNamesCheck = {
|
|
78
|
+
name: "display-names",
|
|
79
|
+
description: "Report token(), tag() and module display names that break the <namespace>:<Name> convention",
|
|
80
|
+
targetHelp: "Directory or file to scan (default: the repo root)",
|
|
81
|
+
schema: displayNameAuditRunRequestSchema,
|
|
82
|
+
prepare: prepareDisplayNameAudit,
|
|
83
|
+
buildRequest: baseAuditRequest,
|
|
84
|
+
run: (fs, request) => runDisplayNameAudit(fs, {
|
|
85
|
+
rootDir: request.rootDir,
|
|
86
|
+
targetPath: request.targetPath,
|
|
87
|
+
allowlist: request.allowlist ?? [],
|
|
88
|
+
}),
|
|
89
|
+
present: presentDisplayNameAuditResult,
|
|
90
|
+
formatJson: formatDisplayNameAuditJsonOutput,
|
|
91
|
+
exitCode: exitCodeForDisplayNameAuditResult,
|
|
92
|
+
};
|
|
93
|
+
const commentsCheck = {
|
|
94
|
+
name: "comments",
|
|
95
|
+
description: "Report section dividers that are not in the repo's one allowed form",
|
|
96
|
+
targetHelp: "Directory or file to scan (default: the repo root)",
|
|
97
|
+
schema: commentAuditRunRequestSchema,
|
|
98
|
+
prepare: prepareCommentAudit,
|
|
99
|
+
buildRequest: (prelude, opts) => ({ ...baseAuditRequest(prelude, opts), fix: !!opts.fix }),
|
|
100
|
+
run: (fs, request) => runCommentAudit(fs, {
|
|
101
|
+
rootDir: request.rootDir,
|
|
102
|
+
targetPath: request.targetPath,
|
|
103
|
+
allowlist: request.allowlist ?? [],
|
|
104
|
+
fix: request.fix,
|
|
105
|
+
}),
|
|
106
|
+
present: presentCommentAuditResult,
|
|
107
|
+
formatJson: formatCommentAuditJsonOutput,
|
|
108
|
+
exitCode: exitCodeForCommentAuditResult,
|
|
109
|
+
extraOptions: (command) => {
|
|
110
|
+
command.option("--fix", "Rewrite every mechanically fixable divider in place", false);
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Adapts an `AuditCheck` descriptor onto the shared command pipeline.
|
|
115
|
+
*/
|
|
116
|
+
function auditCheckToPipeline(check) {
|
|
117
|
+
return {
|
|
118
|
+
name: check.name,
|
|
119
|
+
description: check.description,
|
|
120
|
+
positional: { name: "[target]", help: check.targetHelp },
|
|
121
|
+
jsonHelp: "Print one JSON summary on stdout",
|
|
122
|
+
schema: check.schema,
|
|
123
|
+
configureArgv: check.extraOptions,
|
|
124
|
+
prepare: (fs, input) => check.prepare(fs, { currentWorkingDirectory: input.currentWorkingDirectory, rawTarget: input.rawArg }),
|
|
125
|
+
buildRequest: ({ prelude, opts }) => check.buildRequest(prelude, opts),
|
|
126
|
+
run: async (fs, request) => check.run(fs, request),
|
|
127
|
+
presentHuman: ({ result }) => check.present(result),
|
|
128
|
+
formatJson: ({ result, prelude }) => check.formatJson(result, prelude.rootDir),
|
|
129
|
+
exitCode: check.exitCode,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
16
132
|
/**
|
|
17
133
|
* Top-level `audit` command — the source scans. Every one of them reports by default; only
|
|
18
134
|
* `comments --fix` writes, and only where the rewrite discards nothing a person wrote.
|
|
@@ -21,203 +137,10 @@ import { parseWithSchema } from "#/core/schema-parse";
|
|
|
21
137
|
*/
|
|
22
138
|
export function createAuditCommand() {
|
|
23
139
|
const cmd = new Command("audit").description("Source audits").enablePositionalOptions();
|
|
24
|
-
cmd
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.action(async (target, opts) => {
|
|
30
|
-
const prelude = await prepareRtlAudit(nodeFilesystem, {
|
|
31
|
-
currentWorkingDirectory: process.cwd(),
|
|
32
|
-
rawTarget: readOptionalPositionalArg(target),
|
|
33
|
-
});
|
|
34
|
-
if (!consumeCliAppError(prelude)) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const { rootDir, targetPath, allowlist } = prelude.value;
|
|
38
|
-
const parsed = parseWithSchema(rtlAuditRunRequestSchema, {
|
|
39
|
-
rootDir,
|
|
40
|
-
targetPath,
|
|
41
|
-
allowlist,
|
|
42
|
-
json: !!opts.json,
|
|
43
|
-
});
|
|
44
|
-
if (!consumeCliAppError(parsed)) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const outcome = runRtlAudit(nodeFilesystem, {
|
|
48
|
-
rootDir: parsed.value.rootDir,
|
|
49
|
-
targetPath: parsed.value.targetPath,
|
|
50
|
-
allowlist: parsed.value.allowlist ?? [],
|
|
51
|
-
});
|
|
52
|
-
if (!consumeCliAppError(outcome)) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (parsed.value.json) {
|
|
56
|
-
logger.out(formatRtlAuditJsonOutput(outcome.value, rootDir));
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
presentRtlAuditResult(outcome.value);
|
|
60
|
-
}
|
|
61
|
-
process.exitCode = exitCodeForRtlAuditResult(outcome.value);
|
|
62
|
-
});
|
|
63
|
-
cmd
|
|
64
|
-
.command("links")
|
|
65
|
-
.description("Report markdown links pointing at a missing path or an anchor the target does not offer")
|
|
66
|
-
.argument("[target]", "Directory or file to scan (default: the repo root)")
|
|
67
|
-
.option("--json", "Print one JSON summary on stdout", false)
|
|
68
|
-
.action(async (target, opts) => {
|
|
69
|
-
const prelude = await prepareLinkAudit(nodeFilesystem, {
|
|
70
|
-
currentWorkingDirectory: process.cwd(),
|
|
71
|
-
rawTarget: readOptionalPositionalArg(target),
|
|
72
|
-
});
|
|
73
|
-
if (!consumeCliAppError(prelude)) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const { rootDir, targetPath, allowlist } = prelude.value;
|
|
77
|
-
const parsed = parseWithSchema(linkAuditRunRequestSchema, {
|
|
78
|
-
rootDir,
|
|
79
|
-
targetPath,
|
|
80
|
-
allowlist,
|
|
81
|
-
json: !!opts.json,
|
|
82
|
-
});
|
|
83
|
-
if (!consumeCliAppError(parsed)) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const outcome = runLinkAudit(nodeFilesystem, {
|
|
87
|
-
rootDir: parsed.value.rootDir,
|
|
88
|
-
targetPath: parsed.value.targetPath,
|
|
89
|
-
allowlist: parsed.value.allowlist ?? [],
|
|
90
|
-
});
|
|
91
|
-
if (!consumeCliAppError(outcome)) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (parsed.value.json) {
|
|
95
|
-
logger.out(formatLinkAuditJsonOutput(outcome.value, rootDir));
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
presentLinkAuditResult(outcome.value);
|
|
99
|
-
}
|
|
100
|
-
process.exitCode = exitCodeForLinkAuditResult(outcome.value);
|
|
101
|
-
});
|
|
102
|
-
cmd
|
|
103
|
-
.command("react")
|
|
104
|
-
.description("Report React namespace/default imports and implicit React.* UMD-global type references")
|
|
105
|
-
.argument("[target]", "Directory or file to scan (default: the repo root)")
|
|
106
|
-
.option("--json", "Print one JSON summary on stdout", false)
|
|
107
|
-
.action(async (target, opts) => {
|
|
108
|
-
const prelude = await prepareReactAudit(nodeFilesystem, {
|
|
109
|
-
currentWorkingDirectory: process.cwd(),
|
|
110
|
-
rawTarget: readOptionalPositionalArg(target),
|
|
111
|
-
});
|
|
112
|
-
if (!consumeCliAppError(prelude)) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const { rootDir, targetPath, allowlist } = prelude.value;
|
|
116
|
-
const parsed = parseWithSchema(reactAuditRunRequestSchema, {
|
|
117
|
-
rootDir,
|
|
118
|
-
targetPath,
|
|
119
|
-
allowlist,
|
|
120
|
-
json: !!opts.json,
|
|
121
|
-
});
|
|
122
|
-
if (!consumeCliAppError(parsed)) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const outcome = runReactAudit(nodeFilesystem, {
|
|
126
|
-
rootDir: parsed.value.rootDir,
|
|
127
|
-
targetPath: parsed.value.targetPath,
|
|
128
|
-
allowlist: parsed.value.allowlist ?? [],
|
|
129
|
-
});
|
|
130
|
-
if (!consumeCliAppError(outcome)) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (parsed.value.json) {
|
|
134
|
-
logger.out(formatReactAuditJsonOutput(outcome.value, rootDir));
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
presentReactAuditResult(outcome.value);
|
|
138
|
-
}
|
|
139
|
-
process.exitCode = exitCodeForReactAuditResult(outcome.value);
|
|
140
|
-
});
|
|
141
|
-
cmd
|
|
142
|
-
.command("display-names")
|
|
143
|
-
.description("Report token(), tag() and module display names that break the <namespace>:<Name> convention")
|
|
144
|
-
.argument("[target]", "Directory or file to scan (default: the repo root)")
|
|
145
|
-
.option("--json", "Print one JSON summary on stdout", false)
|
|
146
|
-
.action(async (target, opts) => {
|
|
147
|
-
const prelude = await prepareDisplayNameAudit(nodeFilesystem, {
|
|
148
|
-
currentWorkingDirectory: process.cwd(),
|
|
149
|
-
rawTarget: readOptionalPositionalArg(target),
|
|
150
|
-
});
|
|
151
|
-
if (!consumeCliAppError(prelude)) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const { rootDir, targetPath, allowlist } = prelude.value;
|
|
155
|
-
const parsed = parseWithSchema(displayNameAuditRunRequestSchema, {
|
|
156
|
-
rootDir,
|
|
157
|
-
targetPath,
|
|
158
|
-
allowlist,
|
|
159
|
-
json: !!opts.json,
|
|
160
|
-
});
|
|
161
|
-
if (!consumeCliAppError(parsed)) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const outcome = runDisplayNameAudit(nodeFilesystem, {
|
|
165
|
-
rootDir: parsed.value.rootDir,
|
|
166
|
-
targetPath: parsed.value.targetPath,
|
|
167
|
-
allowlist: parsed.value.allowlist ?? [],
|
|
168
|
-
});
|
|
169
|
-
if (!consumeCliAppError(outcome)) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
if (parsed.value.json) {
|
|
173
|
-
logger.out(formatDisplayNameAuditJsonOutput(outcome.value, rootDir));
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
presentDisplayNameAuditResult(outcome.value);
|
|
177
|
-
}
|
|
178
|
-
process.exitCode = exitCodeForDisplayNameAuditResult(outcome.value);
|
|
179
|
-
});
|
|
180
|
-
cmd
|
|
181
|
-
.command("comments")
|
|
182
|
-
.description("Report section dividers that are not in the repo's one allowed form")
|
|
183
|
-
.argument("[target]", "Directory or file to scan (default: the repo root)")
|
|
184
|
-
.option("--fix", "Rewrite every mechanically fixable divider in place", false)
|
|
185
|
-
.option("--json", "Print one JSON summary on stdout", false)
|
|
186
|
-
.action(async (target, opts) => {
|
|
187
|
-
const prelude = await prepareCommentAudit(nodeFilesystem, {
|
|
188
|
-
currentWorkingDirectory: process.cwd(),
|
|
189
|
-
rawTarget: readOptionalPositionalArg(target),
|
|
190
|
-
});
|
|
191
|
-
if (!consumeCliAppError(prelude)) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
const { rootDir, targetPath, allowlist } = prelude.value;
|
|
195
|
-
const parsed = parseWithSchema(commentAuditRunRequestSchema, {
|
|
196
|
-
rootDir,
|
|
197
|
-
targetPath,
|
|
198
|
-
allowlist,
|
|
199
|
-
fix: !!opts.fix,
|
|
200
|
-
json: !!opts.json,
|
|
201
|
-
});
|
|
202
|
-
if (!consumeCliAppError(parsed)) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
const outcome = runCommentAudit(nodeFilesystem, {
|
|
206
|
-
rootDir: parsed.value.rootDir,
|
|
207
|
-
targetPath: parsed.value.targetPath,
|
|
208
|
-
allowlist: parsed.value.allowlist ?? [],
|
|
209
|
-
fix: parsed.value.fix,
|
|
210
|
-
});
|
|
211
|
-
if (!consumeCliAppError(outcome)) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
if (parsed.value.json) {
|
|
215
|
-
logger.out(formatCommentAuditJsonOutput(outcome.value, rootDir));
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
presentCommentAuditResult(outcome.value);
|
|
219
|
-
}
|
|
220
|
-
process.exitCode = exitCodeForCommentAuditResult(outcome.value);
|
|
221
|
-
});
|
|
140
|
+
registerPipelineSubcommand(cmd, nodeFilesystem, auditCheckToPipeline(rtlCheck));
|
|
141
|
+
registerPipelineSubcommand(cmd, nodeFilesystem, auditCheckToPipeline(linksCheck));
|
|
142
|
+
registerPipelineSubcommand(cmd, nodeFilesystem, auditCheckToPipeline(importsCheck));
|
|
143
|
+
registerPipelineSubcommand(cmd, nodeFilesystem, auditCheckToPipeline(displayNamesCheck));
|
|
144
|
+
registerPipelineSubcommand(cmd, nodeFilesystem, auditCheckToPipeline(commentsCheck));
|
|
222
145
|
return cmd;
|
|
223
146
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CommentAuditResult } from "#/audit/domain/types";
|
|
2
|
+
/**
|
|
3
|
+
* Exit `1` when any non-allowlisted divider still breaks the convention.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.6.0
|
|
6
|
+
*/
|
|
7
|
+
export declare function exitCodeForCommentAuditResult(result: CommentAuditResult): number;
|
|
8
|
+
/**
|
|
9
|
+
* Machine-readable comment-divider summary for `--json`.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.6.0
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatCommentAuditJsonOutput(result: CommentAuditResult, rootDir: string): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CLI_EXIT_GENERAL_ERROR, CLI_EXIT_SUCCESS } from "#/core/exit-codes";
|
|
2
|
+
/**
|
|
3
|
+
* Exit `1` when any non-allowlisted divider still breaks the convention.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.6.0
|
|
6
|
+
*/
|
|
7
|
+
export function exitCodeForCommentAuditResult(result) {
|
|
8
|
+
return result.breakageCount > 0 ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Machine-readable comment-divider summary for `--json`.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.6.0
|
|
14
|
+
*/
|
|
15
|
+
export function formatCommentAuditJsonOutput(result, rootDir) {
|
|
16
|
+
return JSON.stringify({
|
|
17
|
+
schemaVersion: 1,
|
|
18
|
+
ok: result.breakageCount === 0,
|
|
19
|
+
cwd: rootDir,
|
|
20
|
+
result,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Resolved request for a single comment-divider audit run.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.6.0
|
|
6
|
+
*/
|
|
7
|
+
export type CommentAuditRunRequest = {
|
|
8
|
+
readonly rootDir: string;
|
|
9
|
+
readonly targetPath: string;
|
|
10
|
+
readonly allowlist?: ReadonlyArray<string> | undefined;
|
|
11
|
+
readonly fix: boolean;
|
|
12
|
+
readonly json: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Zod schema for {@link CommentAuditRunRequest}.
|
|
16
|
+
*
|
|
17
|
+
* @since 0.6.0
|
|
18
|
+
*/
|
|
19
|
+
export declare const commentAuditRunRequestSchema: z.ZodType<CommentAuditRunRequest>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for {@link CommentAuditRunRequest}.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.6.0
|
|
6
|
+
*/
|
|
7
|
+
export const commentAuditRunRequestSchema = z.object({
|
|
8
|
+
rootDir: z.string().min(1),
|
|
9
|
+
targetPath: z.string().min(1),
|
|
10
|
+
allowlist: z.array(z.string()).optional(),
|
|
11
|
+
fix: z.boolean(),
|
|
12
|
+
json: z.boolean(),
|
|
13
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recognises comment content the repo bans outright: repo-document pointers and JSDoc type syntax.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Why a comment's content fails the convention. None is mechanical — the writer restates the
|
|
6
|
+
* invariant, lets the type carry the type, or moves the tag.
|
|
7
|
+
*
|
|
8
|
+
* @since 0.6.0
|
|
9
|
+
*/
|
|
10
|
+
export type CommentContentDefectKind = "detached-doc" | "doc-pointer" | "jsdoc-type" | "param-coverage" | "param-hyphen" | "since-order" | "stacked-doc";
|
|
11
|
+
/**
|
|
12
|
+
* One banned fragment found inside a comment.
|
|
13
|
+
*
|
|
14
|
+
* @since 0.6.0
|
|
15
|
+
*/
|
|
16
|
+
export interface CommentContentFinding {
|
|
17
|
+
readonly line: number;
|
|
18
|
+
readonly raw: string;
|
|
19
|
+
readonly defect: CommentContentDefectKind;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Scans a source file's comments for banned content, in source order.
|
|
23
|
+
*
|
|
24
|
+
* @since 0.6.0
|
|
25
|
+
*/
|
|
26
|
+
export declare function scanCommentContent(content: string, language: "css" | "js"): Array<CommentContentFinding>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recognises section dividers in source text and renders them in the one form the repo allows.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The column every divider's rule ends at — `oxfmt`'s `printWidth`, indentation included.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.6.0
|
|
8
|
+
*/
|
|
9
|
+
export declare const DIVIDER_COLUMN = 120;
|
|
10
|
+
/**
|
|
11
|
+
* Which comment syntax a divider is written in.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.6.0
|
|
14
|
+
*/
|
|
15
|
+
export type DividerLanguage = "css" | "ignore" | "js";
|
|
16
|
+
/**
|
|
17
|
+
* Why a divider fails the convention. Both kinds are mechanical, so every report is one `--fix` away.
|
|
18
|
+
*
|
|
19
|
+
* @since 0.6.0
|
|
20
|
+
*/
|
|
21
|
+
export type DividerDefectKind = "bad-width" | "legacy-form";
|
|
22
|
+
/**
|
|
23
|
+
* One divider found in a file, with the verdict on its form.
|
|
24
|
+
*
|
|
25
|
+
* @since 0.6.0
|
|
26
|
+
*/
|
|
27
|
+
export interface DividerRegion {
|
|
28
|
+
readonly startLine: number;
|
|
29
|
+
readonly endLine: number;
|
|
30
|
+
readonly indent: string;
|
|
31
|
+
readonly title: string;
|
|
32
|
+
readonly raw: string;
|
|
33
|
+
readonly defect: DividerDefectKind | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Renders a divider in the canonical form.
|
|
37
|
+
*
|
|
38
|
+
* @param indent - leading whitespace copied from the site, counted toward the column
|
|
39
|
+
* @param title - the section name, already trimmed
|
|
40
|
+
* @param language - which comment syntax to draw the divider in
|
|
41
|
+
*
|
|
42
|
+
* @since 0.6.0
|
|
43
|
+
*/
|
|
44
|
+
export declare function renderDivider(indent: string, title: string, language: DividerLanguage): string;
|
|
45
|
+
/**
|
|
46
|
+
* Every section divider in a file, canonical ones included, in source order.
|
|
47
|
+
*
|
|
48
|
+
* @remarks A rule-framed comment that carries prose is a doc block, not a divider, and never
|
|
49
|
+
* appears here — the two are different things and only one of them has a fixed form.
|
|
50
|
+
*
|
|
51
|
+
* @since 0.6.0
|
|
52
|
+
*/
|
|
53
|
+
export declare function scanCommentDividers(content: string, language: DividerLanguage): Array<DividerRegion>;
|
|
54
|
+
/**
|
|
55
|
+
* Rewrites every off-convention divider into the canonical form.
|
|
56
|
+
*
|
|
57
|
+
* @since 0.6.0
|
|
58
|
+
*/
|
|
59
|
+
export declare function applyCommentDividerFixes(content: string, language: DividerLanguage): {
|
|
60
|
+
readonly content: string;
|
|
61
|
+
readonly fixedCount: number;
|
|
62
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves `{@link}` references against the scanned tree, so a rename that orphans one is caught.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* One `{@link}` occurrence found inside a comment.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.6.0
|
|
8
|
+
*/
|
|
9
|
+
export interface LinkReference {
|
|
10
|
+
readonly line: number;
|
|
11
|
+
/** The target as written, e.g. `writeJsonlRun`, `Foo.bar`, `../fixtures/adapter.ts`. */
|
|
12
|
+
readonly target: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Every `{@link}` target in a file's comments, in source order.
|
|
16
|
+
*
|
|
17
|
+
* @since 0.6.0
|
|
18
|
+
*/
|
|
19
|
+
export declare function scanLinkReferences(content: string): Array<LinkReference>;
|
|
20
|
+
/**
|
|
21
|
+
* The identifier a declaration-style target must resolve through — `Foo.bar` resolves via `Foo`.
|
|
22
|
+
*
|
|
23
|
+
* @since 0.6.0
|
|
24
|
+
*/
|
|
25
|
+
export declare function linkTargetHead(target: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether a target names a file or URL rather than a declaration.
|
|
28
|
+
*
|
|
29
|
+
* @since 0.6.0
|
|
30
|
+
*/
|
|
31
|
+
export declare function isPathLinkTarget(target: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Counts word-boundary occurrences of each head across a body of source text.
|
|
34
|
+
*
|
|
35
|
+
* @remarks A `{@link X}` occurrence itself mentions `X` once, so a target is orphaned when its
|
|
36
|
+
* total mentions do not exceed its link occurrences — a rename removes every real mention.
|
|
37
|
+
*
|
|
38
|
+
* @since 0.6.0
|
|
39
|
+
*/
|
|
40
|
+
export declare function countHeadMentions(contents: Iterable<string>, heads: ReadonlySet<string>): Map<string, number>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flags `@since` tags naming a version the owning package has not reached.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* One impossible `@since` stamp found in a file's comments.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.8.0
|
|
8
|
+
*/
|
|
9
|
+
export interface SinceVersionFinding {
|
|
10
|
+
readonly line: number;
|
|
11
|
+
readonly raw: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Compares two SemVer strings by precedence — positive when `left` is greater,
|
|
15
|
+
* null when either side is not a SemVer version.
|
|
16
|
+
*
|
|
17
|
+
* @since 0.8.0
|
|
18
|
+
*/
|
|
19
|
+
export declare function compareVersionPrecedence(left: string, right: string): number | null;
|
|
20
|
+
/**
|
|
21
|
+
* Scans a file's comments for `@since` tags stamped above the package's current
|
|
22
|
+
* version — a release that has not happened, so the stamp cannot be true.
|
|
23
|
+
*
|
|
24
|
+
* @since 0.8.0
|
|
25
|
+
*/
|
|
26
|
+
export declare function scanImpossibleSinceTags(content: string, packageVersion: string): Array<SinceVersionFinding>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates every doc block against the official TSDoc grammar, not a regex approximation.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* One grammar diagnostic from the TSDoc parser.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.6.0
|
|
8
|
+
*/
|
|
9
|
+
export interface TsdocSyntaxFinding {
|
|
10
|
+
readonly line: number;
|
|
11
|
+
/** The parser's stable message id, e.g. `tsdoc-escape-right-brace` — the allowlist key. */
|
|
12
|
+
readonly raw: string;
|
|
13
|
+
readonly reason: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Every TSDoc grammar diagnostic in a file's doc blocks, in source order.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.6.0
|
|
19
|
+
*/
|
|
20
|
+
export declare function scanTsdocSyntax(content: string): Array<TsdocSyntaxFinding>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { logger } from "#/core/logger";
|
|
2
|
+
/**
|
|
3
|
+
* Human-readable comment-divider report.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.6.0
|
|
6
|
+
*/
|
|
7
|
+
export function presentCommentAuditResult(result) {
|
|
8
|
+
for (const file of result.files) {
|
|
9
|
+
logger.out(`\n${file.relativePath}`);
|
|
10
|
+
for (const { line, raw, reason } of file.breakages) {
|
|
11
|
+
logger.out(` ${line}: ${truncate(raw)} → ${reason}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const allowlistSuffix = result.allowlistedCount > 0 ? ` (${result.allowlistedCount} allowlisted)` : "";
|
|
15
|
+
if (result.fixedCount > 0) {
|
|
16
|
+
logger.out(`\n✎ Rewrote ${result.fixedCount} divider(s)`);
|
|
17
|
+
}
|
|
18
|
+
if (result.breakageCount > 0) {
|
|
19
|
+
logger.out(`\n✖ ${result.breakageCount} comment issue(s)${allowlistSuffix} — --fix rewrites divider forms`);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
logger.out(`✓ ${result.dividerCount} divider(s) across ${result.scannedFileCount} file(s), no banned comment content${allowlistSuffix}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function truncate(raw) {
|
|
26
|
+
return raw.length <= 60 ? raw : `${raw.slice(0, 57)}…`;
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AuditCommandPrelude } from "#/audit/prepare";
|
|
2
|
+
import type { AppError } from "#/core/errors";
|
|
3
|
+
import type { Filesystem } from "#/core/filesystem/filesystem";
|
|
4
|
+
import type { Result } from "#/core/result";
|
|
5
|
+
/**
|
|
6
|
+
* Loads config and resolves the scan target for `audit comments`.
|
|
7
|
+
*
|
|
8
|
+
* @remarks Defaults to the repo root: a divider convention that only holds inside one package
|
|
9
|
+
* is not a convention.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.6.0
|
|
12
|
+
*/
|
|
13
|
+
export declare function prepareCommentAudit(fs: Filesystem, args: {
|
|
14
|
+
readonly currentWorkingDirectory: string;
|
|
15
|
+
readonly rawTarget: string | undefined;
|
|
16
|
+
}): Promise<Result<AuditCommandPrelude, AppError>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { prepareRepoRootAudit } from "#/audit/prepare";
|
|
2
|
+
/**
|
|
3
|
+
* Loads config and resolves the scan target for `audit comments`.
|
|
4
|
+
*
|
|
5
|
+
* @remarks Defaults to the repo root: a divider convention that only holds inside one package
|
|
6
|
+
* is not a convention.
|
|
7
|
+
*
|
|
8
|
+
* @since 0.6.0
|
|
9
|
+
*/
|
|
10
|
+
export async function prepareCommentAudit(fs, args) {
|
|
11
|
+
return prepareRepoRootAudit(fs, args, (config) => config.audit?.comments?.allowlist ?? []);
|
|
12
|
+
}
|