@avi2dg/checks 0.21.0 → 0.23.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 +66 -40
- package/CONTRIBUTING.md +14 -10
- package/README.md +15 -24
- package/bunfig.toml +1 -1
- package/dist/effect-channel/index.js +122 -0
- package/dist/{index.js → readability/index.js} +8 -120
- package/docs/configs/commit-messages.md +5 -1
- package/docs/configs/dependency-rules.md +5 -2
- package/docs/configs/effect-rules.md +32 -33
- package/docs/configs/native-settings.md +74 -0
- package/docs/configs/typescript-rules.md +4 -0
- package/docs/design.md +26 -27
- package/docs/gates/checks-backtest.md +4 -0
- package/docs/gates/checks-ci-wiring.md +30 -93
- package/docs/gates/checks-comment-gate.md +4 -0
- package/docs/gates/checks-commit-identity.md +23 -27
- package/docs/gates/checks-docs.md +23 -21
- package/docs/gates/checks-flake.md +4 -10
- package/docs/gates/checks-lint-coverage.md +5 -1
- package/docs/gates/checks-lint.md +22 -104
- package/docs/gates/checks-mutation-compare.md +4 -0
- package/docs/gates/checks-quarantine-clock.md +4 -0
- package/docs/gates/checks-repetition.md +27 -41
- package/docs/gates/checks-subsumed-tests.md +4 -0
- package/docs/gates/checks-suppressions-ratchet.md +4 -0
- package/docs/gates/checks-test-layout.md +16 -8
- package/docs/gates/checks-test.md +68 -36
- package/docs/gates/checks-vendor.md +20 -13
- package/oxlintrc.json +1 -1
- package/package.json +10 -21
- package/scripts/ci-wiring.ts +28 -97
- package/scripts/commit-identity.ts +32 -4
- package/scripts/doc-rules.ts +26 -11
- package/scripts/doc-templates.ts +2 -1
- package/scripts/docs.ts +4 -7
- package/scripts/gates.ts +0 -29
- package/scripts/git.ts +24 -1
- package/scripts/lint.ts +15 -34
- package/scripts/range-gate.ts +1 -2
- package/scripts/repetition.ts +51 -40
- package/scripts/shell-command.ts +7 -1
- package/scripts/swc.ts +46 -0
- package/scripts/test-layout.ts +40 -56
- package/scripts/test-skips.ts +180 -0
- package/scripts/test.ts +33 -38
- package/scripts/vendor.ts +55 -11
- package/dist/feature-rules.js +0 -354
- package/docs/configs/quality-file.md +0 -103
- package/docs/gates/checks-feature-owners.md +0 -113
- package/docs/gates/checks-quality.md +0 -111
- package/docs/gates/checks-size-budget.md +0 -107
- package/quality.schema.json +0 -514
- package/scripts/feature-owners.ts +0 -139
- package/scripts/quality-file.ts +0 -353
- package/scripts/quality.ts +0 -363
- package/scripts/size-budget.ts +0 -285
- package/scripts/size-rules.ts +0 -126
package/scripts/size-rules.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
|
|
3
|
-
export const TESTS_DIRECTORY = "tests";
|
|
4
|
-
|
|
5
|
-
const COUNTED = { skipBlankLines: false, skipComments: false };
|
|
6
|
-
|
|
7
|
-
const FILE_LINES = {
|
|
8
|
-
key: "fileLines",
|
|
9
|
-
rule: "max-lines",
|
|
10
|
-
options: COUNTED,
|
|
11
|
-
measured: /has too many lines \((\d+)\)/,
|
|
12
|
-
limits: "The most lines a file may hold, blank and comment lines counted",
|
|
13
|
-
} as const;
|
|
14
|
-
|
|
15
|
-
const FUNCTION_LINES = {
|
|
16
|
-
key: "functionLines",
|
|
17
|
-
rule: "max-lines-per-function",
|
|
18
|
-
options: COUNTED,
|
|
19
|
-
measured: /has too many lines \((\d+)\)/,
|
|
20
|
-
limits: "The most lines a function may span, blank and comment lines counted",
|
|
21
|
-
} as const;
|
|
22
|
-
|
|
23
|
-
const STATEMENTS = {
|
|
24
|
-
key: "statements",
|
|
25
|
-
rule: "max-statements",
|
|
26
|
-
options: {},
|
|
27
|
-
measured: /has too many statements \((\d+)\)/,
|
|
28
|
-
limits: "The most statements a function may hold",
|
|
29
|
-
} as const;
|
|
30
|
-
|
|
31
|
-
const COMPLEXITY = {
|
|
32
|
-
key: "complexity",
|
|
33
|
-
rule: "cognitive-complexity",
|
|
34
|
-
plugin: "effect-channel",
|
|
35
|
-
options: {},
|
|
36
|
-
measured: /has a cognitive complexity of (\d+)/,
|
|
37
|
-
limits: "The highest cognitive complexity a function may reach, a switch counted once",
|
|
38
|
-
} as const;
|
|
39
|
-
|
|
40
|
-
const DEPTH = {
|
|
41
|
-
key: "depth",
|
|
42
|
-
rule: "max-depth",
|
|
43
|
-
options: {},
|
|
44
|
-
measured: /nested too deeply \((\d+)\)/,
|
|
45
|
-
limits: "The deepest a block may nest inside a function",
|
|
46
|
-
} as const;
|
|
47
|
-
|
|
48
|
-
export const SIZE_RULES = [FILE_LINES, FUNCTION_LINES, STATEMENTS, COMPLEXITY, DEPTH] as const;
|
|
49
|
-
|
|
50
|
-
export type SizeRule = (typeof SIZE_RULES)[number];
|
|
51
|
-
export type LimitKey = SizeRule["key"];
|
|
52
|
-
|
|
53
|
-
export function qualifiedName(rule: SizeRule): string {
|
|
54
|
-
return "plugin" in rule ? `${rule.plugin}/${rule.rule}` : rule.rule;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function diagnosticCode(rule: SizeRule): string {
|
|
58
|
-
return "plugin" in rule ? `${rule.plugin}(${rule.rule})` : `eslint(${rule.rule})`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// An absent limit turns its rule off.
|
|
62
|
-
export type Budget = { readonly [K in LimitKey]?: number };
|
|
63
|
-
|
|
64
|
-
export type Budgets = { readonly production: Budget; readonly tests: Budget };
|
|
65
|
-
|
|
66
|
-
const APPLIES = ["ratchet", "all"] as const;
|
|
67
|
-
export type Applies = (typeof APPLIES)[number];
|
|
68
|
-
|
|
69
|
-
export const SIZE_DEFAULTS = {
|
|
70
|
-
applies: "ratchet",
|
|
71
|
-
production: { fileLines: 400, functionLines: 100, statements: 30, complexity: 15, depth: 4 },
|
|
72
|
-
tests: { fileLines: 600, statements: 50, complexity: 15, depth: 4 },
|
|
73
|
-
} as const satisfies Budgets & { readonly applies: Applies };
|
|
74
|
-
|
|
75
|
-
const Limit = Schema.Int.check(Schema.isGreaterThan(0));
|
|
76
|
-
|
|
77
|
-
function limit({ limits }: SizeRule, fallback: number) {
|
|
78
|
-
return Schema.optionalKey(Limit.annotate({ description: `${limits}; ${fallback} when absent` }));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const ProductionBudget = Schema.Struct({
|
|
82
|
-
fileLines: limit(FILE_LINES, SIZE_DEFAULTS.production.fileLines),
|
|
83
|
-
functionLines: limit(FUNCTION_LINES, SIZE_DEFAULTS.production.functionLines),
|
|
84
|
-
statements: limit(STATEMENTS, SIZE_DEFAULTS.production.statements),
|
|
85
|
-
complexity: limit(COMPLEXITY, SIZE_DEFAULTS.production.complexity),
|
|
86
|
-
depth: limit(DEPTH, SIZE_DEFAULTS.production.depth),
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const TestBudget = Schema.Struct({
|
|
90
|
-
fileLines: limit(FILE_LINES, SIZE_DEFAULTS.tests.fileLines),
|
|
91
|
-
statements: limit(STATEMENTS, SIZE_DEFAULTS.tests.statements),
|
|
92
|
-
complexity: limit(COMPLEXITY, SIZE_DEFAULTS.tests.complexity),
|
|
93
|
-
depth: limit(DEPTH, SIZE_DEFAULTS.tests.depth),
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
export const Size = Schema.Struct({
|
|
97
|
-
applies: Schema.optionalKey(
|
|
98
|
-
Schema.Literals(APPLIES).annotate({
|
|
99
|
-
description: `Which production and test files the budget holds: ratchet, the ones a range adds or changes, to no more overrun per rule than at the range's base; all, every one. ${SIZE_DEFAULTS.applies} when absent. The rest are listed as advisory`,
|
|
100
|
-
message: "Expected ratchet or all, and ratchet replaces changed",
|
|
101
|
-
}),
|
|
102
|
-
),
|
|
103
|
-
production: Schema.optionalKey(
|
|
104
|
-
ProductionBudget.annotate({
|
|
105
|
-
description: `The budget of the files under sources.production, and of the files listed as advisory outside ${TESTS_DIRECTORY}/`,
|
|
106
|
-
}),
|
|
107
|
-
),
|
|
108
|
-
tests: Schema.optionalKey(
|
|
109
|
-
TestBudget.annotate({ description: `The budget of the files under ${TESTS_DIRECTORY}/, which sets no limit on a function's lines` }),
|
|
110
|
-
),
|
|
111
|
-
}).annotate({
|
|
112
|
-
description: "The size budget oxlint holds production and test files to, read by checks-size-budget",
|
|
113
|
-
messageUnexpectedKey: "Expected only applies, production and tests, since each limit is set inside production or tests",
|
|
114
|
-
});
|
|
115
|
-
export type Size = typeof Size.Type;
|
|
116
|
-
|
|
117
|
-
export function budgetsOf(size: Size): Budgets {
|
|
118
|
-
return {
|
|
119
|
-
production: { ...SIZE_DEFAULTS.production, ...size.production },
|
|
120
|
-
tests: { ...SIZE_DEFAULTS.tests, ...size.tests },
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function budgetOf({ production, tests }: Budgets, file: string): Budget {
|
|
125
|
-
return file.startsWith(`${TESTS_DIRECTORY}/`) ? tests : production;
|
|
126
|
-
}
|