@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.
@@ -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`), except `as const`
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 = (["x", "y", "width", "height"] as const).some(
127
+ const isBoxMoved = BOX_SIDES.some(
120
128
  (side) =>
121
129
  Math.abs(before[side] - after[side]) > BOX_TOLERANCE_PIXELS,
122
130
  );