forked from ColumbusLabs/DebtLens
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.ts
More file actions
68 lines (65 loc) · 2.11 KB
/
Copy pathschema.ts
File metadata and controls
68 lines (65 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { severities } from "../core/severity.js";
import { detectorIds } from "../detectors/index.js";
import { defaultConfig } from "./defaults.js";
export const SCHEMA_ID =
"https://raw.githubusercontent.com/ColumbusLabs/debtlens/main/schema/debtlens.config.schema.json";
/**
* Build the JSON Schema for `debtlens.config.json`. Generated from the live rule list,
* severity set, and default threshold keys so it cannot drift from the code. A test
* asserts the committed schema file matches this output.
*/
export function buildConfigSchema(): Record<string, unknown> {
const knownThresholds = Object.fromEntries(
Object.keys(defaultConfig.thresholds).map((key) => [key, { type: "number" }]),
);
return {
$schema: "http://json-schema.org/draft-07/schema#",
$id: SCHEMA_ID,
title: "DebtLens configuration",
description: "Configuration for the DebtLens static-analysis CLI.",
type: "object",
additionalProperties: false,
properties: {
$schema: { type: "string" },
include: {
type: "array",
items: { type: "string" },
description: "Glob patterns to scan.",
},
exclude: {
type: "array",
items: { type: "string" },
description: "Glob patterns to skip.",
},
minSeverity: {
enum: [...severities],
description: "Lowest severity to report.",
},
rules: {
type: "array",
uniqueItems: true,
items: { enum: [...detectorIds] },
description: "Rule ids to run. Omit to run all rules.",
},
maxFiles: {
type: "integer",
minimum: 1,
description: "Maximum number of files to scan.",
},
thresholds: {
type: "object",
description: "Per-rule numeric threshold overrides.",
properties: knownThresholds,
additionalProperties: { type: "number" },
},
vocabulary: {
type: "object",
description: "Naming-drift concept groups (concept id -> competing terms).",
additionalProperties: {
type: "array",
items: { type: "string" },
},
},
},
};
}