@activatus/code-standards 3.1.1 → 3.2.1
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 +92 -60
- package/docs/Guides/regression-checks.md +72 -0
- package/docs/Guides/setup.md +53 -17
- package/docs/Standards/documentation.md +38 -1
- package/docs/Standards/eslint.md +15 -13
- package/docs/Standards/readable-code.md +2 -2
- package/docs/Structure/folder-structure.md +98 -6
- package/docs/templates.mdx +10 -2
- package/docs/version-history.md +54 -7
- package/package.json +6 -2
- package/scripts/verifyStandards/checkAgentFiles.mjs +148 -0
- package/scripts/verifyStandards/checkComponents.mjs +129 -0
- package/scripts/verifyStandards/checkConfigFiles.mjs +230 -0
- package/scripts/verifyStandards/checkConstants.mjs +127 -0
- package/scripts/verifyStandards/checkDocs.mjs +86 -0
- package/scripts/verifyStandards/checkRecordedAnswers.mjs +83 -0
- package/scripts/verifyStandards/checkRequiredFiles.mjs +67 -0
- package/scripts/verifyStandards/checkStructure.mjs +79 -0
- package/scripts/verifyStandards/formatReport.mjs +76 -0
- package/scripts/verifyStandards/projectFiles.mjs +109 -0
- package/scripts/verifyStandards/runChecks.mjs +68 -0
- package/scripts/verifyStandards/verifyStandards.mjs +22 -0
- package/static/templates/AGENTS.md +4 -4
- package/static/templates/docs/development/coding-standards.md +6 -0
- package/static/templates/docs/overview/writing-docs.md +4 -0
- package/static/templates/eslint/base/eslint.config.mjs +2 -2
- package/static/templates/eslint/nextjs/eslint.config.mjs +4 -3
- package/static/templates/eslint/react/eslint.config.mjs +4 -3
- package/static/templates/eslint/typescript/eslint.config.mjs +2 -2
- package/static/templates/tests/visual/pageLayout.visual.ts +188 -0
- package/static/templates/tests/visual/playwright.config.mjs +65 -0
- package/static/templates/tests/visual/visualPages.mjs +3 -0
|
@@ -71,7 +71,11 @@ project-root/
|
|
|
71
71
|
│ ├── constants/ # Constants shared across the app: see Constants below
|
|
72
72
|
│ │ ├── routes.ts # r: every link
|
|
73
73
|
│ │ ├── strings.ts # s: every piece of static text
|
|
74
|
+
│ │ ├── numbers.ts # Every loose named number
|
|
74
75
|
│ │ ├── noData.ts # Stand-in data for local development
|
|
76
|
+
│ │ ├── animation.ts # How things move, once there is any
|
|
77
|
+
│ │ ├── artwork.ts # What is drawn and where, once there is any
|
|
78
|
+
│ │ ├── classNames.ts # Class names shared between files, once there are any
|
|
75
79
|
│ │ └── index.ts
|
|
76
80
|
│ ├── errors/ # Error types and handlers shared across the app
|
|
77
81
|
│ └── types/ # Types shared across the app; a component's own types stay in its types.ts
|
|
@@ -295,19 +299,34 @@ Add the export to `utils/index.ts` whenever you add a function.
|
|
|
295
299
|
|
|
296
300
|
---
|
|
297
301
|
|
|
298
|
-
## 🔤 Constants: `r`, `s`, noData and
|
|
302
|
+
## 🔤 Constants: `r`, `s`, numbers, noData, animation, artwork and class names {#constants}
|
|
299
303
|
|
|
300
|
-
Every link, every piece of text on screen, every named number
|
|
304
|
+
Every link, every piece of text on screen, every named number, every piece of stand-in data, and every motion, drawing and shared class name lives in `lib/constants/`, never written straight into a component. **There is no component-level `constants.ts`**: even a value only one file uses goes here, so every piece of text is in one place when the site is translated into other languages, and every project finds its values in the same seven files.
|
|
301
305
|
|
|
302
306
|
```text
|
|
303
307
|
lib/constants/
|
|
304
308
|
├── routes.ts # r: every link
|
|
305
309
|
├── strings.ts # s: every piece of static text
|
|
306
|
-
├── numbers.ts # Every named number
|
|
310
|
+
├── numbers.ts # Every loose named number
|
|
307
311
|
├── noData.ts # Stand-in data, once the data's shape is decided
|
|
312
|
+
├── animation.ts # How things move, once there is any
|
|
313
|
+
├── artwork.ts # What is drawn and where, once there is any
|
|
314
|
+
├── classNames.ts # Class names shared between files, once there are any
|
|
308
315
|
└── index.ts # Exports all of them
|
|
309
316
|
```
|
|
310
317
|
|
|
318
|
+
**These seven files are the only ones.** Each is one file, never split by topic: no `durations.ts`, `motion.ts` or `layout.ts`. `routes.ts`, `strings.ts`, `numbers.ts` and `index.ts` exist from the start; the other four are created only once the project has something to put in them.
|
|
319
|
+
|
|
320
|
+
| A value that is… | Goes in |
|
|
321
|
+
| ----------------------------------------------------------- | ------------------- |
|
|
322
|
+
| A link | `r` in `routes.ts` |
|
|
323
|
+
| Text shown on screen | `s` in `strings.ts` |
|
|
324
|
+
| A single number with one job | `numbers.ts` |
|
|
325
|
+
| Fake data shaped like a real response | `noData.ts` |
|
|
326
|
+
| A group of values that together say how something moves | `animation.ts` |
|
|
327
|
+
| A group of values that together say what is drawn and where | `artwork.ts` |
|
|
328
|
+
| A Tailwind class string used by more than one file | `classNames.ts` |
|
|
329
|
+
|
|
311
330
|
A file outside the folder imports everything it needs in one line:
|
|
312
331
|
|
|
313
332
|
```tsx
|
|
@@ -378,7 +397,26 @@ export const r = {
|
|
|
378
397
|
<Link href={r.plans.team}>{s.plans.team.action}</Link>
|
|
379
398
|
```
|
|
380
399
|
|
|
381
|
-
**Write each key out by name
|
|
400
|
+
**Write each key out by name** when you mean one item: `r.plans.starter`, never `r.plans[planId]`. A reader can see exactly which words and which link each line uses.
|
|
401
|
+
|
|
402
|
+
**Inside a loop over the list, look each item up by its key.** A loop cannot name its items, so it reads `r` and `s` with the item's id, typed from `r` itself:
|
|
403
|
+
|
|
404
|
+
```ts title="lib/types/index.ts"
|
|
405
|
+
import type { r } from "@/lib/constants";
|
|
406
|
+
|
|
407
|
+
export type SourceIdType = keyof typeof r.sources;
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
```tsx title="app/(homepage)/components/sourceList/SourceList.tsx"
|
|
411
|
+
{sourceIds.map((sourceId) => (
|
|
412
|
+
<Link key={sourceId} href={r.sources[sourceId]}>
|
|
413
|
+
{s.sources[sourceId].title}
|
|
414
|
+
</Link>
|
|
415
|
+
))}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
- **The type comes from `r`**, so a missing or misspelt id fails the type check.
|
|
419
|
+
- **No separate lookup objects**, such as `SOURCE_ROUTES` or `PLAN_ROUTES` mapping an id to its link. `r.sources` already is that lookup: a second one is a copy that drifts out of step.
|
|
382
420
|
|
|
383
421
|
### noData: stand-in data for local development
|
|
384
422
|
|
|
@@ -416,18 +454,72 @@ const insights =
|
|
|
416
454
|
|
|
417
455
|
**A number other than `-1`, `0` or `1` gets a name**, such as `MAXIMUM_RETRY_ATTEMPTS`. Those three mean "nothing", "one more" and "not found", so they read clearly as they are. Any other number was chosen by someone, and its name says what it controls. ESLint checks this with `no-magic-numbers`.
|
|
418
456
|
|
|
419
|
-
**Every named number lives in `lib/constants/numbers.ts`**, even one that only one file uses, so every project finds its numbers in the same place. There is no `n` object: each number is its own `SCREAMING_SNAKE_CASE` export.
|
|
457
|
+
**Every loose named number lives in `lib/constants/numbers.ts`**, even one that only one file uses, so every project finds its numbers in the same place. There is no `n` object: each number is its own `SCREAMING_SNAKE_CASE` export.
|
|
420
458
|
|
|
421
459
|
```ts title="lib/constants/numbers.ts"
|
|
422
460
|
export const COOKIE_DURATION_DAYS = 30;
|
|
423
461
|
export const MAXIMUM_RETRY_ATTEMPTS = 3;
|
|
424
462
|
export const SESSION_TIMEOUT_MILLISECONDS = 900_000;
|
|
463
|
+
export const TOOLTIP_SIDE_OFFSET_PIXELS = 8;
|
|
425
464
|
```
|
|
426
465
|
|
|
427
466
|
- **One file, never split by topic.** `numbers.ts` can run past 300 lines, like `r` and `s`.
|
|
467
|
+
- **Loose numbers only.** A number that only means something beside other values, such as one swing in a choreography, stays inside its object in `animation.ts` or `artwork.ts`. It is never lifted out into `numbers.ts`.
|
|
428
468
|
- **Config files and scripts outside the app**, such as `eslint.config.mjs`, keep their numbers at the top of the file: they are not part of the app and do not import from it.
|
|
429
469
|
- **Put the unit in the name**: `_MILLISECONDS`, `_DAYS`, `_PIXELS`.
|
|
430
470
|
|
|
471
|
+
### Animation: how things move
|
|
472
|
+
|
|
473
|
+
**`animation.ts` holds every object that says how something moves**: motion and choreography (`*_MOTION`), entrances, scroll stops, drift, zoom, scroll pacing, and motion media queries.
|
|
474
|
+
|
|
475
|
+
```ts title="lib/constants/animation.ts"
|
|
476
|
+
export const CONFIDENCE_MOTION = {
|
|
477
|
+
pivot: "bearing-west",
|
|
478
|
+
ease: "easeInOut",
|
|
479
|
+
rounds: [
|
|
480
|
+
{ degrees: 12, seconds: 0.6 },
|
|
481
|
+
{ degrees: -8, seconds: 0.4 },
|
|
482
|
+
],
|
|
483
|
+
snapSeconds: 0.2,
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
export const REDUCED_MOTION_QUERY =
|
|
487
|
+
"(prefers-reduced-motion: reduce)";
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
- **Each object stays whole.** Its numbers, part names and eases only mean something together, so they stay in one object, named by their keys (`snapSeconds`). Never lift its numbers out into `numbers.ts`: `CONFIDENCE_ROUND_ONE_SWING_ONE_DEGREES` is harder to read, and splits one movement across files.
|
|
491
|
+
- **Part names and eases are not text on screen.** They are never shown or translated, so they stay in the object, not in `s`.
|
|
492
|
+
- **Put the unit in the key**: `seconds`, `degrees`, `snapSeconds`.
|
|
493
|
+
|
|
494
|
+
### Artwork: what is drawn and where
|
|
495
|
+
|
|
496
|
+
**`artwork.ts` holds every object that says what is drawn and where**: card layouts and pieces, backdrop tiles, canvas sizes, shape positions and image paths.
|
|
497
|
+
|
|
498
|
+
```ts title="lib/constants/artwork.ts"
|
|
499
|
+
export const HERO_CANVAS = { widthPixels: 1440, heightPixels: 900 };
|
|
500
|
+
|
|
501
|
+
export const BACKDROP_TILES = [
|
|
502
|
+
{ image: "/images/backdrop/tileOne.webp", x: 0, y: 0 },
|
|
503
|
+
{ image: "/images/backdrop/tileTwo.webp", x: 480, y: 0 },
|
|
504
|
+
];
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
- **Each object stays whole**, the same as in `animation.ts`.
|
|
508
|
+
- **An SVG drawing is a component or a file, never a string here.** Long SVG paths go in an `.svg` file in `public/` or in an icon component in `components/ui/`. `artwork.ts` says where a drawing goes, not what its path is.
|
|
509
|
+
|
|
510
|
+
### Class names shared between files
|
|
511
|
+
|
|
512
|
+
**`classNames.ts` holds a Tailwind class string that more than one file uses**, such as the face of a card that a card and its sub-components all draw.
|
|
513
|
+
|
|
514
|
+
```ts title="lib/constants/classNames.ts"
|
|
515
|
+
export const CARD_FACE_CLASS_NAME =
|
|
516
|
+
"rounded-2xl border border-border bg-card shadow-sm";
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
- **Make a component first.** A class string repeated across files usually means a component is missing, and the component is what makes the styling reusable. Use `classNames.ts` only when a component cannot hold the classes and they still repeat, such as when they go on different elements.
|
|
520
|
+
- **A class name used in one file stays inline in that file.**
|
|
521
|
+
- **Name each export after what it styles, ending in `_CLASS_NAME`.**
|
|
522
|
+
|
|
431
523
|
### Rules
|
|
432
524
|
|
|
433
525
|
- **Named exports only:** `export const r`, `export const s`. No default exports.
|
|
@@ -435,7 +527,7 @@ export const SESSION_TIMEOUT_MILLISECONDS = 900_000;
|
|
|
435
527
|
- **Files inside `lib/constants/` import each other directly**, `import { s } from "./strings";`, never through `index.ts`. See [Inside a folder, import files directly](/docs/Structure/import-organization#2-inside-a-folder-import-files-directly).
|
|
436
528
|
- **`r` and `s` are the only single-letter names allowed anywhere.** See [Human-Readable Names](/docs/Standards/human-readable-names#r-and-s).
|
|
437
529
|
- **Other constants**, such as numbers, are `SCREAMING_SNAKE_CASE`: see [Naming Conventions](/docs/Structure/naming-conventions#constants).
|
|
438
|
-
-
|
|
530
|
+
- **All seven files can run past 300 lines.** They are data only, so ESLint does not apply `max-lines` to them. Keep each one a single file: never split them to get under the limit.
|
|
439
531
|
- **`lib/constants/` never imports from `lib/types/`.** `lib/types/` reads some of its types from the constants (`typeof s`), so an import the other way makes a loop. When a constant needs a type, write the type beside the constant, or read it from the constant.
|
|
440
532
|
|
|
441
533
|
---
|
package/docs/templates.mdx
CHANGED
|
@@ -91,7 +91,7 @@ For TypeScript projects. Install commands are on the [ESLint page](/docs/Standar
|
|
|
91
91
|
|
|
92
92
|
**Copy to:** `eslint.config.mjs` in the project root
|
|
93
93
|
|
|
94
|
-
For React projects.
|
|
94
|
+
For React projects. Copy it unchanged. A project on a React version other than 19 sets `settings.react.version` in `eslint.overrides.mjs`: `{ settings: { react: { version: "19.2" } } }`.
|
|
95
95
|
|
|
96
96
|
<CodeBlock language="js" title="eslint.config.mjs">
|
|
97
97
|
{eslintReact}
|
|
@@ -103,7 +103,7 @@ For React projects. Set `settings.react.version` to the project's React version.
|
|
|
103
103
|
|
|
104
104
|
**Copy to:** `eslint.config.mjs` in the project root
|
|
105
105
|
|
|
106
|
-
For Next.js projects.
|
|
106
|
+
For Next.js projects. Copy it unchanged. A project on a React version other than 19 sets `settings.react.version` in `eslint.overrides.mjs`: `{ settings: { react: { version: "19.2" } } }`.
|
|
107
107
|
|
|
108
108
|
<CodeBlock language="js" title="eslint.config.mjs">
|
|
109
109
|
{eslintNextjs}
|
|
@@ -356,6 +356,14 @@ Plain file: [`/templates/next.config.mjs`](pathname:///templates/next.config.mjs
|
|
|
356
356
|
|
|
357
357
|
---
|
|
358
358
|
|
|
359
|
+
## Regression check {#visual}
|
|
360
|
+
|
|
361
|
+
**Copy to:** `tests/visual/` in the project root
|
|
362
|
+
|
|
363
|
+
Optional. Proves a large refactor changed nothing visible. Copy the whole [`static/templates/tests/visual/`](https://github.com/activatus-life/code-standards/tree/main/static/templates/tests/visual) folder. See [Regression Checks for Refactors](/docs/Guides/regression-checks).
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
359
367
|
## Document templates {#document-templates}
|
|
360
368
|
|
|
361
369
|
**Copy to:** the `docs/` folder in the project root, keeping the folder layout
|
package/docs/version-history.md
CHANGED
|
@@ -24,9 +24,10 @@ sidebar_label: "Version History"
|
|
|
24
24
|
5. **Strike out what the standard now covers.** After the changes, re-read the project's list of opted-out and changed standards in `docs/development/coding-standards.md`. Take off the list any exception the new version has made part of the standard, and update any rule it records for an old shape of the standard. A differences list that still describes the old standard sends the next agent wrong.
|
|
25
25
|
6. **Run `pnpm lint`, `pnpm format:check`, `pnpm test` and the build** after each change. `format:check` checks every file git does not ignore; never narrow it to changed files.
|
|
26
26
|
7. **Ask any [Working with the agent](/docs/Guides/setup#4-working-with-the-agent) question** whose answer is not recorded in `docs/development/coding-standards.md`, under "Details".
|
|
27
|
-
8. **
|
|
27
|
+
8. **Run `pnpm standards:check`**, and fix what it finds. See [Checking a project](/docs/Guides/setup#checking-a-project).
|
|
28
|
+
9. **Update the version number** in `AGENTS.md` once every change is done.
|
|
28
29
|
|
|
29
|
-
**A
|
|
30
|
+
**A fix or a minor version keeps the same version number.** When only the last number changes (a fix, such as 3.0.0 → 3.0.1) or the middle number changes (a minor version, such as 3.0.9 → 3.1.0), the project's version in `AGENTS.md` stays the same, but there may still be work to do. Update the package, then read that version's **Fixes** list and do anything it asks for the project's version. Check it every time the package is updated, even when the version number has not changed. A project already on the installed major version is never "nothing to do": follow [Already on this version](/docs/Guides/setup#already-on-this-version).
|
|
30
31
|
|
|
31
32
|
**When a change does not fit the project**, for example it renames a folder the project does not have, skip it. If you are not sure, ask; do not guess.
|
|
32
33
|
|
|
@@ -43,6 +44,7 @@ Anyone changing the standards adds a version, alongside the change:
|
|
|
43
44
|
- **Pilot a version in a real project before releasing it.** Once the work-in-progress version is written, have one real project apply it exactly as written, reading only what the page says. Every judgement call the agent has to make, and every instruction that does not fit the project, is a missing sentence: fold it back into the version before publishing. Release only when the pilot runs without the agent asking a question the page does not answer.
|
|
44
45
|
- **Fixing a released version** bumps only the last number: `3.0.0` → `3.0.1`. Update the version's changes in place, and list what was fixed under its **Fixes**. Projects keep the same version number in `AGENTS.md`. Write each fix so a project already on that version knows what to do.
|
|
45
46
|
- **Adding something optional** to a released version, such as a new setup question, bumps the middle number: `3.0.9` → `3.1.0`. It is written up the same way as a fix, and projects keep the same version number in `AGENTS.md`.
|
|
47
|
+
- **Changes that move files are listed under Structural changes.** At the top of the version's Fixes, list each change that moves or renames files in a project, with a rough size, such as "moves every component `constants.ts`", so a project can plan the work and run a [regression check](/docs/Guides/regression-checks) first. For now, structural changes ship in fix and minor versions; once the standards settle, they will wait for the next major version.
|
|
46
48
|
- **Every release commit is titled `docs: version N.N.N — <what changed>`**, such as `docs: version 3.0.9 — optional project links`, so releases are easy to find in the git log.
|
|
47
49
|
- **Every patch number is published.** Publish each patch to npm as soon as its Fixes are written. A Fixes entry for a version that was never published sends a project to install something that does not exist.
|
|
48
50
|
- **Judgement calls after release are fixes, not workarounds.** When a project's update needed a call the steps did not cover, add it under the version's Fixes so every other project gets it too. A project should never keep a private workaround for an unclear step.
|
|
@@ -51,12 +53,57 @@ Anyone changing the standards adds a version, alongside the change:
|
|
|
51
53
|
|
|
52
54
|
## Version 3
|
|
53
55
|
|
|
54
|
-
**Released:** 2026-10-17 · **Updates from:** version 2 · **Latest fix:** 3.
|
|
56
|
+
**Released:** 2026-10-17 · **Updates from:** version 2 · **Latest fix:** 3.2.1
|
|
55
57
|
|
|
56
58
|
Install it with `pnpm add -D @activatus/code-standards@latest`. Do change 1 first: it says which parts of the project's `AGENTS.md` are now the project's own to write.
|
|
57
59
|
|
|
60
|
+
**Fixes in 3.2.1.** If the project already applied 3.2.0, check these:
|
|
61
|
+
|
|
62
|
+
**Structural changes in 3.2.1.** These move files. Plan them, and run a [regression check](/docs/Guides/regression-checks) first:
|
|
63
|
+
|
|
64
|
+
- Every component `constants.ts` and every topic file in `lib/constants/` (`motion.ts`, `durations.ts`, `cardRail.ts`) moves into the seven standard files. Large on a site with many components: the Activatus homepage has 36 component files and 3 topic files. `pnpm standards:check` names the file each export goes to.
|
|
65
|
+
- Sub-component folders inside a grouping folder, such as `lifeActivated/outcomeArtwork/alignmentArtwork/`, move flat into the parent's `components/` folder. Small: the 3.1.1 step already moved most of them.
|
|
66
|
+
|
|
67
|
+
- **`lib/constants/` has seven standard files:** `routes.ts`, `strings.ts`, `numbers.ts`, `noData.ts`, and three new ones, created only once there is something to put in them:
|
|
68
|
+
- **`animation.ts`**: how things move. Motion and choreography objects (`*_MOTION`), entrances, scroll stops, drift, zoom, scroll pacing and motion media queries.
|
|
69
|
+
- **`artwork.ts`**: what is drawn and where. Layouts, card pieces, backdrop tiles, canvas sizes and image paths. Long SVG paths go in an `.svg` file in `public/` or an icon component, never here.
|
|
70
|
+
- **`classNames.ts`**: Tailwind class strings shared between files, only when a component cannot hold them and they still repeat. A class name one file uses stays inline.
|
|
71
|
+
|
|
72
|
+
Each animation and artwork object stays whole, its numbers named by their keys (`snapSeconds`). Never lift them out into `numbers.ts`, which keeps loose single numbers only. Lifting them out made names like `CONFIDENCE_ROUND_ONE_SWING_ONE_DEGREES` and split one movement across files; the reasons for one numbers file (translation, one place to look) do not apply to motion and drawing data. Each file is one file, never split by topic. See [Constants](/docs/Structure/folder-structure#constants).
|
|
73
|
+
|
|
74
|
+
**What to do:** move every component `constants.ts`, and every other file in `lib/constants/`, into the seven files. A topic file such as `motion.ts` is folded into `animation.ts`. Run `pnpm standards:check`: each finding names the file each export most likely belongs in; check each against the [Constants table](/docs/Structure/folder-structure#constants). In `eslint.config.mjs`, copy the template over it again: the `max-lines` block now reads `lib/constants/{routes,strings,numbers,noData,animation,artwork,classNames}.ts`. Copy the Constants rules into `AGENTS.md` from the template.
|
|
75
|
+
|
|
76
|
+
- **A loop over a list looks each item up by its id.** Write a key out by name when you mean one item, `r.plans.starter`. Inside a loop over the list, use the item's id, typed from `r`: `keyof typeof r.sources`. Delete separate lookup objects that map an id to its link, such as `SOURCE_ROUTES` or `PLAN_ROUTES`: `r` already is that lookup. See [A list of items with links](/docs/Structure/folder-structure#a-list-of-items-with-links).
|
|
77
|
+
|
|
78
|
+
- **`pnpm standards:check` checks more of the How to check lists:** sub-components sit flat in their root component's `components/` folder; the homepage is in `app/(homepage)/`; `docs/development/coding-standards.md` records the four agent answers under "Details"; `docs/design/design-system.md` has a filled-in Colour palette table; and `lib/constants/` holds only the seven standard files. Fix what it finds.
|
|
79
|
+
|
|
80
|
+
- **Keep every docs folder.** 3.2.0's rule is final: no docs folder is deleted, even one that does not apply yet.
|
|
81
|
+
|
|
82
|
+
**How to check:** `pnpm standards:check` passes, or lists only recorded exceptions; `lib/constants/` holds only the seven standard files and `index.ts`; no component has its own `constants.ts`.
|
|
83
|
+
|
|
84
|
+
**Fixes in 3.2.0.** If the project already applied 3.1.1, check these:
|
|
85
|
+
|
|
86
|
+
**Structural changes in 3.2.0.** Only one: restore any docs folder deleted under 3.1.1, from the templates. Small.
|
|
87
|
+
|
|
88
|
+
- **A standards check ships with the package.** Add the script `"standards:check": "node node_modules/@activatus/code-standards/scripts/verifyStandards/verifyStandards.mjs"` to `package.json`, run `pnpm standards:check`, and fix what it finds. It follows the exceptions recorded in `docs/development/coding-standards.md`. See [Checking a project](/docs/Guides/setup#checking-a-project). Copy the Code standards section of `AGENTS.md` from the template again: it now says to run the check.
|
|
89
|
+
- **Keep every docs folder and file**, even ones that do not apply yet. 3.1.1 allowed deleting a folder that could not apply; that is withdrawn, because the folders keep every project's docs laid out the same and a small project grows into them. Restore any folder deleted under 3.1.1 from the templates, and remove its entry from `coding-standards.md`.
|
|
90
|
+
- **The React version lives in `eslint.overrides.mjs`.** A project on a React version other than 19 sets `{ settings: { react: { version: "19.2" } } }` there, and copies the template over `eslint.config.mjs` unchanged.
|
|
91
|
+
- **The `writing-docs.md` and `coding-standards.md` templates gained a `## Why` section.** Add one to each if the project's copies have none.
|
|
92
|
+
- **New, optional: the [Migrating guide](/docs/Guides/migrating) has new stages**, among them a regression check (Stage 0), constants (Stage 4), components (Stage 5) and docs (Stage 6), and the docs standard has [Converting existing docs](/docs/Standards/documentation#-converting-existing-docs). Nothing to do for a project already on version 3.
|
|
93
|
+
- **New, optional: [Regression Checks for Refactors](/docs/Guides/regression-checks)**, a Playwright check that proves a refactor changed nothing visible. Nothing to do unless the project wants it.
|
|
94
|
+
|
|
95
|
+
**How to check:** `pnpm standards:check` passes, or lists only recorded exceptions; every folder from the doc templates exists in `docs/`.
|
|
96
|
+
|
|
58
97
|
**Fixes in 3.1.1.** If the project already applied 3.1.0, check these:
|
|
59
98
|
|
|
99
|
+
**Structural changes in 3.1.1.** These move files. Plan them, and run a [regression check](/docs/Guides/regression-checks) first:
|
|
100
|
+
|
|
101
|
+
- The homepage moves into `app/(homepage)/`: `app/page.tsx` and the homepage's components. Small.
|
|
102
|
+
- The site frame moves into `components/layout/`: the navigation, header and footer. Small.
|
|
103
|
+
- Every component `constants.ts` moves into `lib/constants/`. Large on a site with many components: the Activatus homepage had 36. Follow the 3.2.1 rule, not this version's.
|
|
104
|
+
- Every nested sub-component folder moves flat into its parent's `components/` folder. Medium to large: the Activatus homepage had 28.
|
|
105
|
+
- `r` or `s` split into several files only to stay under 300 lines goes back into one file. Small.
|
|
106
|
+
|
|
60
107
|
- **`routes.ts`, `strings.ts`, `numbers.ts` and `noData.ts` can run past 300 lines.** They hold data only, so `max-lines` no longer applies to them. Splitting `r` or `s` across files to stay under 300 lines only made labels harder to find. In `eslint.config.mjs`, add this block straight after the test-file block:
|
|
61
108
|
|
|
62
109
|
```js
|
|
@@ -81,8 +128,8 @@ Install it with `pnpm add -D @activatus/code-standards@latest`. Do change 1 firs
|
|
|
81
128
|
- **The site frame lives in `components/layout/`**: navigation, header, footer and anything else that frames the pages. It may read `r` and `s`. Move those components there from `components/shared/` or `app/components/`. Layout primitives such as Duplex stay in `components/ui/`.
|
|
82
129
|
- **A props-only component that is not on the Design System Components list stays in `components/ui/`.** Record it, with its props, in `docs/development/coding-standards.md`, under a new "Components for the standards" heading (copy it from the template), and tell the person. Move back into `components/ui/` any such component that was moved out only because it was not listed.
|
|
83
130
|
- **Four components joined the list:** Brand Logo, Notification Card, Scroll Cue and Dropdown Menu. If the project has them, check their props match the [list](/docs/design-system-components).
|
|
84
|
-
- **Every named number lives in `lib/constants/numbers.ts`**, even one only one file uses, in one file that is never split. Move numbers from the tops of app files and from any topic files (`durations.ts`, `limits.ts`) into it. Config files and scripts outside the app keep theirs at the top.
|
|
85
|
-
- **No component-level `constants.ts`.** Every link, piece of text and number goes in `lib/constants/`, even if one file uses it, so all the text is in one place for translation. Move any component's `constants.ts` into `r`, `s` and `numbers.ts`.
|
|
131
|
+
- **Every named number lives in `lib/constants/numbers.ts`**, even one only one file uses, in one file that is never split. Move numbers from the tops of app files and from any topic files (`durations.ts`, `limits.ts`) into it. _Changed in 3.2.1: motion and artwork objects stay whole in `animation.ts` and `artwork.ts`. Do the 3.2.1 step instead of moving their numbers here._ Config files and scripts outside the app keep theirs at the top.
|
|
132
|
+
- **No component-level `constants.ts`.** Every link, piece of text and number goes in `lib/constants/`, even if one file uses it, so all the text is in one place for translation. Move any component's `constants.ts` into `r`, `s` and `numbers.ts`. _Changed in 3.2.1: there are seven constants files to move into. Do the 3.2.1 step instead._
|
|
86
133
|
- **Write `r` and `s` keys out by name**, `r.plans.starter`, never `r.plans[planId]`. A list of items keeps its words in `s` and its links in `r` under the same keys. See [A list of items with links](/docs/Structure/folder-structure#a-list-of-items-with-links).
|
|
87
134
|
- **No `"#"` placeholder links.** Show the text without a link and put `{/* TODO: … */}` above it until the page exists. Unfinished work is marked `// TODO: Message`.
|
|
88
135
|
- **`lib/constants/` never imports from `lib/types/`.** Move any type it imports from there beside the constant.
|
|
@@ -91,7 +138,7 @@ Install it with `pnpm add -D @activatus/code-standards@latest`. Do change 1 firs
|
|
|
91
138
|
- **The palette is listed in `docs/design/design-system.md`**: each colour's name, value, class names and use. `globals.css` holds only colours Tailwind does not have. Copy the Colour palette section from the template and fill it in.
|
|
92
139
|
- **AGENTS.md: the Code standards section sits between `<!-- code-standards:start -->` and `<!-- code-standards:end -->`**, and an update replaces everything between them. Copy the section from the template, markers included. Move any project exception written into it into `docs/development/coding-standards.md`, and anything else the project added, such as a framework's block, outside the markers.
|
|
93
140
|
- **Docs:** copy the new `docs/product/ontology.md` template if the project has none, and ask the person to review it. Fix the link in `overview/writing-docs.md` if `what-is-it.md` was renamed. Retitle `how-it-works.md` "Overview — How It Works". Delete any version 2 leftovers: `_category_.json`, the `sidebar_position`, `sidebar_label`, `slug`, `status` and `lastReviewed` front matter, and `docs/index.md`.
|
|
94
|
-
- **Decision Docs are confirmed with the person** before an agent creates, changes or deletes one, unless `AGENTS.md` names an agent that manages them. A folder that cannot apply may be deleted with the person's yes, recorded in `coding-standards.md
|
|
141
|
+
- **Decision Docs are confirmed with the person** before an agent creates, changes or deletes one, unless `AGENTS.md` names an agent that manages them. ~~A folder that cannot apply may be deleted with the person's yes, recorded in `coding-standards.md`.~~ _Withdrawn in 3.2.0: keep every folder._ Moving or reformatting a doc does not change its Updated date.
|
|
95
142
|
- **Stylelint configs name their export:** `const config = { … }; export default config;`. Change the project's `stylelint.config.mjs` to match.
|
|
96
143
|
- **The Linear ticket prefix is the team's, not the project's.** In `AGENTS.md`, Project workflow, write the Linear workspace, team and project, such as `activatus-life`, team `ACT`, project Launchpad.
|
|
97
144
|
|
|
@@ -468,7 +515,7 @@ See [When a name clashes](/docs/Standards/human-readable-names#when-a-name-clash
|
|
|
468
515
|
### No action needed
|
|
469
516
|
|
|
470
517
|
- The [Setup](/docs/Guides/setup) guide is written for the agent: install the package, check the version, agree the standards, apply them. It never asks which framework the project uses, and never creates the app: the person does that.
|
|
471
|
-
- The [migration guide](/docs/Guides/migrating#stage-
|
|
518
|
+
- The [migration guide](/docs/Guides/migrating#stage-3--names) has a Names stage.
|
|
472
519
|
|
|
473
520
|
---
|
|
474
521
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activatus/code-standards",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "The Activatus code standards: the rules as Markdown, and the config files to copy. Install it so an AI agent can read the standards from node_modules.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"docs",
|
|
12
12
|
"scripts/renameSymbol.mjs",
|
|
13
|
+
"scripts/verifyStandards/*.mjs",
|
|
14
|
+
"!scripts/verifyStandards/*.test.mjs",
|
|
15
|
+
"!scripts/verifyStandards/testProject.mjs",
|
|
13
16
|
"static/templates",
|
|
14
17
|
"README.md"
|
|
15
18
|
],
|
|
@@ -73,6 +76,7 @@
|
|
|
73
76
|
"typecheck": "tsc",
|
|
74
77
|
"format": "prettier --write .",
|
|
75
78
|
"format:check": "prettier --check .",
|
|
76
|
-
"check:eslint-templates": "node scripts/checkEslintTemplates.mjs"
|
|
79
|
+
"check:eslint-templates": "node scripts/checkEslintTemplates.mjs",
|
|
80
|
+
"test": "node --test \"scripts/verifyStandards/*.test.mjs\""
|
|
77
81
|
}
|
|
78
82
|
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Standard 21: AGENTS.md, its code standards section and version,
|
|
2
|
+
// and the agent skills.
|
|
3
|
+
import { readdirSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
import { readTextFile } from "./projectFiles.mjs";
|
|
7
|
+
|
|
8
|
+
const SECTION_START = "<!-- code-standards:start -->";
|
|
9
|
+
const SECTION_END = "<!-- code-standards:end -->";
|
|
10
|
+
const VERSION_LINE_START = "**Code standards version:**";
|
|
11
|
+
const VERSION_PATTERN = /\*\*Code standards version:\*\*\s*(\d+)/;
|
|
12
|
+
const SKILL_FOLDERS = [".agents/skills", ".claude/commands"];
|
|
13
|
+
const PAGE = "docs/Standards/agent-specs.md";
|
|
14
|
+
|
|
15
|
+
// The text between the markers, without the version line: the project
|
|
16
|
+
// fills that line in, and everything else is copied unchanged.
|
|
17
|
+
const readStandardsSection = (agentsText) => {
|
|
18
|
+
const startIndex = agentsText.indexOf(SECTION_START);
|
|
19
|
+
const endIndex = agentsText.indexOf(SECTION_END);
|
|
20
|
+
const hasMarkers = startIndex !== -1 && endIndex !== -1;
|
|
21
|
+
return hasMarkers
|
|
22
|
+
? agentsText
|
|
23
|
+
.slice(startIndex + SECTION_START.length, endIndex)
|
|
24
|
+
.replaceAll("\r\n", "\n")
|
|
25
|
+
.split("\n")
|
|
26
|
+
.filter((line) => !line.startsWith(VERSION_LINE_START))
|
|
27
|
+
.join("\n")
|
|
28
|
+
.trim()
|
|
29
|
+
: undefined;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const checkVersion = ({ agentsText, packageMajorVersion }) => {
|
|
33
|
+
const match = VERSION_PATTERN.exec(agentsText);
|
|
34
|
+
if (!match) {
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
standard: "21",
|
|
38
|
+
message:
|
|
39
|
+
"AGENTS.md has no code standards version. Set **Code standards version:** to the major version the code follows",
|
|
40
|
+
page: "docs/Guides/setup.md",
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
const projectVersion = Number(match[1]);
|
|
45
|
+
if (projectVersion < packageMajorVersion) {
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
standard: "21",
|
|
49
|
+
message: `AGENTS.md says version ${projectVersion}, and the installed package is version ${packageMajorVersion}. Follow "Updating to a newer version"`,
|
|
50
|
+
page: "docs/Guides/setup.md#updating-to-a-newer-version",
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
return [];
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const checkStandardsSection = ({
|
|
58
|
+
agentsText,
|
|
59
|
+
templatesDirectory,
|
|
60
|
+
}) => {
|
|
61
|
+
const projectSection = readStandardsSection(agentsText);
|
|
62
|
+
if (projectSection === undefined) {
|
|
63
|
+
return [
|
|
64
|
+
{
|
|
65
|
+
standard: "21",
|
|
66
|
+
message: `AGENTS.md has no ${SECTION_START} and ${SECTION_END} markers. Copy the Code standards section from the template, markers included`,
|
|
67
|
+
page: PAGE,
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
const templateSection = readStandardsSection(
|
|
72
|
+
readTextFile({
|
|
73
|
+
projectDirectory: templatesDirectory,
|
|
74
|
+
filePath: "AGENTS.md",
|
|
75
|
+
}) ?? "",
|
|
76
|
+
);
|
|
77
|
+
if (projectSection === templateSection) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
return [
|
|
81
|
+
{
|
|
82
|
+
standard: "21",
|
|
83
|
+
message:
|
|
84
|
+
"The Code standards section of AGENTS.md differs from the template. Copy it again, and record any project exception in docs/development/coding-standards.md instead",
|
|
85
|
+
page: PAGE,
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const checkSkills = ({ projectDirectory, templatesDirectory }) => {
|
|
91
|
+
const skillNames = readdirSync(
|
|
92
|
+
path.join(templatesDirectory, "skills"),
|
|
93
|
+
);
|
|
94
|
+
const findings = [];
|
|
95
|
+
for (const folder of SKILL_FOLDERS) {
|
|
96
|
+
for (const skillName of skillNames) {
|
|
97
|
+
const template = readTextFile({
|
|
98
|
+
projectDirectory: templatesDirectory,
|
|
99
|
+
filePath: path.join("skills", skillName),
|
|
100
|
+
});
|
|
101
|
+
const projectSkill = readTextFile({
|
|
102
|
+
projectDirectory,
|
|
103
|
+
filePath: path.join(folder, skillName),
|
|
104
|
+
});
|
|
105
|
+
if (projectSkill === undefined) {
|
|
106
|
+
findings.push({
|
|
107
|
+
standard: "21",
|
|
108
|
+
message: `${folder}/${skillName} is missing`,
|
|
109
|
+
page: "docs/Standards/agent-skills.md",
|
|
110
|
+
});
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (projectSkill.trimEnd() !== template?.trimEnd()) {
|
|
114
|
+
findings.push({
|
|
115
|
+
standard: "21",
|
|
116
|
+
message: `${folder}/${skillName} differs from the template`,
|
|
117
|
+
page: "docs/Standards/agent-skills.md",
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return findings;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const checkAgentFiles = ({
|
|
126
|
+
projectDirectory,
|
|
127
|
+
templatesDirectory,
|
|
128
|
+
packageMajorVersion,
|
|
129
|
+
}) => {
|
|
130
|
+
const agentsText = readTextFile({
|
|
131
|
+
projectDirectory,
|
|
132
|
+
filePath: "AGENTS.md",
|
|
133
|
+
});
|
|
134
|
+
if (agentsText === undefined) {
|
|
135
|
+
return [
|
|
136
|
+
{
|
|
137
|
+
standard: "21",
|
|
138
|
+
message: "AGENTS.md is missing. Follow Setup",
|
|
139
|
+
page: "docs/Guides/setup.md",
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
return [
|
|
144
|
+
...checkVersion({ agentsText, packageMajorVersion }),
|
|
145
|
+
...checkStandardsSection({ agentsText, templatesDirectory }),
|
|
146
|
+
...checkSkills({ projectDirectory, templatesDirectory }),
|
|
147
|
+
];
|
|
148
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// Standards 4 and 15: every function and component has a test file,
|
|
2
|
+
// and every components/ui/ component is on the Design System list.
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { readTextFile } from "./projectFiles.mjs";
|
|
6
|
+
|
|
7
|
+
const SOURCE_FOLDERS = [
|
|
8
|
+
"app/",
|
|
9
|
+
"components/",
|
|
10
|
+
"hooks/",
|
|
11
|
+
"lib/",
|
|
12
|
+
"services/",
|
|
13
|
+
"utils/",
|
|
14
|
+
];
|
|
15
|
+
const SOURCE_FILE_PATTERN = /\.(ts|tsx|js|jsx)$/;
|
|
16
|
+
// Files that hold no function or component of their own.
|
|
17
|
+
const NO_TEST_NEEDED_PATTERN =
|
|
18
|
+
/(\.test\.|\.stories\.|\.d\.ts$|\.config\.|\.types\.tsx?$|(^|\/)(index|types|constants)\.tsx?$)/;
|
|
19
|
+
// A file needs a test when it exports a function or a component.
|
|
20
|
+
// A file of data only, such as an illustration's points, does not.
|
|
21
|
+
const EXPORTS_FUNCTION_PATTERN =
|
|
22
|
+
/export\s+(default\s+)?(async\s+)?function\b|export\s+const\s+\w+\s*(:[^=]+)?=\s*(async\s+)?(\([^)]*\)|\w+)\s*(:[^=]+)?=>/;
|
|
23
|
+
const UI_FOLDER_PATTERN = /^components\/ui\/([^/]+)\//;
|
|
24
|
+
const LISTED_COMPONENT_PATTERN = /^\|\s*\d+\s*\|\s*\*\*(.+?)\*\*/;
|
|
25
|
+
|
|
26
|
+
// "Spacer / Divider" → ["spacerdivider", "spacer", "divider"]
|
|
27
|
+
const toComparableNames = (componentName) => {
|
|
28
|
+
const parts = componentName.split("/");
|
|
29
|
+
return [componentName, ...parts].map((name) =>
|
|
30
|
+
name.toLowerCase().replaceAll(/[^a-z0-9]/g, ""),
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const toComparableName = (folderName) =>
|
|
35
|
+
folderName.toLowerCase().replaceAll(/[^a-z0-9]/g, "");
|
|
36
|
+
|
|
37
|
+
const readListedComponents = ({ standardsDocsDirectory }) => {
|
|
38
|
+
const markdown =
|
|
39
|
+
readTextFile({
|
|
40
|
+
projectDirectory: standardsDocsDirectory,
|
|
41
|
+
filePath: "design-system-components.md",
|
|
42
|
+
}) ?? "";
|
|
43
|
+
return new Set(
|
|
44
|
+
markdown
|
|
45
|
+
.split("\n")
|
|
46
|
+
.map((line) => LISTED_COMPONENT_PATTERN.exec(line)?.[1])
|
|
47
|
+
.filter(Boolean)
|
|
48
|
+
.flatMap((componentName) => toComparableNames(componentName)),
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const checkUiComponents = ({
|
|
53
|
+
projectFiles,
|
|
54
|
+
standardsDocsDirectory,
|
|
55
|
+
recordedExceptions,
|
|
56
|
+
}) => {
|
|
57
|
+
const listedComponents = readListedComponents({
|
|
58
|
+
standardsDocsDirectory,
|
|
59
|
+
});
|
|
60
|
+
const recordedComponents = toComparableName(
|
|
61
|
+
recordedExceptions.componentsText,
|
|
62
|
+
);
|
|
63
|
+
const uiFolders = new Set(
|
|
64
|
+
projectFiles
|
|
65
|
+
.map((filePath) => UI_FOLDER_PATTERN.exec(filePath)?.[1])
|
|
66
|
+
.filter(Boolean),
|
|
67
|
+
);
|
|
68
|
+
return [...uiFolders]
|
|
69
|
+
.filter(
|
|
70
|
+
(folder) =>
|
|
71
|
+
!listedComponents.has(toComparableName(folder)) &&
|
|
72
|
+
!recordedComponents.includes(toComparableName(folder)),
|
|
73
|
+
)
|
|
74
|
+
.map((folder) => ({
|
|
75
|
+
standard: "15",
|
|
76
|
+
message: `components/ui/${folder} is not on the Design System Components list. If it takes everything through props, record it under "Components for the standards" in docs/development/coding-standards.md; otherwise move it out of components/ui/`,
|
|
77
|
+
page: "docs/design-system-components.md",
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const isSourceFile = (filePath) =>
|
|
82
|
+
SOURCE_FOLDERS.some((folder) => filePath.startsWith(folder)) &&
|
|
83
|
+
SOURCE_FILE_PATTERN.test(filePath) &&
|
|
84
|
+
!NO_TEST_NEEDED_PATTERN.test(filePath) &&
|
|
85
|
+
!filePath.startsWith("lib/constants/") &&
|
|
86
|
+
!filePath.startsWith("lib/types/");
|
|
87
|
+
|
|
88
|
+
const findTestFile = ({ filePath, projectFileSet }) => {
|
|
89
|
+
const { dir, name } = path.posix.parse(filePath);
|
|
90
|
+
return [".ts", ".tsx", ".js", ".jsx"].some((extension) =>
|
|
91
|
+
projectFileSet.has(
|
|
92
|
+
path.posix.join(dir, `${name}.test${extension}`),
|
|
93
|
+
),
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const doesExportFunction = ({ projectDirectory, filePath }) =>
|
|
98
|
+
EXPORTS_FUNCTION_PATTERN.test(
|
|
99
|
+
readTextFile({ projectDirectory, filePath }) ?? "",
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const checkTestFiles = ({ projectDirectory, projectFiles }) => {
|
|
103
|
+
const projectFileSet = new Set(projectFiles);
|
|
104
|
+
return projectFiles
|
|
105
|
+
.filter((filePath) => isSourceFile(filePath))
|
|
106
|
+
.filter((filePath) =>
|
|
107
|
+
doesExportFunction({ projectDirectory, filePath }),
|
|
108
|
+
)
|
|
109
|
+
.filter((filePath) => !findTestFile({ filePath, projectFileSet }))
|
|
110
|
+
.map((filePath) => ({
|
|
111
|
+
standard: "4",
|
|
112
|
+
message: `${filePath} has no test file beside it`,
|
|
113
|
+
page: "docs/Standards/readable-code.md#every-function-and-component-has-a-test-file",
|
|
114
|
+
}));
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const checkComponents = ({
|
|
118
|
+
projectDirectory,
|
|
119
|
+
projectFiles,
|
|
120
|
+
standardsDocsDirectory,
|
|
121
|
+
recordedExceptions,
|
|
122
|
+
}) => [
|
|
123
|
+
...checkUiComponents({
|
|
124
|
+
projectFiles,
|
|
125
|
+
standardsDocsDirectory,
|
|
126
|
+
recordedExceptions,
|
|
127
|
+
}),
|
|
128
|
+
...checkTestFiles({ projectDirectory, projectFiles }),
|
|
129
|
+
];
|