@ethlete/agent-rules 0.1.0-next.2 → 0.1.0-next.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ethlete/agent-rules
2
2
 
3
+ ## 0.1.0-next.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ca0bf2f`](https://github.com/ethlete-io/ethdk/commit/ca0bf2f09cd5bd925da52bdb17c93bb62bda8735) Thanks [@TomTomB](https://github.com/TomTomB)! - The `comments` rule is now an allowlist: four kinds of comment are allowed and everything else gets deleted.
8
+
3
9
  ## 0.1.0-next.2
4
10
 
5
11
  ### Minor Changes
@@ -1,31 +1,61 @@
1
1
  ---
2
2
  name: comments
3
- description: Write comments for the next reader of the file, not for the reviewer of your change.
3
+ description: Comments are an allowlist of four cases. Everything else gets deleted before the change is done.
4
4
  kind: rule
5
5
  scope: both
6
6
  ---
7
7
 
8
- ## Comments: write for the next reader of this file, not for the reviewer of your change
8
+ ## Comments: almost none, and never for the reviewer of your change
9
9
 
10
- A comment earns its place by telling someone **using or editing this code** something the
11
- code cannot. Explaining _why the change was made_ is not that — it belongs in the commit
12
- message, the changeset, or the docs.
10
+ **Write no comment unless it fits one of the four cases below.** This is an allowlist, not a
11
+ set of tips. Anything outside it gets **deleted** before you call the change done — not
12
+ softened, not shortened. Code that needs prose to be understood needs a better name, a
13
+ smaller function, or a type; fix that instead of narrating it.
13
14
 
14
- Do **not** leave behind:
15
+ ### The only comments allowed
15
16
 
16
- - **Rationale for a mechanical choice.** `Record<Size, X>` with literal keys, a `@__PURE__`
17
- annotation, a factory instead of a literal, a helper moved to another file — the type,
18
- the annotation and the import already say what happens.
19
- - **Migration narration.** "moved here from X", "used to be a tuple", "so Y no longer pulls Z".
20
- Git knows. A reader six months from now does not care.
21
- - **The same explanation repeated per call site.** If a pattern needs explaining, explain it
22
- once where the pattern is defined (the helper's JSDoc, the lint rule's message, the guide)
23
- and let every use site stay silent.
24
- - **Restating the code.** `// increment the counter` above `counter++`.
17
+ 1. **An ordering or timing constraint** a reasonable edit would break. Say what breaks.
18
+ 2. **An invariant the types cannot express**, that a caller or a future edit could violate.
19
+ 3. **A workaround**, naming its concrete cause (browser bug, upstream issue, framework
20
+ limitation) and linking it where a link exists, so the next reader can tell when it may go.
21
+ 4. **Public API JSDoc** — what it does and how to call it, on something a lib actually
22
+ exports. One or two sentences. Not internals, not history, not why it is shaped that way.
25
23
 
26
- Do keep: non-obvious behaviour and ordering constraints, a real invariant a future edit could
27
- break, a workaround with the reason it exists, and public API JSDoc (what it does and how to
28
- use it — not why it is shaped that way).
24
+ Nothing else qualifies. Not "this is subtle", not "worth noting", not a heading over a group
25
+ of members, not a summary of the function underneath it.
29
26
 
30
- When you catch yourself writing "because", check whether the sentence is aimed at the reviewer
31
- of your diff. If it is, cut it.
27
+ ### The test each one still has to pass
28
+
29
+ Delete it unless **both** are true:
30
+
31
+ - a competent reader who never sees your diff would be **surprised** without it, and
32
+ - a future edit could **break something** that this sentence is the only warning about.
33
+
34
+ Unsure counts as no. A missing comment costs a minute of reading; a stale one misleads for
35
+ years.
36
+
37
+ ### Always delete
38
+
39
+ - **Restating the code** — `// increment the counter` over `counter++`; a JSDoc on `size` that
40
+ says nothing beyond "the size of the button".
41
+ - **Section headers and dividers** — `// --- Inputs ---`, `// Helpers`, `// Public API`.
42
+ - **Rationale for a mechanical choice** — `Record<Size, X>` with literal keys, a `@__PURE__`
43
+ annotation, a factory instead of a literal, a helper moved into its own file. The type, the
44
+ annotation and the import already say what happens.
45
+ - **Migration narration** — "moved here from X", "used to be a tuple", "so Y no longer pulls
46
+ Z", "renamed for clarity". Git knows; the next reader does not care.
47
+ - **The same explanation at every call site.** Explain a pattern once where it is defined (the
48
+ helper's JSDoc, the lint rule's message, the guide) and let every use site stay silent.
49
+ - **Commented-out code.**
50
+ - **`TODO`/`FIXME` without an issue link.** Fix it now or leave nothing.
51
+ - **Hedging and meta** — "note that", "for clarity", "just in case", "this is cleaner", "we
52
+ could also…".
53
+
54
+ ### Before you call the change done
55
+
56
+ Re-read every comment in your diff and cut the ones that are not one of the four. Then fix or
57
+ delete any existing comment your change made wrong — one describing behaviour that no longer
58
+ exists is worse than none.
59
+
60
+ Two signals you have already over-commented: you wrote the word "because", or the diff adds
61
+ more than a handful of comments. Both mean go back and cut.
@@ -21,8 +21,10 @@ published yet, or when you are iterating on it.
21
21
  {%skill:sdk-source%} covers resolving it and what to check before trusting it.
