@ultimat3/cli 31.4.0 → 31.4.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/package.json +29 -29
- package/src/guard-sources.ts +32 -11
- package/src/templates/guard-bare-error.ts +1 -1
- package/src/templates/guard-error-declared.ts +51 -5
- package/src/templates/guard-image-dimensions.ts +3 -2
- package/src/templates/guard-local-binding.ts +74 -0
- package/src/templates/guard-native-confirm.ts +16 -1
- package/src/templates/guard-raw-fetch.ts +11 -3
- package/src/templates/guard-raw-interval.ts +8 -1
- package/src/templates/guard-raw-motion.ts +20 -4
- package/src/templates/guard-semantic-interactive.ts +20 -2
- package/src/templates/guard-undeclared-custom-property.ts +34 -10
- package/src/templates/guard-undefined-style-class.ts +34 -7
- package/src/templates/guard-untranslated-string.ts +5 -4
- package/src/templates/guard-unzoned-date.ts +14 -1
- package/src/templates/scaffold-claude-agents.ts +1 -1
- package/src/templates/scaffold-claude-commands.ts +1 -1
- package/src/templates/scaffold-docs.ts +1 -1
- package/src/templates/scaffold-domain-package.ts +1 -1
- package/src/templates/slice-foundation.ts +1 -1
- package/wiki/Actions.md +3 -2
- package/wiki/Agents.md +1 -1
- package/wiki/Building-Your-Own-Base.md +1 -1
- package/wiki/Interface-Rules.md +3 -3
- package/wiki/MCP-And-AI.md +1 -1
- package/wiki/Upgrading.md +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.4.
|
|
3
|
+
"version": "31.4.1",
|
|
4
4
|
"description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -53,34 +53,34 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/core": "^8.0.9",
|
|
56
|
-
"@ultimat3/action": "31.4.
|
|
57
|
-
"@ultimat3/admin": "31.4.
|
|
58
|
-
"@ultimat3/ai": "31.4.
|
|
59
|
-
"@ultimat3/auth": "31.4.
|
|
60
|
-
"@ultimat3/cache": "31.4.
|
|
61
|
-
"@ultimat3/core": "31.4.
|
|
62
|
-
"@ultimat3/db": "31.4.
|
|
63
|
-
"@ultimat3/entity": "31.4.
|
|
64
|
-
"@ultimat3/flags": "31.4.
|
|
65
|
-
"@ultimat3/http": "31.4.
|
|
66
|
-
"@ultimat3/i18n": "31.4.
|
|
67
|
-
"@ultimat3/jobs": "31.4.
|
|
68
|
-
"@ultimat3/mail": "31.4.
|
|
69
|
-
"@ultimat3/manifest": "31.4.
|
|
70
|
-
"@ultimat3/mcp": "31.4.
|
|
71
|
-
"@ultimat3/money": "31.4.
|
|
72
|
-
"@ultimat3/notify": "31.4.
|
|
73
|
-
"@ultimat3/policy": "31.4.
|
|
74
|
-
"@ultimat3/pwa": "31.4.
|
|
75
|
-
"@ultimat3/query": "31.4.
|
|
76
|
-
"@ultimat3/realtime": "31.4.
|
|
77
|
-
"@ultimat3/render": "31.4.
|
|
78
|
-
"@ultimat3/schema": "31.4.
|
|
79
|
-
"@ultimat3/scraping": "31.4.
|
|
80
|
-
"@ultimat3/seo": "31.4.
|
|
81
|
-
"@ultimat3/storage": "31.4.
|
|
82
|
-
"@ultimat3/testing": "31.4.
|
|
83
|
-
"@ultimat3/time": "31.4.
|
|
56
|
+
"@ultimat3/action": "31.4.1",
|
|
57
|
+
"@ultimat3/admin": "31.4.1",
|
|
58
|
+
"@ultimat3/ai": "31.4.1",
|
|
59
|
+
"@ultimat3/auth": "31.4.1",
|
|
60
|
+
"@ultimat3/cache": "31.4.1",
|
|
61
|
+
"@ultimat3/core": "31.4.1",
|
|
62
|
+
"@ultimat3/db": "31.4.1",
|
|
63
|
+
"@ultimat3/entity": "31.4.1",
|
|
64
|
+
"@ultimat3/flags": "31.4.1",
|
|
65
|
+
"@ultimat3/http": "31.4.1",
|
|
66
|
+
"@ultimat3/i18n": "31.4.1",
|
|
67
|
+
"@ultimat3/jobs": "31.4.1",
|
|
68
|
+
"@ultimat3/mail": "31.4.1",
|
|
69
|
+
"@ultimat3/manifest": "31.4.1",
|
|
70
|
+
"@ultimat3/mcp": "31.4.1",
|
|
71
|
+
"@ultimat3/money": "31.4.1",
|
|
72
|
+
"@ultimat3/notify": "31.4.1",
|
|
73
|
+
"@ultimat3/policy": "31.4.1",
|
|
74
|
+
"@ultimat3/pwa": "31.4.1",
|
|
75
|
+
"@ultimat3/query": "31.4.1",
|
|
76
|
+
"@ultimat3/realtime": "31.4.1",
|
|
77
|
+
"@ultimat3/render": "31.4.1",
|
|
78
|
+
"@ultimat3/schema": "31.4.1",
|
|
79
|
+
"@ultimat3/scraping": "31.4.1",
|
|
80
|
+
"@ultimat3/seo": "31.4.1",
|
|
81
|
+
"@ultimat3/storage": "31.4.1",
|
|
82
|
+
"@ultimat3/testing": "31.4.1",
|
|
83
|
+
"@ultimat3/time": "31.4.1",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/src/guard-sources.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
// why: `join` builds the host-separator path a glob entry is read at; Bun ships no path API.
|
|
7
7
|
import { join } from 'node:path';
|
|
8
|
+
import { renderThrowable, stringField } from '@ultimat3/core';
|
|
8
9
|
|
|
9
10
|
export interface GuardFile {
|
|
10
11
|
/** App-root-relative POSIX path, so a finding names the file an author opens. */
|
|
@@ -31,6 +32,12 @@ export interface GuardSources {
|
|
|
31
32
|
* (`X_PRERENDER_FAILED`, with the Sass error), never a guard's to repeat.
|
|
32
33
|
*/
|
|
33
34
|
compiled(path: string): Promise<GuardStylesheet | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* Why `compiled(path)` is `undefined`: the compiler's (or the read's) first line, so a guard
|
|
37
|
+
* that reports a broken sheet names the error. `undefined` when the sheet compiles. Optional
|
|
38
|
+
* so a `GuardSources` an app built itself, before this existed, still satisfies the type.
|
|
39
|
+
*/
|
|
40
|
+
compileError?(path: string): Promise<string | undefined>;
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
/** Path segments that are never the app's own source. */
|
|
@@ -49,7 +56,7 @@ export function guardSources(
|
|
|
49
56
|
const texts = new Map<string, Promise<string>>();
|
|
50
57
|
for (const file of seed) texts.set(file.path, Promise.resolve(file.source));
|
|
51
58
|
const walks = new Map<string, Promise<readonly GuardFile[]>>();
|
|
52
|
-
const sheets = new Map<string, Promise<GuardStylesheet |
|
|
59
|
+
const sheets = new Map<string, Promise<GuardStylesheet | string>>();
|
|
53
60
|
|
|
54
61
|
const textOf = (path: string): Promise<string> => {
|
|
55
62
|
let text = texts.get(path);
|
|
@@ -70,7 +77,8 @@ export function guardSources(
|
|
|
70
77
|
return Promise.all(paths.map(async (path) => ({ path, text: await textOf(path) })));
|
|
71
78
|
};
|
|
72
79
|
|
|
73
|
-
|
|
80
|
+
/** The sheet, or the first line of why it is not one. */
|
|
81
|
+
const compile = async (path: string): Promise<GuardStylesheet | string> => {
|
|
74
82
|
try {
|
|
75
83
|
const source = await textOf(path);
|
|
76
84
|
// Imported here, not at the top: Sass loads on the first compile, and a gate run whose
|
|
@@ -78,11 +86,24 @@ export function guardSources(
|
|
|
78
86
|
const { compileStylesheet } = await import('@ultimat3/render/server');
|
|
79
87
|
const { css, classes } = compileStylesheet(join(root, path), source);
|
|
80
88
|
return { css, classes };
|
|
81
|
-
} catch {
|
|
82
|
-
|
|
89
|
+
} catch (error) {
|
|
90
|
+
// The compiler's own words: render's `X_PRERENDER_FAILED` carries them in its cause behind
|
|
91
|
+
// the absolute path, which names a temp root in a test and a different checkout in CI.
|
|
92
|
+
const absolute = join(root, path);
|
|
93
|
+
const said = (stringField(error, 'cause') ?? renderThrowable(error)).split('\n')[0] ?? '';
|
|
94
|
+
return said.replace(`${absolute} did not compile: `, '').replaceAll(absolute, path);
|
|
83
95
|
}
|
|
84
96
|
};
|
|
85
97
|
|
|
98
|
+
const compiledOnce = (path: string): Promise<GuardStylesheet | string> => {
|
|
99
|
+
let sheet = sheets.get(path);
|
|
100
|
+
if (sheet === undefined) {
|
|
101
|
+
sheet = compile(path);
|
|
102
|
+
sheets.set(path, sheet);
|
|
103
|
+
}
|
|
104
|
+
return sheet;
|
|
105
|
+
};
|
|
106
|
+
|
|
86
107
|
return {
|
|
87
108
|
files(glob) {
|
|
88
109
|
let found = walks.get(glob);
|
|
@@ -92,13 +113,13 @@ export function guardSources(
|
|
|
92
113
|
}
|
|
93
114
|
return found;
|
|
94
115
|
},
|
|
95
|
-
compiled(path) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return sheet;
|
|
116
|
+
async compiled(path) {
|
|
117
|
+
const sheet = await compiledOnce(path);
|
|
118
|
+
return typeof sheet === 'string' ? undefined : sheet;
|
|
119
|
+
},
|
|
120
|
+
async compileError(path) {
|
|
121
|
+
const sheet = await compiledOnce(path);
|
|
122
|
+
return typeof sheet === 'string' ? sheet : undefined;
|
|
102
123
|
},
|
|
103
124
|
};
|
|
104
125
|
}
|
|
@@ -59,7 +59,7 @@ export function bareThrows(files: readonly SourceFile[]): readonly Finding[] {
|
|
|
59
59
|
findings.push({
|
|
60
60
|
code: CODE,
|
|
61
61
|
cause: \`\${file.path}:\${line} throws a bare \${thrown} — it reaches its reader as a stack trace with no code, no cause and nothing to run\`,
|
|
62
|
-
fix: \`declare the failure in \${file.path} with defineError({ code, title, status, cause, fix }) from @ultimat3/core — an X_SCREAMING_SNAKE code and a fix naming a command — and throw its class, then: x verify\`,
|
|
62
|
+
fix: \`declare the failure in \${file.path} with defineError({ code, title, status, cause, fix }) from @ultimat3/core/page — an X_SCREAMING_SNAKE code and a fix naming a command — and throw its class, then: x verify\`,
|
|
63
63
|
at: file.path,
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// The `error-declared` guard `x new` ships: an app code is declared with `defineError
|
|
2
|
-
// handwritten `UltimateError` subclass or a literal-coded `new
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// The `error-declared` guard `x new` ships: an app code is declared with `defineError` from
|
|
2
|
+
// `@ultimat3/core/page`, never a handwritten `UltimateError` subclass or a literal-coded `new
|
|
3
|
+
// UltimateError` (the reference app's "post not found" answered 500), and never from the barrel,
|
|
4
|
+
// which carried both framework titles tables into every island that threw (+11 kB on three routes).
|
|
5
5
|
|
|
6
6
|
import { guardCode } from './guard';
|
|
7
7
|
import type { GeneratedFile } from './naming';
|
|
@@ -14,6 +14,8 @@ const source =
|
|
|
14
14
|
(): string => `// error-declared: an app code is declared once, with defineError — its title, its status and its class.
|
|
15
15
|
// \`x verify\` discovers every file in \`guards/\` and runs its \`guard\` inside the \`boundaries\`
|
|
16
16
|
// step — nothing registers this file, so nothing can forget to. Delete it to drop the rule.
|
|
17
|
+
// defineError is imported from @ultimat3/core/page: an errors module is shared by actions and
|
|
18
|
+
// islands, and the barrel carries the framework's titles tables into every island that throws.
|
|
17
19
|
//
|
|
18
20
|
// Known limits, both read by nothing short of a type checker: an alias by assignment
|
|
19
21
|
// (const Base = UltimateError) and a shorthand key whose value is a literal elsewhere
|
|
@@ -31,6 +33,12 @@ const NAMESPACE_IMPORT =
|
|
|
31
33
|
/\\bimport\\s+\\*\\s+as\\s+([A-Za-z_$][\\w$]*)\\s+from\\s*['"]@ultimat3\\/core(?:\\/page)?['"]/g;
|
|
32
34
|
const ALIAS = /^\\s*UltimateError\\s+as\\s+([A-Za-z_$][\\w$]*)\\s*$/;
|
|
33
35
|
|
|
36
|
+
/** The barrel alone — never its page subpath — and defineError in a named list, aliased or not. */
|
|
37
|
+
const BARREL_NAMED = /\\bimport\\s+\\{([^}]*)\\}\\s*from\\s*['"]@ultimat3\\/core['"]/g;
|
|
38
|
+
const BARREL_NAMESPACE =
|
|
39
|
+
/\\bimport\\s+\\*\\s+as\\s+([A-Za-z_$][\\w$]*)\\s+from\\s*['"]@ultimat3\\/core['"]/g;
|
|
40
|
+
const DEFINE_ERROR = /^\\s*defineError(?:\\s+as\\s+[A-Za-z_$][\\w$]*)?\\s*$/;
|
|
41
|
+
|
|
34
42
|
/** A literal code as the object's own key — bare or quoted — read where the walk below stands. */
|
|
35
43
|
const LITERAL_CODE = /^(?:code|'code'|"code")\\s*:\\s*['"\`]/;
|
|
36
44
|
|
|
@@ -108,10 +116,34 @@ const literalCodeIn = (text: string, open: number): boolean => {
|
|
|
108
116
|
const finding = (file: SourceFile, line: number, what: string): Finding => ({
|
|
109
117
|
code: CODE,
|
|
110
118
|
cause: \`\${file.path}:\${line} \${what} — the title, the HTTP status and the class are then declared apart, and a code with no status answers 500 and hides its cause\`,
|
|
111
|
-
fix: \`rewrite it in \${file.path} as defineError({ code, title, status, cause, fix }) from @ultimat3/core (offSocket: true for a code no response carries), then: x verify\`,
|
|
119
|
+
fix: \`rewrite it in \${file.path} as defineError({ code, title, status, cause, fix }) from @ultimat3/core/page (offSocket: true for a code no response carries), then: x verify\`,
|
|
120
|
+
at: file.path,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const barrelFinding = (file: SourceFile, line: number): Finding => ({
|
|
124
|
+
code: CODE,
|
|
125
|
+
cause: \`\${file.path}:\${line} takes defineError from the @ultimat3/core barrel — every island that throws the code then carries the framework's titles table, ~5.5 kB it never reads\`,
|
|
126
|
+
fix: \`import { defineError } from '@ultimat3/core/page' in \${file.path} — the same function, without the table — then: x verify\`,
|
|
112
127
|
at: file.path,
|
|
113
128
|
});
|
|
114
129
|
|
|
130
|
+
/** Each line that reaches defineError through the barrel: a named import, or a namespace's member. */
|
|
131
|
+
const barrelDefineErrorLines = (text: string): readonly number[] => {
|
|
132
|
+
const lines: number[] = [];
|
|
133
|
+
for (const match of text.matchAll(BARREL_NAMED)) {
|
|
134
|
+
if ((match[1] ?? '').split(',').some((part) => DEFINE_ERROR.test(part))) {
|
|
135
|
+
lines.push(lineOf(text, match.index));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
for (const match of text.matchAll(BARREL_NAMESPACE)) {
|
|
139
|
+
const member = nameSource([\`\${match[1] ?? ''}.defineError\`]);
|
|
140
|
+
for (const use of text.matchAll(new RegExp(\`\\\\b\${member}\\\\b\`, 'g'))) {
|
|
141
|
+
lines.push(lineOf(text, use.index));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return lines;
|
|
145
|
+
};
|
|
146
|
+
|
|
115
147
|
/** Pure — the caller does the I/O — so the rule is testable without a filesystem. */
|
|
116
148
|
export function undeclaredErrors(files: readonly SourceFile[]): readonly Finding[] {
|
|
117
149
|
const found: { readonly path: string; readonly line: number; readonly finding: Finding }[] = [];
|
|
@@ -122,6 +154,9 @@ export function undeclaredErrors(files: readonly SourceFile[]): readonly Finding
|
|
|
122
154
|
const line = lineOf(text, index);
|
|
123
155
|
found.push({ path: file.path, line, finding: finding(file, line, what) });
|
|
124
156
|
};
|
|
157
|
+
for (const line of barrelDefineErrorLines(text)) {
|
|
158
|
+
found.push({ path: file.path, line, finding: barrelFinding(file, line) });
|
|
159
|
+
}
|
|
125
160
|
for (const match of text.matchAll(new RegExp(\`\\\\bextends\\\\s+(?:\${names})\\\\b\`, 'g'))) {
|
|
126
161
|
push(match.index, 'subclasses UltimateError by hand');
|
|
127
162
|
}
|
|
@@ -241,6 +276,17 @@ unitTest(
|
|
|
241
276
|
},
|
|
242
277
|
);
|
|
243
278
|
|
|
279
|
+
unitTest('defineError from the barrel is refused; from the page subpath it is the rule', () => {
|
|
280
|
+
const declared =
|
|
281
|
+
"defineError({ code: 'X_NOT_FOUND', title: 't', status: 404, cause: 'c', fix: 'x' });";
|
|
282
|
+
expect(
|
|
283
|
+
undeclaredErrors(file(\`import { defineError } from '@ultimat3/core';\\n\${declared}\`)),
|
|
284
|
+
).toHaveLength(1);
|
|
285
|
+
expect(
|
|
286
|
+
undeclaredErrors(file(\`import { defineError } from '@ultimat3/core/page';\\n\${declared}\`)),
|
|
287
|
+
).toEqual([]);
|
|
288
|
+
});
|
|
289
|
+
|
|
244
290
|
unitTest('an alias from the page subpath and a quoted code key are the same rule', () => {
|
|
245
291
|
const paged = "import { UltimateError as PageError } from '@ultimat3/core/page';\\n";
|
|
246
292
|
expect(
|
|
@@ -148,8 +148,9 @@ export const guard: Guard = {
|
|
|
148
148
|
// \`{apps/web,packages/ui}/**/*.tsx\` each match ZERO files, where \`apps/*/{site,app}/**/*.tsx\`
|
|
149
149
|
// matches 17 — so folding these into one line silently turns the guard off, which is worse than
|
|
150
150
|
// the hole it closes. A LEADING group is fine and the stylesheet guards here rely on it:
|
|
151
|
-
// \`{apps,packages}/**/*.scss\` matches all 15.
|
|
152
|
-
|
|
151
|
+
// \`{apps,packages}/**/*.scss\` matches all 15. \`shared/\` is read too: a component there renders
|
|
152
|
+
// on every page that imports it, and leaving it out was a directory the rule never saw.
|
|
153
|
+
for (const pattern of ['apps/*/{site,app,shared}/**/*.tsx', 'packages/*/src/**/*.tsx']) {
|
|
153
154
|
// The run's ONE read: every guard asking for these two globs shares the walk.
|
|
154
155
|
for (const file of await sources.files(pattern)) {
|
|
155
156
|
if (/\\.test\\.tsx?$/.test(file.path)) continue;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// The source text of `bindsLocally()`, spliced into each shipped guard that refuses a call to a
|
|
2
|
+
// global by name (`confirm(`, `fetch(`, `setInterval(`): a file that declares its own binding of
|
|
3
|
+
// that name calls its own function, never the global. One copy here, so the three guards read a
|
|
4
|
+
// binding the same way. `String.raw` keeps the regexes as written; the text holds no backtick.
|
|
5
|
+
|
|
6
|
+
export const LOCAL_BINDING_SOURCE = String.raw`const DECLARED = /\b(?:const|let|var|class|function\s*\*?)\s+([A-Za-z_$][\w$]*)/g;
|
|
7
|
+
const ARROW_PARAMETER = /(?<![\w$.])([A-Za-z_$][\w$]*)\s*=>/g;
|
|
8
|
+
const IMPORT_CLAUSE = /\bimport\s+([^;]*?)\bfrom\b/g;
|
|
9
|
+
/** A name an import clause binds: 'a', '{ a }', '* as a', '{ b as a }' — never the 'b' of 'b as a'. */
|
|
10
|
+
const IMPORTED = /(?<![\w$])([A-Za-z_$][\w$]*)(?![\w$])(?!\s+as\b)/g;
|
|
11
|
+
const IDENTIFIER = /(?<![\w$.])[A-Za-z_$][\w$]*(?![\w$])/g;
|
|
12
|
+
/** After a pattern's closing bracket: '=' closes a destructuring, '=>' or a body a parameter list. */
|
|
13
|
+
const PATTERN_END = /^\s*(?::[^=;{}()]*?)?\s*(=>|=(?!=)|\{)/;
|
|
14
|
+
const CONDITION = /\b(?:if|for|while|switch|with)\s*$/;
|
|
15
|
+
const OPENERS = '([{';
|
|
16
|
+
const CLOSERS = ')]}';
|
|
17
|
+
|
|
18
|
+
/** The index of the bracket closing the one at 'open', or the end of the text. */
|
|
19
|
+
const closing = (text: string, open: number): number => {
|
|
20
|
+
let depth = 0;
|
|
21
|
+
for (let index = open; index < text.length; index += 1) {
|
|
22
|
+
if (OPENERS.includes(text[index] ?? '')) depth += 1;
|
|
23
|
+
if (CLOSERS.includes(text[index] ?? '') && --depth === 0) return index;
|
|
24
|
+
}
|
|
25
|
+
return text.length;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** The brackets enclosing 'at', innermost first, up to and including the first parenthesis. */
|
|
29
|
+
const enclosing = (text: string, at: number): readonly number[] => {
|
|
30
|
+
const opens: number[] = [];
|
|
31
|
+
let depth = 0;
|
|
32
|
+
for (let index = at - 1; index >= 0; index -= 1) {
|
|
33
|
+
const char = text[index] ?? '';
|
|
34
|
+
if (CLOSERS.includes(char)) depth += 1;
|
|
35
|
+
else if (OPENERS.includes(char) && depth > 0) depth -= 1;
|
|
36
|
+
else if (OPENERS.includes(char)) {
|
|
37
|
+
opens.push(index);
|
|
38
|
+
if (char === '(') break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return opens;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** Whether the occurrence at 'at' sits in a parameter list or a destructuring pattern. */
|
|
45
|
+
const inPattern = (text: string, at: number, name: string): boolean => {
|
|
46
|
+
const opens = enclosing(text, at);
|
|
47
|
+
// '{ name: other }' binds 'other', and '(name: Type)' is a parameter: a key only in braces.
|
|
48
|
+
if (text[opens[0] ?? -1] === '{' && /^\s*:/.test(text.slice(at + name.length))) return false;
|
|
49
|
+
for (const open of opens) {
|
|
50
|
+
const close = closing(text, open);
|
|
51
|
+
const end = PATTERN_END.exec(text.slice(close + 1, close + 200))?.[1];
|
|
52
|
+
if (end === undefined) continue;
|
|
53
|
+
if (text[open] !== '(') return end === '=';
|
|
54
|
+
return end !== '=' && !CONDITION.test(text.slice(Math.max(0, open - 10), open));
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Whether the file binds 'name' itself — declared, imported, a parameter or destructured — so a
|
|
61
|
+
* bare 'name(' is its own function and not the global. File-wide, not scoped: a guard is a regex.
|
|
62
|
+
*/
|
|
63
|
+
const bindsLocally = (text: string, name: string): boolean => {
|
|
64
|
+
for (const match of text.matchAll(DECLARED)) if (match[1] === name) return true;
|
|
65
|
+
for (const match of text.matchAll(ARROW_PARAMETER)) if (match[1] === name) return true;
|
|
66
|
+
for (const clause of text.matchAll(IMPORT_CLAUSE)) {
|
|
67
|
+
for (const match of (clause[1] ?? '').matchAll(IMPORTED)) if (match[1] === name) return true;
|
|
68
|
+
}
|
|
69
|
+
for (const match of text.matchAll(IDENTIFIER)) {
|
|
70
|
+
if (match[0] !== name || /^\s*\(/.test(text.slice(match.index + name.length))) continue;
|
|
71
|
+
if (inPattern(text, match.index, name)) return true;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
};`;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// one way. A `// why:` on the call's line, or the line above it, admits a call that is not that.
|
|
5
5
|
|
|
6
6
|
import { guardCode } from './guard';
|
|
7
|
+
import { LOCAL_BINDING_SOURCE } from './guard-local-binding';
|
|
7
8
|
import type { GeneratedFile } from './naming';
|
|
8
9
|
|
|
9
10
|
/** Derived from the guard's name, never a literal: an `X_*` literal here is a FRAMEWORK code. */
|
|
@@ -19,7 +20,8 @@ const source =
|
|
|
19
20
|
// translated, styled or refused, and it blocks the page while it is up. \`ConfirmDialog\` from
|
|
20
21
|
// \`@ultimat3/ui\` focuses Cancel, posts natively with scripting off and stays open on a refusal.
|
|
21
22
|
// Read: a bare, \`window.\`, \`self.\` or \`globalThis.\` \`confirm(\` in a \`*.island.tsx\` or anywhere
|
|
22
|
-
// under \`apps/web/\`.
|
|
23
|
+
// under \`apps/web/\`. Not read: a bare \`confirm(\` in a file that binds its own \`confirm\`
|
|
24
|
+
// (declared, imported, a parameter, destructured). Admitted: a \`// why:\` on the line or above it.
|
|
23
25
|
|
|
24
26
|
import type { Finding, Guard } from '@ultimat3/cli';
|
|
25
27
|
|
|
@@ -35,6 +37,8 @@ export interface SourceFile {
|
|
|
35
37
|
const CALL = /(?<![\\w$.])(?<!function\\s+)(?:(?:globalThis|window|self)\\s*\\.\\s*)?confirm\\s*\\(/g;
|
|
36
38
|
const WHY = /\\/\\/\\s*why:/;
|
|
37
39
|
|
|
40
|
+
${LOCAL_BINDING_SOURCE}
|
|
41
|
+
|
|
38
42
|
/** Comments and string bodies blanked IN PLACE, so a line number still points at the source. */
|
|
39
43
|
const blank = (text: string): string =>
|
|
40
44
|
text
|
|
@@ -50,7 +54,10 @@ export function nativeConfirms(files: readonly SourceFile[]): readonly Finding[]
|
|
|
50
54
|
for (const file of files) {
|
|
51
55
|
const lines = file.source.split('\\n');
|
|
52
56
|
const text = blank(file.source);
|
|
57
|
+
const local = bindsLocally(text, 'confirm');
|
|
53
58
|
for (const match of text.matchAll(CALL)) {
|
|
59
|
+
// A bare call to the file's own \`confirm\` is not the dialog; \`window.confirm(\` always is.
|
|
60
|
+
if (local && match[0].startsWith('confirm')) continue;
|
|
54
61
|
const line = text.slice(0, match.index).split('\\n').length;
|
|
55
62
|
if (WHY.test(lines[line - 1] ?? '') || WHY.test(lines[line - 2] ?? '')) continue;
|
|
56
63
|
const at = \`\${file.path}:\${line}\`;
|
|
@@ -117,6 +124,14 @@ unitTest('a comment, a string, a method and a definition are not calls', () => {
|
|
|
117
124
|
expect(nativeConfirms(file('function confirm(input) { return input; }'))).toEqual([]);
|
|
118
125
|
});
|
|
119
126
|
|
|
127
|
+
unitTest('a confirm the file binds itself is its own; window.confirm( never is', () => {
|
|
128
|
+
expect(nativeConfirms(file('const confirm = async () => {};\\nvoid confirm();'))).toEqual([]);
|
|
129
|
+
expect(nativeConfirms(file('const ask = (confirm) => confirm();'))).toEqual([]);
|
|
130
|
+
expect(nativeConfirms(file("import { confirm } from './x';\\nconfirm('Delete?');"))).toEqual([]);
|
|
131
|
+
expect(nativeConfirms(file("let confirm;\\nwindow.confirm('Delete?');"))).toHaveLength(1);
|
|
132
|
+
expect(nativeConfirms(file("const { confirm: ask } = deps;\\nconfirm('x');"))).toHaveLength(1);
|
|
133
|
+
});
|
|
134
|
+
|
|
120
135
|
unitTest('islands and apps/web are read; tests and other packages are not', () => {
|
|
121
136
|
expect(readsFile('apps/web/app/posts/page.tsx')).toBe(true);
|
|
122
137
|
expect(readsFile('packages/ui/src/delete.island.tsx')).toBe(true);
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// signal it stays legal: the guard cannot prove the other properties, and outbound() is the way.
|
|
5
5
|
|
|
6
6
|
import { guardCode } from './guard';
|
|
7
|
+
import { LOCAL_BINDING_SOURCE } from './guard-local-binding';
|
|
7
8
|
import type { GeneratedFile } from './naming';
|
|
8
9
|
|
|
9
10
|
/** Derived from the guard's name, never a literal: an `X_*` literal here is a FRAMEWORK code. */
|
|
@@ -15,9 +16,11 @@ const source =
|
|
|
15
16
|
// \`x verify\` discovers every file in \`guards/\` and runs its \`guard\` inside the \`boundaries\`
|
|
16
17
|
// step — nothing registers this file, so nothing can forget to. Delete it to drop the rule.
|
|
17
18
|
//
|
|
18
|
-
// Read: a bare or \`globalThis.\` \`fetch(\` call. Not read: an injected \`deps.fetch(\`, a
|
|
19
|
-
//
|
|
20
|
-
//
|
|
19
|
+
// Read: a bare or \`globalThis.\` \`fetch(\` call. Not read: an injected \`deps.fetch(\`, a bare
|
|
20
|
+
// \`fetch(\` in a file that binds its own \`fetch\` (declared, imported, a parameter, destructured),
|
|
21
|
+
// a method DEFINITION (\`fetch(request) {\`, Bun.serve's handler), a test, or an island (a browser
|
|
22
|
+
// has no request to outlive). Options passed as a variable read as unsignalled: spread them and add
|
|
23
|
+
// the key.
|
|
21
24
|
|
|
22
25
|
import type { Finding, Guard } from '@ultimat3/cli';
|
|
23
26
|
|
|
@@ -33,6 +36,8 @@ export interface SourceFile {
|
|
|
33
36
|
const CALL = /(?<![\\w$.])(?:globalThis\\s*\\.\\s*)?fetch\\s*\\(/g;
|
|
34
37
|
const SIGNAL = /(?<![\\w$.])signal\\s*[:,}]/g;
|
|
35
38
|
|
|
39
|
+
${LOCAL_BINDING_SOURCE}
|
|
40
|
+
|
|
36
41
|
/** Comments and string bodies blanked IN PLACE, so a line number still points at the source. */
|
|
37
42
|
const blank = (text: string): string =>
|
|
38
43
|
text
|
|
@@ -72,7 +77,10 @@ export function rawFetches(files: readonly SourceFile[]): readonly Finding[] {
|
|
|
72
77
|
const findings: Finding[] = [];
|
|
73
78
|
for (const file of files) {
|
|
74
79
|
const text = blank(file.source);
|
|
80
|
+
const local = bindsLocally(text, 'fetch');
|
|
75
81
|
for (const match of text.matchAll(CALL)) {
|
|
82
|
+
// A bare call to the file's own \`fetch\` is an injected client; \`globalThis.fetch(\` never is.
|
|
83
|
+
if (local && match[0].startsWith('fetch')) continue;
|
|
76
84
|
const open = match.index + match[0].length - 1;
|
|
77
85
|
const close = closeOf(text, open);
|
|
78
86
|
const after = text.slice(close + 1).trimStart();
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// A `// why:` on the call's line, or the line above it, admits a tick that is not a read.
|
|
5
5
|
|
|
6
6
|
import { guardCode } from './guard';
|
|
7
|
+
import { LOCAL_BINDING_SOURCE } from './guard-local-binding';
|
|
7
8
|
import type { GeneratedFile } from './naming';
|
|
8
9
|
|
|
9
10
|
/** Derived from the guard's name, never a literal: an `X_*` literal here is a FRAMEWORK code. */
|
|
@@ -19,7 +20,8 @@ const source =
|
|
|
19
20
|
// for a 401 forever. \`visibleInterval(run, ms)\` from \`@ultimat3/core/page\` makes no call while the
|
|
20
21
|
// tab is hidden, one when it is shown, and stops at the first lost session. Read: a bare,
|
|
21
22
|
// \`window.\`, \`self.\` or \`globalThis.\` \`setInterval(\` in a \`*.island.tsx\`. Admitted: a \`// why:\` on
|
|
22
|
-
// the call's line or the line above it — an animation tick is not a read.
|
|
23
|
+
// the call's line or the line above it — an animation tick is not a read. Not read: a bare
|
|
24
|
+
// \`setInterval(\` in a file that binds its own (declared, imported, a parameter, destructured).
|
|
23
25
|
|
|
24
26
|
import type { Finding, Guard } from '@ultimat3/cli';
|
|
25
27
|
|
|
@@ -35,6 +37,8 @@ export interface SourceFile {
|
|
|
35
37
|
const CALL = /(?<![\\w$.])(?:(?:globalThis|window|self)\\s*\\.\\s*)?setInterval\\s*\\(/g;
|
|
36
38
|
const WHY = /\\/\\/\\s*why:/;
|
|
37
39
|
|
|
40
|
+
${LOCAL_BINDING_SOURCE}
|
|
41
|
+
|
|
38
42
|
/** Comments and string bodies blanked IN PLACE, so a line number still points at the source. */
|
|
39
43
|
const blank = (text: string): string =>
|
|
40
44
|
text
|
|
@@ -50,7 +54,10 @@ export function rawIntervals(files: readonly SourceFile[]): readonly Finding[] {
|
|
|
50
54
|
for (const file of files) {
|
|
51
55
|
const lines = file.source.split('\\n');
|
|
52
56
|
const text = blank(file.source);
|
|
57
|
+
const local = bindsLocally(text, 'setInterval');
|
|
53
58
|
for (const match of text.matchAll(CALL)) {
|
|
59
|
+
// A bare call to the file's own \`setInterval\` is not the timer; \`window.\` always is.
|
|
60
|
+
if (local && match[0].startsWith('setInterval')) continue;
|
|
54
61
|
const line = text.slice(0, match.index).split('\\n').length;
|
|
55
62
|
if (WHY.test(lines[line - 1] ?? '') || WHY.test(lines[line - 2] ?? '')) continue;
|
|
56
63
|
const at = \`\${file.path}:\${line}\`;
|
|
@@ -15,7 +15,9 @@ const source =
|
|
|
15
15
|
// step — nothing registers this file, so nothing can forget to. Delete it to drop the rule.
|
|
16
16
|
//
|
|
17
17
|
// A keyword is not a literal: \`linear\`, \`ease\`, \`infinite\` and \`0s\` are never reported, and a
|
|
18
|
-
// multiple of a token is still the token — \`calc(#{tokens.duration(slower)} * 2)\`.
|
|
18
|
+
// multiple of a token is still the token — \`calc(#{tokens.duration(slower)} * 2)\`. A custom
|
|
19
|
+
// property is read too: \`--ease: cubic-bezier(…)\` is a second scale that every \`var(--ease)\` then
|
|
20
|
+
// moves at. The scale's own properties come from \`@ultimat3/ui\`, which this never scans.
|
|
19
21
|
|
|
20
22
|
import type { Finding, Guard } from '@ultimat3/cli';
|
|
21
23
|
|
|
@@ -58,7 +60,8 @@ const namespaceOf = (scss: string): string =>
|
|
|
58
60
|
|
|
59
61
|
/** A declaration; a Sass \`#{…}\` interpolation is a value that carries braces. */
|
|
60
62
|
const DECLARATION = /(?<![\\w$-])([\\w-]+)\\s*:\\s*((?:#\\{[^}]*\\}|[^;{}])+)/g;
|
|
61
|
-
|
|
63
|
+
/** A motion property, or a custom property — whose value Sass does not evaluate, hence \`#{…}\`. */
|
|
64
|
+
const MOTION_PROPERTY = /^(?:transition|animation)(?:-|$)|^--/;
|
|
62
65
|
/** A token read, with its argument list: \`tokens.duration(fast)\`, \`var(--duration-fast)\`. */
|
|
63
66
|
const TOKEN_CALL = /(?<![\\w-])(?:var|(?:[\\w-]+\\.)[\\w-]+|duration|easing)\\([^()]*\\)/g;
|
|
64
67
|
const TIME = /(?<![\\w.#-])(\\d*\\.?\\d+)(ms|s)\\b/g;
|
|
@@ -85,6 +88,8 @@ export function rawMotion(files: readonly StyleFile[]): readonly Finding[] {
|
|
|
85
88
|
const property = match[1] ?? '';
|
|
86
89
|
if (!MOTION_PROPERTY.test(property)) continue;
|
|
87
90
|
const value = (match[2] ?? '').trim().replaceAll(/\\s+/g, ' ');
|
|
91
|
+
const custom = property.startsWith('--');
|
|
92
|
+
const token = (call: string): string => (custom ? \`#{\${call}}\` : call);
|
|
88
93
|
const read = value.replaceAll(TOKEN_CALL, (call) => ' '.repeat(call.length));
|
|
89
94
|
const literals: string[] = [];
|
|
90
95
|
let written = '';
|
|
@@ -98,14 +103,18 @@ export function rawMotion(files: readonly StyleFile[]): readonly Finding[] {
|
|
|
98
103
|
...[...read.matchAll(CURVE)].map((curve) => ({
|
|
99
104
|
index: curve.index,
|
|
100
105
|
text: curve[0],
|
|
101
|
-
token:
|
|
106
|
+
token: token(
|
|
107
|
+
\`\${ns}.easing(\${EASINGS[(curve[1] ?? '').replaceAll(/\\s+/g, '')] ?? 'out'})\`,
|
|
108
|
+
),
|
|
102
109
|
})),
|
|
103
110
|
...[...read.replaceAll(CURVE, (curve) => ' '.repeat(curve.length)).matchAll(TIME)]
|
|
104
111
|
.filter((time) => Number(time[1]) !== 0)
|
|
105
112
|
.map((time) => ({
|
|
106
113
|
index: time.index,
|
|
107
114
|
text: time[0],
|
|
108
|
-
token:
|
|
115
|
+
token: token(
|
|
116
|
+
\`\${ns}.duration(\${durationFor(Number(time[1]) * (time[2] === 's' ? 1000 : 1))})\`,
|
|
117
|
+
),
|
|
109
118
|
})),
|
|
110
119
|
].sort((a, b) => a.index - b.index);
|
|
111
120
|
for (const hit of hits) {
|
|
@@ -184,6 +193,13 @@ unitTest('one declaration is one finding, with every literal in it rewritten', (
|
|
|
184
193
|
);
|
|
185
194
|
});
|
|
186
195
|
|
|
196
|
+
unitTest('a custom property holding a raw curve or time is refused, the fix interpolated', () => {
|
|
197
|
+
expect(fixes(':root { --ease: cubic-bezier(0, 0, 1, 1); }')[0]).toStartWith(
|
|
198
|
+
'--ease: #{tokens.easing(out)} — ',
|
|
199
|
+
);
|
|
200
|
+
expect(fixes(':root { --wait: 0.4s; --gap: 12px; --ok: var(--duration-fast); }')).toHaveLength(1);
|
|
201
|
+
});
|
|
202
|
+
|
|
187
203
|
unitTest('the fix speaks the namespace the sheet uses the tokens under', () => {
|
|
188
204
|
const scss = "@use '../shared/tokens' as t;\\n.a { transition-duration: 120ms; }";
|
|
189
205
|
expect(fixes(scss)[0]).toStartWith('transition-duration: t.duration(fast) — ');
|
|
@@ -67,6 +67,14 @@ const ROLE = /(?<![\\w-])role\\s*=\\s*["']([a-z]+)["']/;
|
|
|
67
67
|
const TABINDEX = /(?<![\\w-])tab[Ii]ndex\\s*=/;
|
|
68
68
|
const KEYS = /(?<![\\w-])onKey(?:Down|Up|Press)\\s*=/;
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* An option an \`aria-activedescendant\` combobox manages: focus stays on the input, which answers
|
|
72
|
+
* the keys, so the option is \`tabIndex={-1}\` with a pointer handler and nothing more — the WAI-ARIA
|
|
73
|
+
* combobox pattern, complete as written. \`option\` only: no other role is exempted by this shape.
|
|
74
|
+
*/
|
|
75
|
+
const MANAGED = /(?<![\\w-])role\\s*=\\s*["']option["']/;
|
|
76
|
+
const UNFOCUSED = /(?<![\\w-])tab[Ii]ndex\\s*=\\s*(?:\\{\\s*-1\\s*\\}|["']-1["'])/;
|
|
77
|
+
|
|
70
78
|
export interface SourceFile {
|
|
71
79
|
/** App-root-relative POSIX path, so the finding names the file an author opens. */
|
|
72
80
|
readonly path: string;
|
|
@@ -134,6 +142,7 @@ export function semanticInteractive(files: readonly SourceFile[]): readonly Find
|
|
|
134
142
|
// guide asks for — a deliberate widget, written by someone who read the obligation. This
|
|
135
143
|
// rule is about the incomplete ones, so all three present is the one shape it passes over.
|
|
136
144
|
if (ROLE.test(tag.attrs) && TABINDEX.test(tag.attrs) && KEYS.test(tag.attrs)) continue;
|
|
145
|
+
if (MANAGED.test(tag.attrs) && UNFOCUSED.test(tag.attrs)) continue;
|
|
137
146
|
const at = \`\${file.path}:\${lineOf(text, tag.index)}\`;
|
|
138
147
|
const role = ROLE.exec(tag.attrs)?.[1] ?? '';
|
|
139
148
|
const native = NATIVE.get(role);
|
|
@@ -170,8 +179,9 @@ export const guard: Guard = {
|
|
|
170
179
|
// \`{apps/web,packages/ui}/**/*.tsx\` each match ZERO files, where \`apps/*/{site,app}/**/*.tsx\`
|
|
171
180
|
// matches 17 — so folding these into one line silently turns the guard off, which is worse than
|
|
172
181
|
// the hole it closes. A LEADING group is fine and the stylesheet guards here rely on it:
|
|
173
|
-
// \`{apps,packages}/**/*.scss\` matches all 15.
|
|
174
|
-
|
|
182
|
+
// \`{apps,packages}/**/*.scss\` matches all 15. \`shared/\` is read too: a component there renders
|
|
183
|
+
// on every page that imports it, and leaving it out was a directory the rule never saw.
|
|
184
|
+
for (const pattern of ['apps/*/{site,app,shared}/**/*.tsx', 'packages/*/src/**/*.tsx']) {
|
|
175
185
|
// The run's ONE read: every guard asking for these two globs shares the walk.
|
|
176
186
|
for (const file of await sources.files(pattern)) {
|
|
177
187
|
if (/\\.test\\.tsx?$/.test(file.path)) continue;
|
|
@@ -221,6 +231,14 @@ unitTest('a role with a tab stop and a key handler is a deliberate widget', () =
|
|
|
221
231
|
expect(semanticInteractive(file(widget))).toEqual([]);
|
|
222
232
|
});
|
|
223
233
|
|
|
234
|
+
// The WAI-ARIA combobox: focus stays on the input, which answers the keys for its options.
|
|
235
|
+
unitTest('a managed option is silent; one with a tab stop is not', () => {
|
|
236
|
+
const managed = '<div role="option" tabIndex={-1} onMouseDown={pick}>A</div>';
|
|
237
|
+
expect(semanticInteractive(file(managed))).toEqual([]);
|
|
238
|
+
const focusable = '<div role="option" onMouseDown={pick}>A</div>';
|
|
239
|
+
expect(semanticInteractive(file(focusable))).toHaveLength(1);
|
|
240
|
+
});
|
|
241
|
+
|
|
224
242
|
unitTest('data-role is not role, and a live region is not a control', () => {
|
|
225
243
|
expect(semanticInteractive(file('<p data-role="status" role="status">Saved</p>'))).toEqual([]);
|
|
226
244
|
});
|
|
@@ -18,8 +18,9 @@ const source =
|
|
|
18
18
|
// Read from the COMPILED sheets, so \`tokens.space(7)\` — a step the scale does not have — is the
|
|
19
19
|
// \`var(--space-7)\` it compiles to. Declared means: set by any stylesheet in the app (the global
|
|
20
20
|
// one emits every token), or named in a \`.ts\`/\`.tsx\` file, where an inline \`style\` sets it. A
|
|
21
|
-
// \`var(--x, fallback)\` declares its own answer and is never reported.
|
|
22
|
-
// compile
|
|
21
|
+
// \`var(--x, fallback)\` declares its own answer and is never reported. A sheet that fails to
|
|
22
|
+
// compile is itself a finding, and while one does no read is judged: its declarations are unknown,
|
|
23
|
+
// and a rule that read nothing never passes.
|
|
23
24
|
|
|
24
25
|
import type { Finding, Guard } from '@ultimat3/cli';
|
|
25
26
|
|
|
@@ -31,7 +32,10 @@ export interface CompiledSheet {
|
|
|
31
32
|
readonly path: string;
|
|
32
33
|
/** The source, to find the line a compiled \`var()\` came from. */
|
|
33
34
|
readonly scss: string;
|
|
34
|
-
|
|
35
|
+
/** \`undefined\` when the sheet does not compile. */
|
|
36
|
+
readonly css: string | undefined;
|
|
37
|
+
/** The compiler's first line, when it does not. */
|
|
38
|
+
readonly error?: string | undefined;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
const DECLARED = /(--[A-Za-z_][\\w-]*)\\s*:/g;
|
|
@@ -84,9 +88,20 @@ export function undeclaredCustomProperties(
|
|
|
84
88
|
sheets: readonly CompiledSheet[],
|
|
85
89
|
sources: readonly string[],
|
|
86
90
|
): readonly Finding[] {
|
|
91
|
+
// One sheet that does not compile and the declared set is incomplete: every read of what it
|
|
92
|
+
// declares would be reported. The broken sheet is the finding; the reads wait for its repair.
|
|
93
|
+
const broken = sheets.filter((sheet) => sheet.css === undefined);
|
|
94
|
+
if (broken.length > 0) {
|
|
95
|
+
return broken.map((sheet) => ({
|
|
96
|
+
code: CODE,
|
|
97
|
+
cause: \`\${sheet.path} does not compile\${sheet.error === undefined ? '' : \`: \${sheet.error}\`} — so the custom properties it declares are unknown and no var() read in this app was checked\`,
|
|
98
|
+
fix: \`repair the Sass in \${sheet.path}\${sheet.error === undefined ? " — x build --target static prints the compiler's error for a sheet a page uses —" : ' at the error the cause quotes,'} then: x verify\`,
|
|
99
|
+
at: sheet.path,
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
87
102
|
const declared = new Set<string>();
|
|
88
103
|
for (const sheet of sheets) {
|
|
89
|
-
for (const match of sheet.css.matchAll(DECLARED)) declared.add(match[1] ?? '');
|
|
104
|
+
for (const match of (sheet.css ?? '').matchAll(DECLARED)) declared.add(match[1] ?? '');
|
|
90
105
|
}
|
|
91
106
|
for (const source of sources) {
|
|
92
107
|
for (const match of source.matchAll(NAMED)) declared.add(match[0]);
|
|
@@ -95,7 +110,7 @@ export function undeclaredCustomProperties(
|
|
|
95
110
|
const findings: Finding[] = [];
|
|
96
111
|
for (const sheet of sheets) {
|
|
97
112
|
const reported = new Set<string>();
|
|
98
|
-
for (const match of sheet.css.matchAll(READ)) {
|
|
113
|
+
for (const match of (sheet.css ?? '').matchAll(READ)) {
|
|
99
114
|
const name = match[1] ?? '';
|
|
100
115
|
if (declared.has(name) || reported.has(name)) continue;
|
|
101
116
|
reported.add(name);
|
|
@@ -123,11 +138,9 @@ export const guard: Guard = {
|
|
|
123
138
|
// A partial is \`@use\`d into the sheets that are compiled here; alone it is not a stylesheet.
|
|
124
139
|
if ((file.path.split('/').pop() ?? '').startsWith('_')) continue;
|
|
125
140
|
const compiled = await sources.compiled(file.path);
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (compiled === undefined) return [];
|
|
130
|
-
sheets.push({ path: file.path, scss: file.text, css: compiled.css });
|
|
141
|
+
// \`compileError\` is optional on \`GuardSources\`: an older CLI reports the sheet without it.
|
|
142
|
+
const error = compiled === undefined ? await sources.compileError?.(file.path) : undefined;
|
|
143
|
+
sheets.push({ path: file.path, scss: file.text, css: compiled?.css, error });
|
|
131
144
|
}
|
|
132
145
|
const code = await sources.files('{apps,packages}/**/*.{ts,tsx}');
|
|
133
146
|
return undeclaredCustomProperties(
|
|
@@ -203,6 +216,17 @@ unitTest('a property an inline style can set is declared', () => {
|
|
|
203
216
|
expect(check('.bar { width: var(--fill); }', '.bar{width:var(--fill)}', [tsx])).toEqual([]);
|
|
204
217
|
});
|
|
205
218
|
|
|
219
|
+
unitTest('a sheet that does not compile is the finding, and no read is judged while it is', () => {
|
|
220
|
+
const broken = { path: 'apps/web/shared/broken.scss', scss: ':root { --x: ; ', css: undefined };
|
|
221
|
+
const findings = undeclaredCustomProperties(
|
|
222
|
+
[GLOBAL, broken, sheet('', '.a{color:var(--x)}')],
|
|
223
|
+
[],
|
|
224
|
+
);
|
|
225
|
+
expect(findings.map((finding) => finding.at)).toEqual(['apps/web/shared/broken.scss']);
|
|
226
|
+
const quoted = undeclaredCustomProperties([{ ...broken, error: 'Error: expected "}".' }], []);
|
|
227
|
+
expect(quoted[0]?.cause).toContain('does not compile: Error: expected "}".');
|
|
228
|
+
});
|
|
229
|
+
|
|
206
230
|
unitTest('a read with a fallback declares its own answer', () => {
|
|
207
231
|
expect(check('.a { color: var(--maybe, inherit); }', '.a{color:var(--maybe, inherit)}')).toEqual(
|
|
208
232
|
[],
|
|
@@ -17,7 +17,8 @@ const source =
|
|
|
17
17
|
//
|
|
18
18
|
// Read from the COMPILED sheet, so a class a mixin generates or \`&-suffix\` nests is one, and a
|
|
19
19
|
// class inside \`:global()\` is not. A computed member (\`styles[name]\`) is out of scope: its key is
|
|
20
|
-
// only known when the component runs. A sheet that does not compile is
|
|
20
|
+
// only known when the component runs. A sheet that does not compile, or is not there, is a finding
|
|
21
|
+
// at its import: no read off it can be checked, and a rule that read nothing never passes.
|
|
21
22
|
|
|
22
23
|
import type { Finding, Guard } from '@ultimat3/cli';
|
|
23
24
|
|
|
@@ -30,8 +31,13 @@ export interface MarkupFile {
|
|
|
30
31
|
readonly tsx: string;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
/**
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* The classes a stylesheet compiles, by app-root-relative path; \`{ error }\` with the compiler's
|
|
36
|
+
* first line when it does not, \`undefined\` when there is no line to give.
|
|
37
|
+
*/
|
|
38
|
+
export type CompiledClasses = (
|
|
39
|
+
sheet: string,
|
|
40
|
+
) => Promise<readonly string[] | { readonly error: string } | undefined>;
|
|
35
41
|
|
|
36
42
|
const blank = (text: string): string => text.replaceAll(/[^\\n]/g, ' ');
|
|
37
43
|
|
|
@@ -80,7 +86,17 @@ export async function undefinedStyleClasses(
|
|
|
80
86
|
const binding = imported[1] ?? '';
|
|
81
87
|
const sheet = resolve(file.path, imported[2] ?? '');
|
|
82
88
|
const declared = await classesOf(sheet);
|
|
83
|
-
if (declared === undefined)
|
|
89
|
+
if (declared === undefined || 'error' in declared) {
|
|
90
|
+
const at = \`\${file.path}:\${lineOf(tsx, imported.index)}\`;
|
|
91
|
+
const said = declared === undefined ? '' : \`: \${declared.error}\`;
|
|
92
|
+
findings.push({
|
|
93
|
+
code: CODE,
|
|
94
|
+
cause: \`\${at} imports \${sheet}, which does not compile\${said} — no class read off \${binding} was checked, and each may render as nothing\`,
|
|
95
|
+
fix: \`repair the Sass in \${sheet}\${said === '' ? " (x build --target static prints the compiler's error)" : ' at the error the cause quotes'}, or correct the import at \${at}, then: x verify\`,
|
|
96
|
+
at,
|
|
97
|
+
});
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
84
100
|
// \`styles.hero\` and \`styles['hero-title']\` — a static key either way. \`styles[name]\` has no
|
|
85
101
|
// quote after the bracket and is not matched. A path is not a read: \`'./shell.module.scss'\`
|
|
86
102
|
// holds \`shell.module\`, so a name that follows a slash, a quote or a dash is skipped.
|
|
@@ -118,7 +134,10 @@ export const guard: Guard = {
|
|
|
118
134
|
markup.map((file) => ({ path: file.path, tsx: file.text })),
|
|
119
135
|
async (sheet) => {
|
|
120
136
|
const compiled = await sources.compiled(sheet);
|
|
121
|
-
|
|
137
|
+
if (compiled !== undefined) return Object.keys(compiled.classes);
|
|
138
|
+
// \`compileError\` is optional on \`GuardSources\`: an older CLI reports the sheet without it.
|
|
139
|
+
const error = await sources.compileError?.(sheet);
|
|
140
|
+
return error === undefined ? undefined : { error };
|
|
122
141
|
},
|
|
123
142
|
);
|
|
124
143
|
},
|
|
@@ -202,9 +221,17 @@ unitTest('a computed key, a comment and another object are out of scope', async
|
|
|
202
221
|
for (const body of silent) expect(await check(body)).toEqual([]);
|
|
203
222
|
});
|
|
204
223
|
|
|
205
|
-
unitTest(
|
|
224
|
+
unitTest('a sheet that does not compile is refused at its import, once', async () => {
|
|
206
225
|
const imports = "import styles from './broken.module.scss';";
|
|
207
|
-
|
|
226
|
+
const findings = await check('export const Page = () => <h1 class={styles.any} />;', imports);
|
|
227
|
+
expect(findings.map((finding) => finding.at)).toEqual(['apps/web/site/page.tsx:1']);
|
|
228
|
+
expect(findings[0]?.cause).toContain('apps/web/site/broken.module.scss, which does not compile');
|
|
229
|
+
// With the compiler's line to give, the finding quotes it.
|
|
230
|
+
const quoted = await undefinedStyleClasses(
|
|
231
|
+
page('export const Page = () => <h1 class={styles.any} />;'),
|
|
232
|
+
async () => ({ error: 'Error: expected "}".' }),
|
|
233
|
+
);
|
|
234
|
+
expect(quoted[0]?.cause).toContain('which does not compile: Error: expected "}".');
|
|
208
235
|
});
|
|
209
236
|
`;
|
|
210
237
|
|
|
@@ -108,16 +108,17 @@ export const guard: Guard = {
|
|
|
108
108
|
const files: SourceFile[] = [];
|
|
109
109
|
// Every rendered surface: an app's \`site/\` and \`app/\`, and the shared components under
|
|
110
110
|
// \`packages/*/src\` — \`x new\` scaffolds a \`packages/ui\` whose components render to a user, so
|
|
111
|
-
// a hardcoded string there used to be green. \`
|
|
112
|
-
//
|
|
111
|
+
// a hardcoded string there used to be green. \`shared/\` holds the components both surfaces
|
|
112
|
+
// import, so it renders too; \`api/\` renders nothing; \`packages/*/dist\` is a build output.
|
|
113
113
|
//
|
|
114
114
|
// TWO globs, and the rule is that a brace ALTERNATIVE may not contain a \`/\`. Measured on Bun
|
|
115
115
|
// 1.4.0 against \`examples/dummy\`: \`{apps/*/{site,app},packages/*/src}/**/*.tsx\` and
|
|
116
116
|
// \`{apps/web,packages/ui}/**/*.tsx\` each match ZERO files, where \`apps/*/{site,app}/**/*.tsx\`
|
|
117
117
|
// matches 17 — so folding these into one line silently turns the guard off, which is worse than
|
|
118
118
|
// the hole it closes. A LEADING group is fine and the stylesheet guards here rely on it:
|
|
119
|
-
// \`{apps,packages}/**/*.scss\` matches all 15.
|
|
120
|
-
|
|
119
|
+
// \`{apps,packages}/**/*.scss\` matches all 15. \`shared/\` is read too: a component there renders
|
|
120
|
+
// on every page that imports it, and leaving it out was a directory the rule never saw.
|
|
121
|
+
for (const pattern of ['apps/*/{site,app,shared}/**/*.tsx', 'packages/*/src/**/*.tsx']) {
|
|
121
122
|
// The run's ONE read: every guard asking for these two globs shares the walk.
|
|
122
123
|
for (const file of await sources.files(pattern)) {
|
|
123
124
|
if (/\\.test\\.tsx?$/.test(file.path)) continue;
|
|
@@ -40,6 +40,9 @@ const FORMATTER =
|
|
|
40
40
|
*/
|
|
41
41
|
const ZONED = /\\btimeZone\\s*[:,}]|(['"])timeZone\\1\\s*:/;
|
|
42
42
|
|
|
43
|
+
/** What follows a formatter's \`)\` when it only reports its options — the host zone among them. */
|
|
44
|
+
const RESOLVED = /^\\s*\\.\\s*resolvedOptions\\s*\\(/;
|
|
45
|
+
|
|
43
46
|
/**
|
|
44
47
|
* The zoned call that replaces a formatter with no zone option. A \`Map\`, not an object: an
|
|
45
48
|
* object literal's prototype answers \`toLocaleString\`, and the bare call would read as one.
|
|
@@ -93,7 +96,11 @@ export function unzonedDates(files: readonly SourceFile[]): readonly Finding[] {
|
|
|
93
96
|
const text = blank(file.source);
|
|
94
97
|
for (const match of text.matchAll(FORMATTER)) {
|
|
95
98
|
const open = match.index + match[0].length - 1;
|
|
96
|
-
|
|
99
|
+
const args = argumentsOf(text, open);
|
|
100
|
+
if (ZONED.test(args)) continue;
|
|
101
|
+
// \`Intl.DateTimeFormat().resolvedOptions()\` READS the host's zone and formats nothing: it is
|
|
102
|
+
// how a browser learns which zone to pass. Only a formatter that goes on to format is a date.
|
|
103
|
+
if (RESOLVED.test(text.slice(open + args.length + 2))) continue;
|
|
97
104
|
const line = lineOf(text, match.index);
|
|
98
105
|
// The bare \`.toLocaleString(\` is ALSO \`Number.prototype.toLocaleString\`, and a regex cannot
|
|
99
106
|
// tell a count from a date. The match stands — a date formatted this way is the defect this
|
|
@@ -193,6 +200,12 @@ unitTest('toDateString and toTimeString name the zoned call', () => {
|
|
|
193
200
|
expect(time[0]?.fix).toContain('toLocaleTimeString(locale');
|
|
194
201
|
});
|
|
195
202
|
|
|
203
|
+
unitTest('reading the host zone through resolvedOptions() formats no date', () => {
|
|
204
|
+
const read = 'const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;';
|
|
205
|
+
expect(unzonedDates(file(read))).toEqual([]);
|
|
206
|
+
expect(unzonedDates(file("Intl.DateTimeFormat('en').formatToParts(at);"))).toHaveLength(1);
|
|
207
|
+
});
|
|
208
|
+
|
|
196
209
|
unitTest('a commented-out call is a note, not a call', () => {
|
|
197
210
|
expect(unzonedDates(file("// at.toLocaleDateString('en-US');"))).toEqual([]);
|
|
198
211
|
});
|
|
@@ -100,7 +100,7 @@ renders. A change outside that set is a collision — report it, do not make it.
|
|
|
100
100
|
| Generate, then edit | \`bunx x g <kind> <name> --feature <slice>\` for every one of them — a hand-written primitive is missing from every registry that projects it |
|
|
101
101
|
| One authz object | the policy decides; a route or a UI that re-checks is a second answer that will drift |
|
|
102
102
|
| Data through the repo | an action calls \`repo.ts\`, never the database |
|
|
103
|
-
| Errors are instructions | never \`throw new Error\` — declare each code once with \`defineError({ code, title, status, cause, fix })\` from \`@ultimat3/core\`: a stable \`X_SCREAMING_SNAKE\` code, a cause and a \`fix:\` a caller can actually run. \`guards/error-declared.ts\` refuses a handwritten \`UltimateError\` subclass |
|
|
103
|
+
| Errors are instructions | never \`throw new Error\` — declare each code once with \`defineError({ code, title, status, cause, fix })\` from \`@ultimat3/core/page\`: a stable \`X_SCREAMING_SNAKE\` code, a cause and a \`fix:\` a caller can actually run. \`guards/error-declared.ts\` refuses a handwritten \`UltimateError\` subclass |
|
|
104
104
|
| Jobs run at least once | a handler must be idempotent — an upsert or a statement whose second run changes nothing, never \`count + 1\` |
|
|
105
105
|
| Tasks name a time zone | a cron schedule with an ambient zone is a different time twice a year |
|
|
106
106
|
| No \`any\` | \`unknown\` plus a schema parse |
|
|
@@ -105,7 +105,7 @@ While you iterate, narrow the *feedback*, not the gate:
|
|
|
105
105
|
|
|
106
106
|
## 5. Hard rules
|
|
107
107
|
|
|
108
|
-
Never a bare \`throw new Error\` — declare each code once with \`defineError\` from \`@ultimat3/core\`:
|
|
108
|
+
Never a bare \`throw new Error\` — declare each code once with \`defineError\` from \`@ultimat3/core/page\`:
|
|
109
109
|
a stable code, a title, a status, a cause and a runnable \`fix:\`.
|
|
110
110
|
No \`any\`; use \`unknown\` and parse. Named exports only. \`import type\` for types.
|
|
111
111
|
Tests next to the source as \`<file>.test.ts\`, failure case first — a test that cannot fail is not a
|
|
@@ -47,7 +47,7 @@ queries, jobs, MCP tools, published operations and tests it touches, each with p
|
|
|
47
47
|
| Vendors | a server \`fetch(\` carries a \`signal\` in its own options — better, it is \`outbound()\` from \`@ultimat3/core/outbound\`: a deadline, the caller's signal, safe-only retry | \`guards/raw-fetch.ts\` |
|
|
48
48
|
| Polling | an island re-reads on a timer with \`visibleInterval(run, ms)\` from \`@ultimat3/core/page\` — no call while the tab is hidden, none after a lost session — never a bare \`setInterval(\`; a \`// why:\` on the line admits a tick that is not a read | \`guards/raw-interval.ts\` |
|
|
49
49
|
| Confirmation | a destructive act asks through \`ConfirmDialog\` from \`@ultimat3/ui\` — Cancel focused, a native post, stays open on a refusal — never \`confirm(\`; a \`// why:\` on the line admits a call that is not that question | \`guards/native-confirm.ts\` |
|
|
50
|
-
| Errors | never \`throw new Error\` — declare each code once, \`defineError({ code, title, status, cause, fix })\` from \`@ultimat3/core\`, and throw its class; never a handwritten \`UltimateError\` subclass | \`guards/bare-error.ts\`, \`guards/error-declared.ts\` |
|
|
50
|
+
| Errors | never \`throw new Error\` — declare each code once, \`defineError({ code, title, status, cause, fix })\` from \`@ultimat3/core/page\`, and throw its class; never a handwritten \`UltimateError\` subclass | \`guards/bare-error.ts\`, \`guards/error-declared.ts\` |
|
|
51
51
|
| Money | \`{ minor, currency }\`, never a float — \`money()\` on the column | the type: \`price: 19.99\` is TS2322, \`number\` is not \`MoneyInput\` |
|
|
52
52
|
| Time | store UTC, format with an explicit IANA time zone | \`guards/unzoned-date.ts\` |
|
|
53
53
|
| Strings | every user-facing string goes through \`t()\` | \`guards/untranslated-string.ts\` |
|
|
@@ -18,7 +18,7 @@ const domainIndex = (
|
|
|
18
18
|
): string => `// Pure types and constants. No I/O of any kind: no fs, no network, no database, no env reads.
|
|
19
19
|
// \`Money\` is @ultimat3/schema's, re-exported and never restated: one declaration of
|
|
20
20
|
// { minor, currency } is what makes an entity column, a form field and this module the same type.
|
|
21
|
-
import { defineError } from '@ultimat3/core';
|
|
21
|
+
import { defineError } from '@ultimat3/core/page';
|
|
22
22
|
import type { MoneyValue as Money } from '@ultimat3/schema';
|
|
23
23
|
|
|
24
24
|
export type { MoneyValue as Money } from '@ultimat3/schema';
|
|
@@ -38,7 +38,7 @@ const errorsSource = (feature: NameSet): string => {
|
|
|
38
38
|
return `// The ${feature.kebab} feature's X_* codes. Never throw a bare Error: an agent reading the failure
|
|
39
39
|
// needs the code, the cause and the exact command that fixes it.
|
|
40
40
|
|
|
41
|
-
import { defineError } from '@ultimat3/core';
|
|
41
|
+
import { defineError } from '@ultimat3/core/page';
|
|
42
42
|
|
|
43
43
|
// One declaration: the title, the 404 a response answers, and the class a service throws. No
|
|
44
44
|
// \`docs:\` — it resolves from the code's registered descriptor, so the link has one home.
|
package/wiki/Actions.md
CHANGED
|
@@ -249,11 +249,12 @@ X_ACTION_POLICY_MISSING: action registered without a policy
|
|
|
249
249
|
|
|
250
250
|
Every code carries the same `{ code, cause, fix, docs }` in the terminal, the dev overlay, the HTTP body, `--json`, and the MCP tool error. Full list: [Error codes](Error-Codes).
|
|
251
251
|
|
|
252
|
-
A handler's OWN refusals are app codes, each declared once with `defineError` from
|
|
252
|
+
A handler's OWN refusals are app codes, each declared once with `defineError` from
|
|
253
|
+
`@ultimat3/core/page` (the barrel carries the framework's titles into every island that throws one)
|
|
253
254
|
— the title, the status the HTTP projection answers and the class `handle` throws:
|
|
254
255
|
|
|
255
256
|
```ts
|
|
256
|
-
import { defineError } from '@ultimat3/core';
|
|
257
|
+
import { defineError } from '@ultimat3/core/page';
|
|
257
258
|
|
|
258
259
|
export const PostNotFound = defineError<string>({
|
|
259
260
|
code: 'X_POST_NOT_FOUND',
|
package/wiki/Agents.md
CHANGED
|
@@ -195,7 +195,7 @@ No new run outcome and no deferred tool. The call is a `tool_result` flagged `is
|
|
|
195
195
|
|
|
196
196
|
```ts
|
|
197
197
|
import { inProcessTool } from '@ultimat3/ai';
|
|
198
|
-
import { defineError } from '@ultimat3/core';
|
|
198
|
+
import { defineError } from '@ultimat3/core/page';
|
|
199
199
|
import { t } from '@ultimat3/schema';
|
|
200
200
|
|
|
201
201
|
declare function loadDoc(id: string): Promise<{ id: string; body: string } | undefined>;
|
|
@@ -130,7 +130,7 @@ Both will bite. Both are the app's job, one line each.
|
|
|
130
130
|
|
|
131
131
|
A primitive is wrapped; an error code is not. Declare each code at its own call site with
|
|
132
132
|
`defineError({ code: 'X_INVOICE_NOT_FOUND', title, status: 404, cause, fix })` from
|
|
133
|
-
`@ultimat3/core` — the title, the HTTP status and the class in one call. The `errors` step and the
|
|
133
|
+
`@ultimat3/core/page` — the title, the HTTP status and the class in one call. The `errors` step and the
|
|
134
134
|
manifest read the `code:` literal where it is written, so a factory that takes the code as a
|
|
135
135
|
parameter hides it (`X_ERROR_CODE_UNRESOLVED`). A family of codes is a prefix (`X_BILLING_*`),
|
|
136
136
|
never a base class: `guards/error-declared.ts` refuses `extends UltimateError`, and
|
package/wiki/Interface-Rules.md
CHANGED
|
@@ -245,7 +245,7 @@ them: [Testing](Testing#seeing-what-you-built).
|
|
|
245
245
|
|
|
246
246
|
## Stylesheets
|
|
247
247
|
|
|
248
|
-
Biome does not read `.scss`. These seven guards are the only thing that does. `As of 2026-
|
|
248
|
+
Biome does not read `.scss`. These seven guards are the only thing that does. `As of 2026-11`.
|
|
249
249
|
|
|
250
250
|
| Rule | Refused by | The `fix:` it names |
|
|
251
251
|
|---|---|---|
|
|
@@ -253,9 +253,10 @@ Biome does not read `.scss`. These seven guards are the only thing that does. `A
|
|
|
253
253
|
| A viewport query names a rung of the one ladder | `guards/raw-breakpoint.ts` — `@media` with a `width` feature | `@include tokens.respond-to(md)` / `respond-down(md)` / `respond-between(md, lg)` |
|
|
254
254
|
| A layer is a name | `guards/raw-z-index.ts` — a number in `z-index` | `z-index: tokens.z(dropdown)`; behind its own stacking context, `calc(-1 * #{tokens.z(raised)})` |
|
|
255
255
|
| Elevation comes off the themed shadow scale | `guards/raw-shadow.ts` — a hand-written length in `box-shadow`, `text-shadow` or `drop-shadow()` | `box-shadow: tokens.shadow('sm')`, or `@include tokens.surface` |
|
|
256
|
-
| One tempo | `guards/raw-motion.ts` — a duration or `cubic-bezier()` literal in `transition*` / `animation
|
|
256
|
+
| One tempo | `guards/raw-motion.ts` — a duration or `cubic-bezier()` literal in `transition*` / `animation*`, or assigned to a custom property (`--ease: cubic-bezier(…)`) | `transition: opacity tokens.duration(fast) tokens.easing(out)`; in a custom property, interpolated: `--ease: #{tokens.easing(out)}` |
|
|
257
257
|
| A class a component reads is a class its sheet compiles | `guards/undefined-style-class.ts` — `styles.x` / `styles['x-y']` against the COMPILED `.module.scss` | the nearest class the sheet declares, or the rule to add |
|
|
258
258
|
| A custom property a sheet reads is one the app declares | `guards/undeclared-custom-property.ts` — `var(--x)` in the compiled CSS with no declaration anywhere and no fallback | the steps the scale really has: `tokens.space(7)` → `0 \| 1 \| 2 \| …` |
|
|
259
|
+
| A guard that reads compiled sheets never passes by reading nothing | `guards/undeclared-custom-property.ts` and `guards/undefined-style-class.ts` — a sheet that does not compile, or an imported one that does not exist, is a finding quoting the compiler's first line; while one is broken, no `var()` read is judged | repair the Sass at the error quoted |
|
|
259
260
|
|
|
260
261
|
| Not a finding | Why |
|
|
261
262
|
|---|---|
|
|
@@ -266,7 +267,6 @@ Biome does not read `.scss`. These seven guards are the only thing that does. `A
|
|
|
266
267
|
| `linear`, `ease`, `0s`, `calc(#{tokens.duration(slower)} * 2)` | a keyword, a zero, a multiple of a token |
|
|
267
268
|
| `styles[name]` | a computed key is only known when the component runs |
|
|
268
269
|
| `var(--x, fallback)`; a property a `.ts`/`.tsx` file names | it declares its own answer; an inline `style` sets it |
|
|
269
|
-
| a sheet that does not compile | the build's refusal (`X_PRERENDER_FAILED`), not a guard's |
|
|
270
270
|
|
|
271
271
|
## Data access
|
|
272
272
|
|
package/wiki/MCP-And-AI.md
CHANGED
|
@@ -241,7 +241,7 @@ verdict a production problem document gives. The developer audience keeps both.
|
|
|
241
241
|
same two fields, plus `docs` — declared once with `defineError`:
|
|
242
242
|
|
|
243
243
|
```ts
|
|
244
|
-
import { defineError } from '@ultimat3/core';
|
|
244
|
+
import { defineError } from '@ultimat3/core/page';
|
|
245
245
|
|
|
246
246
|
export const RefundWindowClosed = defineError<{ readonly ageDays: number }>({
|
|
247
247
|
code: 'X_REFUND_WINDOW_CLOSED',
|
package/wiki/Upgrading.md
CHANGED
|
@@ -197,6 +197,7 @@ A setter still on a package's `.` barrel is `X_ADAPTER_PORT_INCOMPLETE` on the `
|
|
|
197
197
|
| `x exercise` reports `X_AUDIT_SINK_MISSING` (`X_QUERY_AUDIT_SINK_MISSING` for a query) on every `audit: true` primitive, and `x build` lists each page whose render runs one under `unmeasured`: entry 43 moved `auditSink` into `runtime.ts`, and neither pass installs `runtime.ts` | fixed in **31.2.0**: both read `apps/<app>/runtime.ts` through the boot's own loader, a memory sink standing in for the declared one so neither writes to it. On 31.0.0–31.1.0, install a memory sink at the top of `apps/web/exercise.ts` and `apps/web/prerender.ts` — `installAuditSink(memoryAuditSink())`, `installAuditSink` from `@ultimat3/core/adapter`, `memoryAuditSink` from `@ultimat3/action`; on 31.2.0, delete it |
|
|
198
198
|
| `defineFactory` (`@ultimat3/testing`, entry 40) widens a string literal in `defaults` or a trait to `string`, so an `enumerated([…])` column is TS2322 — `Type 'string' is not assignable to type '"closed" \| "open"'` | `'open' as const` on the literal. Fixed in **31.2.0**: from it, an `as const` or per-literal annotation added for this TS2322 can be deleted — kept, it is harmless |
|
|
199
199
|
| `disk('<name>')` is `X_STORAGE_DISK_UNKNOWN` for a disk your own `defineStorage({ disks: { … } })` declares, when an app module reached from `runtime.ts` makes that call: the boot installed its one-disk registry over it | fixed in **31.2.0**: the boot keeps a registry the app declared, and the app's `defineStorage()` wins over `runtime.storage`. Upgrade to it; no workaround is verified for 31.0.0–31.1.0 |
|
|
200
|
+
| `x g guard error-declared --force` (or a new `x new`) writes a guard that refuses `defineError` imported from `@ultimat3/core`, `X_ERROR_DECLARED` at the import line (`As of 2026-11`): through the barrel every island that throws an app code carried both framework titles tables, 12,019 B against 6,507 B for one declaration thrown | `import { defineError } from '@ultimat3/core/page'` — the same function. A `/* @__PURE__ */` or `"sideEffects": false` added to keep the table out is no longer needed for that |
|
|
200
201
|
|
|
201
202
|
## 29.x → 30.0.0, entry by entry
|
|
202
203
|
|