@activatus/code-standards 3.2.1 → 3.3.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/docs/Guides/migrating.md +9 -4
- package/docs/Guides/regression-checks.md +1 -0
- package/docs/Guides/setup.md +22 -16
- package/docs/Standards/eslint.md +34 -3
- package/docs/Standards/readable-code.md +30 -1
- package/docs/Standards/working-with-agents.md +5 -1
- package/docs/Structure/folder-structure.md +102 -44
- package/docs/version-history.md +132 -29
- package/package.json +1 -1
- package/scripts/verifyStandards/checkAgentFiles.mjs +50 -8
- package/scripts/verifyStandards/checkConstants.mjs +10 -72
- package/scripts/verifyStandards/checkRecordedAnswers.mjs +5 -1
- package/scripts/verifyStandards/formatReport.mjs +3 -1
- package/scripts/verifyStandards/runChecks.mjs +4 -8
- package/static/templates/AGENTS.md +8 -5
- package/static/templates/docs/development/coding-standards.md +1 -1
- package/static/templates/eslint/nextjs/eslint.config.mjs +11 -0
- package/static/templates/eslint/react/eslint.config.mjs +10 -0
- package/static/templates/eslint/typescript/eslint.config.mjs +10 -0
- package/static/templates/skills/typescript.md +3 -1
- package/static/templates/tests/visual/pageLayout.visual.ts +9 -1
|
@@ -16,7 +16,7 @@ Every Activatus project follows the same standards, so people and agents can mov
|
|
|
16
16
|
|
|
17
17
|
[For each standard this project skips or changes, at setup or later: its number and name from the setup list, what is different, why, and the date the person agreed. For example: "7. Prettier — skipped: the project uses Biome for formatting (2026-10-23)." Every rule in `eslint.overrides.mjs` has an entry here. If nothing differs, write "No differences".]
|
|
18
18
|
|
|
19
|
-
- Working with the agent: GitHub repo [link or None]; Linear project [project or None]; status circles [yes or no]; ask before every commit and push [yes or no] ([YYYY-MM-DD]).
|
|
19
|
+
- Working with the agent: GitHub repo [link or None]; Linear project [project or None]; status circles [yes or no]; ask before every commit and push [yes or no]; told about decisions [yes or no] ([YYYY-MM-DD]).
|
|
20
20
|
|
|
21
21
|
## Components for the standards
|
|
22
22
|
|
|
@@ -56,6 +56,14 @@ const NO_SATISFIES = {
|
|
|
56
56
|
"Type a value where it is declared, not with satisfies afterwards.",
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
// Give a value a real type instead. consistent-type-assertions always
|
|
60
|
+
// lets `as const` through, so it is banned here.
|
|
61
|
+
const NO_AS_CONST = {
|
|
62
|
+
selector: "TSAsExpression[typeAnnotation.typeName.name='const']",
|
|
63
|
+
message:
|
|
64
|
+
"Give the value a real type where it is declared, not as const.",
|
|
65
|
+
};
|
|
66
|
+
|
|
59
67
|
const config = [
|
|
60
68
|
{
|
|
61
69
|
ignores: [
|
|
@@ -111,6 +119,7 @@ const config = [
|
|
|
111
119
|
"no-restricted-syntax": [
|
|
112
120
|
"error",
|
|
113
121
|
NO_SATISFIES,
|
|
122
|
+
NO_AS_CONST,
|
|
114
123
|
...RESTRICTED_SYNTAX,
|
|
115
124
|
...SINGLE_OBJECT_PARAMETER,
|
|
116
125
|
],
|
|
@@ -215,6 +224,7 @@ const config = [
|
|
|
215
224
|
rules: {
|
|
216
225
|
"no-restricted-syntax": [
|
|
217
226
|
"error",
|
|
227
|
+
NO_AS_CONST,
|
|
218
228
|
...RESTRICTED_SYNTAX,
|
|
219
229
|
...SINGLE_OBJECT_PARAMETER,
|
|
220
230
|
],
|
|
@@ -227,6 +237,7 @@ const config = [
|
|
|
227
237
|
"no-restricted-syntax": [
|
|
228
238
|
"error",
|
|
229
239
|
NO_SATISFIES,
|
|
240
|
+
NO_AS_CONST,
|
|
230
241
|
...RESTRICTED_SYNTAX,
|
|
231
242
|
],
|
|
232
243
|
},
|
|
@@ -57,6 +57,14 @@ const NO_SATISFIES = {
|
|
|
57
57
|
"Type a value where it is declared, not with satisfies afterwards.",
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
// Give a value a real type instead. consistent-type-assertions always
|
|
61
|
+
// lets `as const` through, so it is banned here.
|
|
62
|
+
const NO_AS_CONST = {
|
|
63
|
+
selector: "TSAsExpression[typeAnnotation.typeName.name='const']",
|
|
64
|
+
message:
|
|
65
|
+
"Give the value a real type where it is declared, not as const.",
|
|
66
|
+
};
|
|
67
|
+
|
|
60
68
|
const config = [
|
|
61
69
|
{
|
|
62
70
|
ignores: [
|
|
@@ -113,6 +121,7 @@ const config = [
|
|
|
113
121
|
"no-restricted-syntax": [
|
|
114
122
|
"error",
|
|
115
123
|
NO_SATISFIES,
|
|
124
|
+
NO_AS_CONST,
|
|
116
125
|
...RESTRICTED_SYNTAX,
|
|
117
126
|
...SINGLE_OBJECT_PARAMETER,
|
|
118
127
|
],
|
|
@@ -213,6 +222,7 @@ const config = [
|
|
|
213
222
|
rules: {
|
|
214
223
|
"no-restricted-syntax": [
|
|
215
224
|
"error",
|
|
225
|
+
NO_AS_CONST,
|
|
216
226
|
...RESTRICTED_SYNTAX,
|
|
217
227
|
...SINGLE_OBJECT_PARAMETER,
|
|
218
228
|
],
|
|
@@ -55,6 +55,14 @@ const NO_SATISFIES = {
|
|
|
55
55
|
"Type a value where it is declared, not with satisfies afterwards.",
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
// Give a value a real type instead. consistent-type-assertions always
|
|
59
|
+
// lets `as const` through, so it is banned here.
|
|
60
|
+
const NO_AS_CONST = {
|
|
61
|
+
selector: "TSAsExpression[typeAnnotation.typeName.name='const']",
|
|
62
|
+
message:
|
|
63
|
+
"Give the value a real type where it is declared, not as const.",
|
|
64
|
+
};
|
|
65
|
+
|
|
58
66
|
const config = [
|
|
59
67
|
{
|
|
60
68
|
ignores: [
|
|
@@ -102,6 +110,7 @@ const config = [
|
|
|
102
110
|
"no-restricted-syntax": [
|
|
103
111
|
"error",
|
|
104
112
|
NO_SATISFIES,
|
|
113
|
+
NO_AS_CONST,
|
|
105
114
|
...RESTRICTED_SYNTAX,
|
|
106
115
|
...SINGLE_OBJECT_PARAMETER,
|
|
107
116
|
],
|
|
@@ -193,6 +202,7 @@ const config = [
|
|
|
193
202
|
rules: {
|
|
194
203
|
"no-restricted-syntax": [
|
|
195
204
|
"error",
|
|
205
|
+
NO_AS_CONST,
|
|
196
206
|
...RESTRICTED_SYNTAX,
|
|
197
207
|
...SINGLE_OBJECT_PARAMETER,
|
|
198
208
|
],
|
|
@@ -11,11 +11,13 @@ Replace loose types with precise ones in the given files.
|
|
|
11
11
|
2. Find every loose type in scope:
|
|
12
12
|
- `any`, written or implied
|
|
13
13
|
- Non-null assertions (`value!`)
|
|
14
|
-
- Type casts (`value as SomeType`)
|
|
14
|
+
- Type casts (`value as SomeType`)
|
|
15
|
+
- `as const`
|
|
15
16
|
3. Fix each one:
|
|
16
17
|
- Replace `any` with the real type, or with `unknown` narrowed by a check
|
|
17
18
|
- Replace `value!` with a check that the value exists
|
|
18
19
|
- Replace a cast with validation or a properly typed source
|
|
20
|
+
- Replace `as const` with a real type where the value is declared, from `lib/types/` for a constant, putting any exact values in the type
|
|
19
21
|
4. Follow the naming rule for every type you add or rename: the name ends in `Props` (the object parameter of a component or function) or `Type` (everything else).
|
|
20
22
|
5. Run `pnpm typecheck`, then `pnpm lint`. Fix any errors your changes caused.
|
|
21
23
|
6. Report each change: the file, what the type was, and what it is now. List anything you could not tighten, and why.
|
|
@@ -28,6 +28,14 @@ type ElementMeasurementType = {
|
|
|
28
28
|
opacity: number;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
// The sides of a box that must not move.
|
|
32
|
+
const BOX_SIDES: readonly (keyof ElementMeasurementType)[] = [
|
|
33
|
+
"x",
|
|
34
|
+
"y",
|
|
35
|
+
"width",
|
|
36
|
+
"height",
|
|
37
|
+
];
|
|
38
|
+
|
|
31
39
|
type PageProps = { page: Page };
|
|
32
40
|
|
|
33
41
|
type ScrollStopType = {
|
|
@@ -116,7 +124,7 @@ const describeDifferences = ({
|
|
|
116
124
|
differences.push(`${key} is missing`);
|
|
117
125
|
continue;
|
|
118
126
|
}
|
|
119
|
-
const isBoxMoved =
|
|
127
|
+
const isBoxMoved = BOX_SIDES.some(
|
|
120
128
|
(side) =>
|
|
121
129
|
Math.abs(before[side] - after[side]) > BOX_TOLERANCE_PIXELS,
|
|
122
130
|
);
|