22
22
  - The checkout has its dependencies installed (`yarn install` in the checkout root - the
23
23
  SDK repo is a Yarn 4 workspace).
24
- - Note which branch it is on. Building `main` when your app runs `-next` prereleases
25
- swaps in a completely different API surface.
24
+ - Check which branch it is on before building - unless the user said otherwise, that
25
+ should be `next`, up to date with `origin/next`. Building `main` when your app runs
26
+ `-next` prereleases swaps in a completely different API surface, and building a stale
27
+ `next` rebuilds a bug that is already fixed upstream. Ask before changing its branch.
26
28
 
27
29
  ## 2. Build the libraries you changed
28
30
 
@@ -38,15 +38,40 @@ holds the full `.d.ts` surface of exactly the version this repo runs - and to
38
38
  {%docsBaseUrl%}. Then tell the user a local checkout would help, and offer the snippet
39
39
  above (the file is gitignored, so adding it changes nothing for anyone else).
40
40
 
41
- ## 2. Check the checkout matches what is installed
41
+ ## 2. Check the branch before you read anything
42
42
 
43
- A checkout sits on whatever branch the developer left it on, so it can be months of
44
- work ahead of the installed package - or behind it. Compare before you trust it:
43
+ A checkout sits on whatever branch the developer left it on, so the first command you
44
+ run against it is the one that tells you what you are looking at:
45
45
 
46
46
  ```bash
47
- grep '"@ethlete/' package.json # what this repo runs
47
+ git -C <sdkSourcePath> fetch --quiet # read-only, safe
48
+ git -C <sdkSourcePath> status -sb # branch, ahead/behind, dirty files
49
+ ```
50
+
51
+ **Unless the user says otherwise, the expected state is `next`, up to date with
52
+ `origin/next`.** That is the branch the SDK develops on, and the one the `-next`
53
+ prereleases are cut from. Anything else and you are reading a different SDK than the
54
+ one you are about to describe.
55
+
56
+ When it is not in that state, **say so and ask** - never switch, pull, stash or reset
57
+ it yourself. It is someone's working tree, and the read-only rule below applies:
58
+
59
+ - **On another branch** - name it and ask whether to read it as-is or whether they want
60
+ `next`. A feature branch may be exactly what you were sent to look at.
61
+ - **Behind `origin/next`** - report how far. The code you would quote may already be
62
+ fixed upstream, so read the missing commits before calling anything a bug:
63
+ `git -C <sdkSourcePath> log --oneline HEAD..origin/next`.
64
+ - **Dirty** - it may contain someone's work in progress. Say so rather than quoting it
65
+ as SDK behaviour.
66
+
67
+ ## 3. Check the checkout matches what is installed
68
+
69
+ Even on a clean `next`, the checkout can be months of work ahead of the installed
70
+ package - or behind it:
71
+
72
+ ```bash
73
+ grep '"@ethlete/' package.json # what this repo runs
48
74
  grep -m1 '"version"' <sdkSourcePath>/libs/<lib>/package.json # what the checkout is at
49
- git -C <sdkSourcePath> status -sb # branch, and whether it is dirty
50
75
  ```
51
76
 
52
77
  Rules when they differ:
@@ -55,10 +80,8 @@ Rules when they differ:
55
80
  `.d.ts` in `node_modules` is the truth about the API you are calling.
56
81
  - Source that is ahead describes an **unreleased** API. Never write consumer code
57
82
  against it, and never assume it is available - say what release it needs.
58
- - A dirty checkout may contain someone's work in progress. Say so rather than quoting
59
- it as SDK behaviour.
60
83
 
61
- ## 3. Where things live
84
+ ## 4. Where things live
62
85
 
63
86
  Paths are relative to the checkout root:
64
87
 
@@ -79,7 +102,7 @@ Inside a component domain: `<name>.component.ts` with its `.css` next to it,
79
102
  `index.ts` as the barrel. The lib's public surface is `libs/<lib>/src/index.ts` -
80
103
  anything not re-exported from there is internal, whatever it looks like.
81
104
 
82
- ## 4. Search it, don't read it whole
105
+ ## 5. Search it, don't read it whole
83
106
 
84
107
  ```bash
85
108
  rg -n "etButton" <sdkSourcePath>/libs/components/src --glob '!*.spec.ts' # a selector
@@ -91,12 +114,14 @@ Specs are the cheapest description of intended behaviour - `<name>.component.spe
91
114
  next to a component usually answers "is this supposed to happen?" faster than the
92
115
  implementation does.
93
116
 
94
- ## 5. The checkout is read-only from here
117
+ ## 6. The checkout is read-only from here
95
118
 
96
119
  It is a different repository with its own branch, lint, docs and changeset workflow.
97
- Never edit it while working on a task in this repo, and never copy its internals into
98
- consumer code - a private helper is not a supported API and disappears without a major
99
- version (the same goes for anything under a `subtle` namespace).
120
+ Never edit it while working on a task in this repo - that covers its git state too, so
121
+ no `checkout`, `pull`, `stash` or `reset` without the user asking for it (`fetch` is
122
+ fine). Never copy its internals into consumer code either - a private helper is not a
123
+ supported API and disappears without a major version (the same goes for anything under
124
+ a `subtle` namespace).
100
125
 
101
126
  When the fix belongs in the SDK, say so and describe it precisely: file, symbol, and
102
127
  the behaviour it should have. If the user wants that fix verified against this app
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethlete/agent-rules",
3
- "version": "0.1.0-next.2",
3
+ "version": "0.1.0-next.3",
4
4
  "license": "MIT",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",