@itrocks/handbook 0.0.16 → 0.0.18
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/AGENTS.md
CHANGED
|
@@ -17,6 +17,7 @@ For any front-end change, follow
|
|
|
17
17
|
- Keep proposed and authored messages short and in English. Describe the behaviour change from the closest
|
|
18
18
|
user perspective: user > functionality > developer. For purely technical changes, use simple and beginner-friendly
|
|
19
19
|
developer language (KISS).
|
|
20
|
+
- Omit details already clear from the context, such as the package name in a commit to that package's repository.
|
|
20
21
|
- Cover all pending changes in each repository; for multiple commits, list each commit's files and shared-file hunks.
|
|
21
22
|
- For changes generated or modified by agents or subagents, add an `AI-assisted-by` trailer for each distinct
|
|
22
23
|
contributing agent identity:
|
|
@@ -26,6 +26,10 @@ When modifying a framework package, update its `package.json` version as soon as
|
|
|
26
26
|
Choose the highest level required by the development: patch for fixes or documentation, minor for backwards-compatible
|
|
27
27
|
features, major for breaking changes.
|
|
28
28
|
|
|
29
|
+
Keep packages at major version `0` while they are in pre-1.0 development. For a breaking change, increment the minor
|
|
30
|
+
version and reset the patch version to zero. For example, bump `0.0.2` to `0.1.0`. Move to `1.0.0` only when explicitly
|
|
31
|
+
requested.
|
|
32
|
+
|
|
29
33
|
First inspect `git diff HEAD -- package.json` in that package's repository, covering staged and unstaged changes.
|
|
30
34
|
Compare the working version with `HEAD`: if it already contains an increment at the required level or higher, keep it.
|
|
31
35
|
Otherwise, increment the required component from the `HEAD` version and reset lower components to zero.
|
|
@@ -30,32 +30,67 @@ inferring placement from position thresholds.
|
|
|
30
30
|
such as YAML.
|
|
31
31
|
- Omit semicolons; use single quotes and template literals for interpolation or multiline text.
|
|
32
32
|
- Space postfix operators: `index ++`, `index --`.
|
|
33
|
-
- Align
|
|
34
|
-
|
|
33
|
+
- Align the variable names in consecutive `const` and `let` declarations at the same indentation level.
|
|
34
|
+
Use three spaces after `let` in a mixed group.
|
|
35
|
+
- Align `from`, `=`, `:`, `??` and values in adjacent related lines where the limit allows. Align `=` only on
|
|
36
|
+
directly adjacent lines that contain the operator. A blank line, comment or continuation line without `=` ends the
|
|
37
|
+
alignment group. This applies to declarations, including typed declarations and type aliases, and to related
|
|
38
|
+
assignments. Align related constructor parameters as well. Pad with spaces and keep at least one before each operator.
|
|
35
39
|
- Declare one variable per statement. Separate preparation, object configuration and the final call or return with
|
|
36
40
|
blank lines when they form distinct steps.
|
|
37
41
|
- Put `{` on the next line for classes, interfaces, functions, methods and constructors.
|
|
38
42
|
- Keep `{` on the control line for conditions, loops, `switch`, `try`, `catch` and `finally`.
|
|
39
43
|
- Put `else`, `catch` and `finally` on a new line after the preceding `}`.
|
|
40
|
-
- An `if` or `else`
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
- An `if` or `else` may omit braces only if the entire line fits within 120 columns and its body is `break`,
|
|
45
|
+
`continue`, `return` alone or `return` followed by a variable or literal. Put every other body in braces. Place
|
|
46
|
+
the opening brace on the condition line, indent the body on the next line and put the closing brace on its
|
|
47
|
+
own line. This applies to `throw new Error(...)` and to a `return` that calls a function or computes a value.
|
|
48
|
+
In an `if`/`else` pair, use braces for both or neither.
|
|
43
49
|
- For empty constructors, keep `{}` on the closing parameter line, including after a multiline parameter list.
|
|
44
50
|
- Leave a blank line after a non-empty class opening brace and before its closing brace.
|
|
45
51
|
|
|
52
|
+
```ts
|
|
53
|
+
type Id = number
|
|
54
|
+
type Label = string
|
|
55
|
+
|
|
56
|
+
let count = 0
|
|
57
|
+
const limit = 10
|
|
58
|
+
|
|
59
|
+
const hasAccess = isPublic
|
|
60
|
+
|| (isMember && (status === 'active'))
|
|
61
|
+
const label = getLabel()
|
|
62
|
+
|
|
63
|
+
if (cached) return cached
|
|
64
|
+
if (missing) {
|
|
65
|
+
throw new Error('Missing value')
|
|
66
|
+
}
|
|
67
|
+
if (count < limit) {
|
|
68
|
+
return loadValue()
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
46
72
|
## Wrapped expressions
|
|
47
73
|
|
|
48
74
|
The 120-column limit is a maximum, not a target. Break dense expressions earlier when their structure is clearer.
|
|
49
75
|
|
|
76
|
+
- In chained conditions, use parentheses around comparisons and around groups that must be evaluated together.
|
|
77
|
+
When mixing `&&` and `||`, show the intended precedence explicitly, even if it matches the language's default.
|
|
78
|
+
The assignment operator `=` is outside this rule. When assigning a condition, group only its logical parts.
|
|
50
79
|
- For multiline control conditions, put `if (` on its own line, indent the condition once, and align `) {` with `if`.
|
|
51
80
|
Put leading `&&` and `||` on continuation lines at the same condition indentation.
|
|
52
81
|
- Prefer a direct ternary return when choosing between two values. Keep only simple ternaries on one line; otherwise
|
|
53
82
|
put `?` and `:` on separate lines, one level below the return or assignment. Parenthesise concatenation branches.
|
|
83
|
+
- In a ternary expression, parenthesise comparisons and binary logical operations (`&&` and `||`) in the condition
|
|
84
|
+
or either branch, even when a single operator is used.
|
|
54
85
|
- For a ternary chain, align successive conditions and their results instead of increasing indentation for each case.
|
|
55
86
|
- In multiline array and object literals, put one entry per line, including spreads and shorthand properties.
|
|
56
87
|
Break nested calls at argument boundaries and close each enclosing call at its corresponding indentation level.
|
|
57
88
|
|
|
58
89
|
```ts
|
|
90
|
+
if (isPublic || (isMember && (status === 'active'))) return
|
|
91
|
+
|
|
92
|
+
const canRead = isPublic || (isMember && (status === 'active'))
|
|
93
|
+
|
|
59
94
|
if (
|
|
60
95
|
!path || !path.startsWith('/') || path.startsWith('//')
|
|
61
96
|
|| (new URL(path, origin).pathname !== path)
|
|
@@ -67,6 +102,10 @@ return (!prefix || path.startsWith(prefix + '/'))
|
|
|
67
102
|
? path
|
|
68
103
|
: (prefix + path)
|
|
69
104
|
|
|
105
|
+
return (status === 'active')
|
|
106
|
+
? (isOwner || isAdmin)
|
|
107
|
+
: false
|
|
108
|
+
|
|
70
109
|
result =
|
|
71
110
|
isFunction(value) ? value(options) :
|
|
72
111
|
isType(value) ? new value(options) :
|
|
@@ -106,14 +145,16 @@ function calculate(
|
|
|
106
145
|
|
|
107
146
|
## Ordering
|
|
108
147
|
|
|
109
|
-
Sort homogeneous sequences alphabetically by stable name wherever order has no semantic significance.
|
|
148
|
+
Sort homogeneous sequences alphabetically by stable name, ignoring case, wherever order has no semantic significance.
|
|
110
149
|
This includes configuration, documentation, object/array entries, declarations, members, imports, exports,
|
|
111
150
|
parameters and test cases. Preserve existing responsibility groups, placing new members in their matching group,
|
|
112
151
|
then sort within each group. Use short sentence-case section comments, preserving acronym capitals such as HTML and URL.
|
|
113
152
|
Preserve required initialisation, side effects, fallback, precedence, lifecycle, overload, protocol and runtime order;
|
|
114
153
|
comment non-obvious constraints.
|
|
115
154
|
|
|
116
|
-
Group module declarations as
|
|
155
|
+
Group module declarations as type aliases, interfaces, value declarations, functions, then classes. Sort both `const`
|
|
156
|
+
and `let` by name within the same group. Sort exported and internal functions together by function name and keep each
|
|
157
|
+
set of overloads with its implementation.
|
|
117
158
|
|
|
118
159
|
For side-effect-free imports, locality precedes alphabetical order:
|
|
119
160
|
|
package/package.json
CHANGED