@wcstack/lint 4.6.2 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/cli.cjs +76 -19
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -89,7 +89,7 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
|
|
|
89
89
|
|
|
90
90
|
- **発見**: HTML ファイルから上へ辿って最も近い `wcstack.manifest.json` が自動で使われます — コマンドラインに渡す必要はありません。`application` artifact を含む `*.manifest.json` を引数に渡した場合は、その実行全体で発見を置き換えます。VS Code 拡張も同じファイルを発見するので IDE と CLI の結果は一致します。
|
|
91
91
|
- **効果**: `stateSchema` を宣言すると、schema 上に確定的に存在しないバインドパスは `wcs/path-nonexistent`(**error**・exit `1`)、`for:` に非配列は `wcs/path-type-mismatch`(**error**)になります。schema が開いたままの箇所(素の `{}`)は沈黙し、インラインスクリプトのメソッド / getter / `$listKeys` は引き続き存在扱いです。`stateSchema` が無ければ従来どおりです。
|
|
92
|
-
- **契約が要るとき**: validator が全体を読めない state は、契約が無いとパスをまったく検査できません。よくあるのはトップレベルの spread です — `export default { ...defaults(), get total() { … } }` は静的には見えないキーを持ち込むので、その state のパスは検査しません。4.4 から、spread の上で 1 回だけそう言います(`wcs/path-dynamic-unknown`、info)。`stateSchema` があれば束縛を —— 4.4 から getter の中で読むパス(`wcs/read-path-missing`)も ——
|
|
92
|
+
- **契約が要るとき**: validator が全体を読めない state は、契約が無いとパスをまったく検査できません。よくあるのはトップレベルの spread です — `export default { ...defaults(), get total() { … } }` は静的には見えないキーを持ち込むので、その state のパスは検査しません。4.4 から、spread の上で 1 回だけそう言います(`wcs/path-dynamic-unknown`、info)。`stateSchema` があれば束縛を —— 4.4 から getter の中で読むパス(`wcs/read-path-missing`)も —— それで検査します。読めない `<wcs-state src>` — / から始まるパス・URL・無いファイル — の state も検査できません。4.7 から、それを属性の上で 1 回だけ言います(`wcs/state-src-unread`、info)。4.6 までは何も言いませんでした。`src` はページからの相対パスで読むので、ファイルはサーバーと同じ並びに置いてください。
|
|
93
93
|
- **schema の出どころ**: 手で書く(受け付けるのは JSON-Schema サブセット `type / properties / required / items / enum / const / anyOf / $defs / $ref` のみ)か、TypeScript の state ファイル(または JSDoc で型を付けた JavaScript のファイル)から `wcs-schema`(`@wcstack/typescript`)で生成します。manifest は派生物なので、CI では `wcs-schema check` で同期を保ってください。
|
|
94
94
|
|
|
95
95
|
## 生成 → 検証 → 修正ループでの利用
|
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ Without a contract, a path the validator cannot resolve is only a **warning** (`
|
|
|
89
89
|
|
|
90
90
|
- **Discovery**: the nearest `wcstack.manifest.json` walking up from the HTML file is used automatically — nothing to pass on the command line. Passing `*.manifest.json` arguments that contain an `application` artifact replaces discovery for the whole run. The VS Code extension discovers the same file, so IDE and CLI agree.
|
|
91
91
|
- **Effect**: when a `stateSchema` is declared, a bound path that the schema definitely lacks is `wcs/path-nonexistent` (**error**, exit `1`); `for:` on a non-array is `wcs/path-type-mismatch` (**error**). Paths the schema leaves open (a bare `{}`) stay silent, and methods / getters / `$listKeys` from the inline script still count as existing. Without a `stateSchema`, behavior is unchanged.
|
|
92
|
-
- **When a contract is needed**: a state the validator cannot read in full needs one for its paths to be checked at all. A top-level spread is the common case — `export default { ...defaults(), get total() { … } }` brings in keys no static reader sees, so the validator checks no path of that state, and since 4.4 it says so once, at the spread (`wcs/path-dynamic-unknown`, info). With a `stateSchema` the bindings — and, since 4.4, the paths the getters read (`wcs/read-path-missing`) — are checked against it.
|
|
92
|
+
- **When a contract is needed**: a state the validator cannot read in full needs one for its paths to be checked at all. A top-level spread is the common case — `export default { ...defaults(), get total() { … } }` brings in keys no static reader sees, so the validator checks no path of that state, and since 4.4 it says so once, at the spread (`wcs/path-dynamic-unknown`, info). With a `stateSchema` the bindings — and, since 4.4, the paths the getters read (`wcs/read-path-missing`) — are checked against it. A `<wcs-state src>` it cannot read — a path from `/`, a URL, a file that is not there — leaves that state unchecked as well; since 4.7 it says so once, at the attribute (`wcs/state-src-unread`, info), where up to 4.6 it said nothing. It reads a `src` relative to the page: keep the files laid out as on the server.
|
|
93
93
|
- **Where the schema comes from**: write it by hand (only the JSON-Schema subset `type / properties / required / items / enum / const / anyOf / $defs / $ref` is accepted), or generate it from a TypeScript state file — or a JavaScript one with JSDoc types — with `wcs-schema` (`@wcstack/typescript`). The manifest is a derived artifact — keep it in sync with `wcs-schema check` in CI.
|
|
94
94
|
|
|
95
95
|
## Use in generate–validate–fix loops
|
package/dist/cli.cjs
CHANGED
|
@@ -89,6 +89,9 @@ var WcsDiagnosticCode = {
|
|
|
89
89
|
// lint の限界の告知(作者の誤りではない): `export default { … }` のトップレベルの spread が持ち込むキーは読めないので、
|
|
90
90
|
// stateSchema の無い state のパスは検査しない — それを spread の上で 1 回だけ言う。info。
|
|
91
91
|
PathDynamicUnknown: "wcs/path-dynamic-unknown",
|
|
92
|
+
// lint の限界の告知(作者の誤りではない): 読めない `<wcs-state src>`(/ から始まるパス・URL・無いファイル)の state は
|
|
93
|
+
// パスもスクリプトの規則も検査しない — それを src の上で 1 回だけ言う。info(docs/seam-apps.md、prod-booking)。
|
|
94
|
+
StateSrcUnread: "wcs/state-src-unread",
|
|
92
95
|
// --- existing binding-expression validators (retrofitted) ---
|
|
93
96
|
FilterUnknown: "wcs/filter-unknown",
|
|
94
97
|
FilterArity: "wcs/filter-arity",
|
|
@@ -2179,11 +2182,11 @@ var registered = {
|
|
|
2179
2182
|
percent: { factory: percent, arity: [0, 1] },
|
|
2180
2183
|
unit: { factory: nullishPassthrough(unit), arity: [1, 1] },
|
|
2181
2184
|
// The locale-dependent three take a locale like `locale` does (`date(ja-JP)`), and a style (`date(ja-JP,long)`)
|
|
2182
|
-
date: { factory: date, arity: [0, 2] },
|
|
2183
|
-
time: { factory: time, arity: [0, 2] },
|
|
2184
|
-
datetime: { factory: datetime, arity: [0, 2] },
|
|
2185
|
-
ymd: { factory: ymd, arity: [0, 1] },
|
|
2186
|
-
hms: { factory: hms, arity: [0, 1] },
|
|
2185
|
+
date: { factory: nullishPassthrough(date), arity: [0, 2] },
|
|
2186
|
+
time: { factory: nullishPassthrough(time), arity: [0, 2] },
|
|
2187
|
+
datetime: { factory: nullishPassthrough(datetime), arity: [0, 2] },
|
|
2188
|
+
ymd: { factory: nullishPassthrough(ymd), arity: [0, 1] },
|
|
2189
|
+
hms: { factory: nullishPassthrough(hms), arity: [0, 1] },
|
|
2187
2190
|
// the core set of 4.0.0-rc.3 (the core's own: eq ne not lt le gt ge falsy truthy boolean)
|
|
2188
2191
|
eq: eq2,
|
|
2189
2192
|
ne: ne2,
|
|
@@ -2595,7 +2598,7 @@ function tokenize(text3) {
|
|
|
2595
2598
|
i += 2;
|
|
2596
2599
|
continue;
|
|
2597
2600
|
}
|
|
2598
|
-
if ("{}[]<>()
|
|
2601
|
+
if ("{}[]<>()|&,;:?!*.=".includes(ch)) {
|
|
2599
2602
|
tokens.push({ t: "punct", v: ch });
|
|
2600
2603
|
i++;
|
|
2601
2604
|
continue;
|
|
@@ -2644,6 +2647,7 @@ function parseJsDocType(text3) {
|
|
|
2644
2647
|
const member = parsePostfix();
|
|
2645
2648
|
if (member === null) return null;
|
|
2646
2649
|
members.push(member);
|
|
2650
|
+
if (expect("&")) continue;
|
|
2647
2651
|
if (!expect("|")) break;
|
|
2648
2652
|
}
|
|
2649
2653
|
if (isPunct("=>")) {
|
|
@@ -2807,12 +2811,21 @@ function readBracedType(comment, tag) {
|
|
|
2807
2811
|
return null;
|
|
2808
2812
|
}
|
|
2809
2813
|
function readJsDocTypeBefore(content, propIndex) {
|
|
2814
|
+
const comment = jsDocCommentBefore(content, propIndex);
|
|
2815
|
+
return comment === void 0 ? void 0 : readBracedType(comment, "type")?.type.trim();
|
|
2816
|
+
}
|
|
2817
|
+
function readJsDocReturnsBefore(content, propIndex) {
|
|
2818
|
+
const comment = jsDocCommentBefore(content, propIndex);
|
|
2819
|
+
if (comment === void 0) return void 0;
|
|
2820
|
+
return (readBracedType(comment, "returns") ?? readBracedType(comment, "return"))?.type.trim();
|
|
2821
|
+
}
|
|
2822
|
+
function jsDocCommentBefore(content, propIndex) {
|
|
2810
2823
|
let end = propIndex;
|
|
2811
2824
|
while (end > 0 && /\s/.test(content[end - 1])) end--;
|
|
2812
2825
|
if (!content.startsWith("*/", end - 2)) return void 0;
|
|
2813
2826
|
const start = content.lastIndexOf("/*", end - 2);
|
|
2814
2827
|
if (start === -1 || content[start + 2] !== "*") return void 0;
|
|
2815
|
-
return
|
|
2828
|
+
return content.slice(start, end);
|
|
2816
2829
|
}
|
|
2817
2830
|
function collectJsDocTypedefs(script, scan) {
|
|
2818
2831
|
const typedefs = /* @__PURE__ */ new Map();
|
|
@@ -2899,6 +2912,7 @@ function analyzeStatePaths(scriptContent) {
|
|
|
2899
2912
|
const settable = !recursive && effective !== "data" && effective.set;
|
|
2900
2913
|
paths.push({ path: prop.name, kind: recursive ? "recursive" : "computed", ...settable ? { settable } : {} });
|
|
2901
2914
|
}
|
|
2915
|
+
if (prop.declaredType !== void 0) pushDeclaredShapePaths(prop.name, prop.declaredType, paths, 0, typedefs);
|
|
2902
2916
|
continue;
|
|
2903
2917
|
}
|
|
2904
2918
|
pushDataPropertyPaths(prop, paths, typedefs);
|
|
@@ -3408,11 +3422,21 @@ function expressionShape(text3, paths, aliases) {
|
|
|
3408
3422
|
if (scan.startsWith("[")) {
|
|
3409
3423
|
const inner = extractDelimitedContent(expr, scan, 0, "[", "]");
|
|
3410
3424
|
rest = inner.length + 2;
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3425
|
+
if (inner.trim() === "") {
|
|
3426
|
+
shape = EMPTY_LIST;
|
|
3427
|
+
} else {
|
|
3428
|
+
const spread = /^\s*\.\.\.([\s\S]+)$/.exec(inner);
|
|
3429
|
+
if (spread === null || splitTopLevelElements(inner).length !== 1) return null;
|
|
3430
|
+
const source = expressionShape(spread[1], paths, aliases);
|
|
3431
|
+
if (source === null || !source.isList) return null;
|
|
3432
|
+
shape = source;
|
|
3433
|
+
}
|
|
3434
|
+
} else if (scan.startsWith("(")) {
|
|
3435
|
+
const inner = extractDelimitedContent(expr, scan, 0, "(", ")");
|
|
3436
|
+
const base = expressionShape(inner, paths, aliases);
|
|
3437
|
+
if (base === null) return null;
|
|
3438
|
+
shape = base;
|
|
3439
|
+
rest = inner.length + 2;
|
|
3416
3440
|
} else {
|
|
3417
3441
|
const base = readBase(expr, scan, aliases, paths);
|
|
3418
3442
|
if (base === null) return null;
|
|
@@ -3486,8 +3510,7 @@ function applyChain(expr, scan, start, initial) {
|
|
|
3486
3510
|
if (!shape.isList) return null;
|
|
3487
3511
|
shape = pickRow(shape);
|
|
3488
3512
|
} else if (method === "map") {
|
|
3489
|
-
|
|
3490
|
-
const mapped = mapRows(args, shape);
|
|
3513
|
+
const mapped = mapRows(args, shape.isList ? shape : OPAQUE);
|
|
3491
3514
|
if (mapped === null) return null;
|
|
3492
3515
|
shape = mapped;
|
|
3493
3516
|
} else {
|
|
@@ -3497,6 +3520,7 @@ function applyChain(expr, scan, start, initial) {
|
|
|
3497
3520
|
return shape.opaque ? null : shape;
|
|
3498
3521
|
}
|
|
3499
3522
|
var OPAQUE = { isList: true, mirrors: [], fields: [], opaque: true };
|
|
3523
|
+
var EMPTY_LIST = { isList: true, mirrors: [], fields: [] };
|
|
3500
3524
|
function pickRow(shape) {
|
|
3501
3525
|
return {
|
|
3502
3526
|
isList: false,
|
|
@@ -3766,7 +3790,12 @@ function extractDefaultExportObject(script) {
|
|
|
3766
3790
|
function parseTopLevelProperties(objectContent, allowEmptyDataKeys = false) {
|
|
3767
3791
|
const props = [];
|
|
3768
3792
|
const scan = maskCommentsAndStrings(objectContent);
|
|
3769
|
-
const
|
|
3793
|
+
const params = String.raw`\((?:[^()]|\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\))*\)`;
|
|
3794
|
+
const dataKey = allowEmptyDataKeys ? String.raw`(?:"([^"]*)"|'([^']*)'|([$\w]+))` : String.raw`(?:"([^"]+)"|'([^']+)'|([$\w]+))`;
|
|
3795
|
+
const regex = new RegExp(
|
|
3796
|
+
String.raw`(?:(?:get|set)\s+(?:"([^"]+)"|'([^']+)'|([$\w]+))\s*${params}\s*\{)|(?:(?:async\s+)?(?:"([^"]+)"|'([^']+)'|([$\w]+))\s*${params}\s*\{)|(?:${dataKey}\s*:\s*)`,
|
|
3797
|
+
"gd"
|
|
3798
|
+
);
|
|
3770
3799
|
let match;
|
|
3771
3800
|
while ((match = regex.exec(scan)) !== null) {
|
|
3772
3801
|
const indices = match.indices;
|
|
@@ -3787,6 +3816,8 @@ function parseTopLevelProperties(objectContent, allowEmptyDataKeys = false) {
|
|
|
3787
3816
|
if (accessorName) {
|
|
3788
3817
|
const { body, bodyStart } = skipBody();
|
|
3789
3818
|
const accessor = match[0].startsWith("set") ? "set" : "get";
|
|
3819
|
+
const returnsText = accessor === "get" ? readJsDocReturnsBefore(objectContent, match.index) : void 0;
|
|
3820
|
+
const declaredType = returnsText === void 0 ? null : parseJsDocType(returnsText);
|
|
3790
3821
|
props.push({
|
|
3791
3822
|
name: accessorName,
|
|
3792
3823
|
kind: "getter",
|
|
@@ -3794,7 +3825,8 @@ function parseTopLevelProperties(objectContent, allowEmptyDataKeys = false) {
|
|
|
3794
3825
|
value: body,
|
|
3795
3826
|
valueStart: bodyStart,
|
|
3796
3827
|
nameStart: nameSpan[0],
|
|
3797
|
-
nameEnd: nameSpan[1]
|
|
3828
|
+
nameEnd: nameSpan[1],
|
|
3829
|
+
...declaredType !== null ? { declaredType } : {}
|
|
3798
3830
|
});
|
|
3799
3831
|
continue;
|
|
3800
3832
|
}
|
|
@@ -10944,6 +10976,7 @@ var ja = {
|
|
|
10944
10976
|
commandTokenUnbound: (t) => `\u30B3\u30DE\u30F3\u30C9\u30C8\u30FC\u30AF\u30F3 "${t}" \u3092 emit \u3057\u3066\u3044\u307E\u3059\u304C\u3001\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u305D\u308C\u3092\u53D7\u3051\u308B command.<\u30E1\u30BD\u30C3\u30C9>: ${t} \u306E\u675F\u7E1B\u304C\u3042\u308A\u307E\u305B\u3093\u3002emit \u306F\u8AB0\u306B\u3082\u5C4A\u304D\u307E\u305B\u3093\u3002\u30E1\u30BD\u30C3\u30C9\u3092\u547C\u3076\u8981\u7D20\u306B\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08command.focus: ${t}\uFF09`,
|
|
10945
10977
|
writePathMissing: (k) => `"${k}" \u306F state \u304C\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044\u30AD\u30FC\u3067\u3059\u3002\u66F8\u304D\u8FBC\u307F\u306F\u65B0\u3057\u3044\u30AD\u30FC\u3092\u4F5C\u308B\u3060\u3051\u3067\u3001\u5BA3\u8A00\u3057\u305F\u30AD\u30FC\u306E\u675F\u7E1B\u306B\u306F\u5C4A\u304D\u307E\u305B\u3093`,
|
|
10946
10978
|
readPathMissing: (p, top) => top ? `"${p}" \u306F state \u304C\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044\u30AD\u30FC\u3067\u3059\u3002\u8AAD\u3093\u3060\u6642\u70B9\u3067\u4F8B\u5916\u306B\u306A\u308A\u307E\u3059\uFF08#301\uFF09` : `\u30D1\u30B9 "${p}" \u306F\u72B6\u614B\u5B9A\u7FA9\u306B\u5B58\u5728\u3057\u307E\u305B\u3093\u3002\u8AAD\u307F\u306F undefined \u306B\u306A\u308A\u3001\u305D\u3053\u304B\u3089\u8A08\u7B97\u3057\u305F\u5024\u306F\u9ED9\u3063\u3066\u9055\u3044\u307E\u3059`,
|
|
10979
|
+
stateSrcUnread: (src) => `"${src}" \u3092\u8AAD\u3081\u306A\u3044\u306E\u3067\u3001\u3053\u306E state \u306E\u30D1\u30B9\u3082\u30B9\u30AF\u30EA\u30D7\u30C8\u306E\u898F\u5247\u3082\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\u3002src \u306F\u3053\u306E\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u306E\u76F8\u5BFE\u30D1\u30B9\u3067\u8AAD\u307F\u307E\u3059\uFF08/ \u304B\u3089\u59CB\u307E\u308B\u30D1\u30B9\u3068 URL \u306F\u8AAD\u307F\u307E\u305B\u3093\uFF09\u3002\u30B5\u30FC\u30D0\u30FC\u3068\u540C\u3058\u4E26\u3073\u306B\u7F6E\u3044\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u3001\u3053\u306E\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u306E\u76F8\u5BFE\u30D1\u30B9\u3067\u6307\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
10947
10980
|
pathDynamicUnknownSpread: (sp) => `${sp} \u304C\u6301\u3061\u8FBC\u3080\u30AD\u30FC\u306F\u9759\u7684\u306B\u8AAD\u3081\u306A\u3044\u306E\u3067\u3001\u3053\u306E state \u306E\u30D1\u30B9\u306F\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\uFF08\u675F\u7E1B\u30FBgetter \u306E\u4E2D\u306E\u8AAD\u307F\u30FB$watch \u306E\u30AD\u30FC\uFF09\u3002\u30AD\u30FC\u3092 wcstack.manifest.json \u306E stateSchema \u306B\u5BA3\u8A00\u3059\u308B\u3068\u691C\u67FB\u3055\u308C\u307E\u3059\u3002npx wcs-schema\uFF08@wcstack/typescript\uFF09\u304C state \u306E\u578B\uFF08JSDoc\u30FBTypeScript\uFF09\u304B\u3089\u4F5C\u308C\u307E\u3059`,
|
|
10948
10981
|
pathReadonlyTwoWay: (p, prop) => `"${p}" \u306F setter \u306E\u7121\u3044 getter \u3067\u3059\u304C\u3001${prop}: \u306F\u8AAD\u8005\u306E\u5165\u529B\u3092\u66F8\u304D\u623B\u3059\u306E\u3067\u3001\u5165\u529B\u306E\u305F\u3073\u306B\u66F8\u304D\u8FBC\u307F\u304C\u5931\u6557\u3057\u307E\u3059\uFF08"${p}" is a getter without a setter\uFF09\u3002setter \u3092\u8DB3\u3059\uFF08set "${p}"(v) { \u2026 }\uFF09\u304B\u3001#ro \u3067\u4E00\u65B9\u5411\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${prop}#ro: ${p}\uFF09`,
|
|
10949
10982
|
submitWithoutPrevent: (h) => `onsubmit \u306B #prevent \u304C\u7121\u304F\u3001"${h}" \u3082 preventDefault \u3092\u547C\u3073\u307E\u305B\u3093\u3002\u30D6\u30E9\u30A6\u30B6\u306F\u30D5\u30A9\u30FC\u30E0\u3082\u9001\u308B\u306E\u3067\u3001\u30DA\u30FC\u30B8\u304C\u8AAD\u307F\u76F4\u3055\u308C\u308B\u304B\u3001router \u304C\u3042\u308C\u3070 GET \u304C\u6B04\u306E\u5024\uFF08\u30D1\u30B9\u30EF\u30FC\u30C9\u3082\uFF09\u3092 URL \u3068\u5C65\u6B74\u306B\u8F09\u305B\u307E\u3059\u3002onsubmit#prevent: ${h} \u3068\u66F8\u304F\u304B\u3001\u30CF\u30F3\u30C9\u30E9\u3067 event.preventDefault() \u3092\u547C\u3093\u3067\u304F\u3060\u3055\u3044`,
|
|
@@ -11153,6 +11186,7 @@ var en = {
|
|
|
11153
11186
|
commandTokenUnbound: (t) => `The command token "${t}" is emitted, but no command.<method>: ${t} binding in this document receives it, so the emit reaches nothing. Bind it on the element whose method it should call (command.focus: ${t})`,
|
|
11154
11187
|
writePathMissing: (k) => `"${k}" is not a key the state declares. The write creates a new key and reaches no binding of a declared one`,
|
|
11155
11188
|
readPathMissing: (p, top) => top ? `"${p}" is not a key the state declares. Reading it throws (#301)` : `Path "${p}" does not exist in the state definition. The read gives undefined, and what is computed from it is wrong without a word`,
|
|
11189
|
+
stateSrcUnread: (src) => `"${src}" cannot be read, so this state's paths and script rules are not checked. A src is read relative to this file (a path from / or a URL is not read): point it at the file laid out as on the server, relative to this file`,
|
|
11156
11190
|
pathDynamicUnknownSpread: (sp) => `The keys ${sp} brings in cannot be read statically, so this state's paths are not checked (bindings, reads in getters, $watch keys). Declare the keys in the stateSchema of wcstack.manifest.json to have them checked; npx wcs-schema (@wcstack/typescript) derives it from the state's types (JSDoc or TypeScript)`,
|
|
11157
11191
|
pathReadonlyTwoWay: (p, prop) => `"${p}" is a getter without a setter, and ${prop}: writes back what the reader enters, so every edit fails ("${p}" is a getter without a setter). Add a setter (set "${p}"(v) { \u2026 }), or bind it one way with #ro (${prop}#ro: ${p})`,
|
|
11158
11192
|
submitWithoutPrevent: (h) => `onsubmit has no #prevent and "${h}" does not call preventDefault, so the browser submits the form too: the page reloads, or with the router a GET puts the fields (a password too) in the URL and the history. Write onsubmit#prevent: ${h}, or call event.preventDefault() in the handler`,
|
|
@@ -11666,7 +11700,7 @@ function forEachStateMethod(elements, html, fileReader, spelling, fn) {
|
|
|
11666
11700
|
for (const callable of analyzeCallableBodies(script)) {
|
|
11667
11701
|
if (callable.kind !== "method" || spelling !== null && !callable.body.includes(spelling)) continue;
|
|
11668
11702
|
const head = script.slice(callable.end, callable.bodyStart - 1);
|
|
11669
|
-
const params = /\(([
|
|
11703
|
+
const params = /\(([\s\S]*)\)\s*$/.exec(head);
|
|
11670
11704
|
if (params === null) continue;
|
|
11671
11705
|
fn(volume === null ? callable.name : `${volume}.${callable.name}`, params[1], callable.body);
|
|
11672
11706
|
}
|
|
@@ -14029,6 +14063,7 @@ var BUILTIN_TAGS = {
|
|
|
14029
14063
|
"withCredentials": "with-credentials",
|
|
14030
14064
|
"events": "events",
|
|
14031
14065
|
"raw": "raw",
|
|
14066
|
+
"staleAfter": "stale-after",
|
|
14032
14067
|
"manual": "manual",
|
|
14033
14068
|
"trigger": null
|
|
14034
14069
|
},
|
|
@@ -14219,6 +14254,7 @@ var BUILTIN_TAGS = {
|
|
|
14219
14254
|
"reconnectInterval": "reconnect-interval",
|
|
14220
14255
|
"maxReconnects": "max-reconnects",
|
|
14221
14256
|
"binaryType": "binary-type",
|
|
14257
|
+
"staleAfter": "stale-after",
|
|
14222
14258
|
"manual": "manual",
|
|
14223
14259
|
"trigger": null,
|
|
14224
14260
|
"send": null
|
|
@@ -16981,6 +17017,27 @@ function nearName(path, tree) {
|
|
|
16981
17017
|
return null;
|
|
16982
17018
|
}
|
|
16983
17019
|
|
|
17020
|
+
// src/service/stateSourceValidator.ts
|
|
17021
|
+
function validateStateSources(html, stateTagName = "wcs-state", locale2, fileReader) {
|
|
17022
|
+
if (fileReader === void 0) return [];
|
|
17023
|
+
const out = [];
|
|
17024
|
+
for (const element2 of parseWcsStateElements(html, stateTagName)) {
|
|
17025
|
+
const src = element2.srcAttr;
|
|
17026
|
+
const span = element2.srcSpan;
|
|
17027
|
+
if (src === void 0 || span === void 0 || element2.stateAttr !== void 0 || element2.bindComponent) continue;
|
|
17028
|
+
const readable = src.endsWith(".json") ? Boolean(fileReader(src)) : readStateScriptFile(src, fileReader) !== void 0;
|
|
17029
|
+
if (readable) continue;
|
|
17030
|
+
out.push({
|
|
17031
|
+
code: WcsDiagnosticCode.StateSrcUnread,
|
|
17032
|
+
start: span.start,
|
|
17033
|
+
end: span.end,
|
|
17034
|
+
message: getMessages(locale2).stateSrcUnread(src),
|
|
17035
|
+
severity: "info"
|
|
17036
|
+
});
|
|
17037
|
+
}
|
|
17038
|
+
return out;
|
|
17039
|
+
}
|
|
17040
|
+
|
|
16984
17041
|
// src/core/sidecar/jsonSource.ts
|
|
16985
17042
|
var JsonReader = class {
|
|
16986
17043
|
constructor(text3) {
|
|
@@ -17426,9 +17483,9 @@ function validateDocument(text3, options = {}) {
|
|
|
17426
17483
|
const stateTagName = options.stateTagName ?? "wcs-state";
|
|
17427
17484
|
const fileReader = options.fileReader;
|
|
17428
17485
|
const applicationSchema = options.applicationSchema ?? (fileReader !== void 0 ? discoverApplicationManifest(fileReader)?.schema : void 0);
|
|
17429
|
-
const found = validateText(text3, options, applicationSchema);
|
|
17486
|
+
const found = [...validateText(text3, options, applicationSchema), ...validateStateSources(text3, stateTagName, options.locale, fileReader)];
|
|
17430
17487
|
const page = fileReader === void 0 ? null : inlineExternalStates(text3, stateTagName, fileReader);
|
|
17431
|
-
if (page === null) return found;
|
|
17488
|
+
if (page === null) return sortDiagnostics(found);
|
|
17432
17489
|
const key = (d) => [d.code, d.start, d.end, d.message, d.origin?.path, d.origin?.start].join("\0");
|
|
17433
17490
|
const seen2 = new Set(found.map(key));
|
|
17434
17491
|
const out = [...found];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/lint",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"description": "Static-contract validator CLI (wcs-validate) for wcstack data-wcs bindings and wcstack.manifest.json sidecars. Thin npm wrapper around the wcstack-intellisense validator core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|