@wcstack/lint 4.8.0 → 4.9.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 CHANGED
@@ -66,7 +66,7 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
66
66
 
67
67
  ## state の契約を宣言する(`stateSchema`)
68
68
 
69
- 契約が無いと、validator が解決できないパスは **warning**(`wcs/binding-path-missing`)に留まります: インラインスクリプトが静的に読めなくても `count` は実行時には存在するかもしれないからです。`[]` で始まるリストの行のフィールドは、行を足す・置き換える代入式の行リテラルから読みます。外から届くリスト(`<wcs-fetch>` や `<wcs-storage>` が埋めるまで `null`)にはそのリテラルが無いので、プロパティの直前の JSDoc `@type` で形を宣言してください(`/** @type {{ id: number, name: string }[] | null} */ catalog: null`)。同じスクリプトの `@typedef` で行の型に名前を付け、`@type {Product[] | null}` と書いてもかまいません。HTML と同じ(または上の)ディレクトリに `application` sidecar を置くと、同じ typo が **error** になります:
69
+ 契約が無いと、validator が解決できないパスは **warning**(`wcs/binding-path-missing`)に留まります: インラインスクリプトが静的に読めなくても `count` は実行時には存在するかもしれないからです。`[]` で始まるリストの行のフィールドは、行を足す・置き換える代入式の行リテラルから読みます。4.9 から、`map` で行を作り直す代入 — `this.rows = [...this.items].map((c) => ({ id: c.id, label: c.name }))`・`.filter(…).map((c) => { return { … }; })` — も、そうする getter と同じく読み、`{}` を種にしたキーへ代入したオブジェクトリテラルのキーも読みます(`this.fieldErrors = { date: "…" }` で `fieldErrors.date`。リテラルの中の spread は追いません)。外から届くリスト(`<wcs-fetch>` や `<wcs-storage>` が埋めるまで `null`)にはそのリテラルが無いので、プロパティの直前の JSDoc `@type` で形を宣言してください(`/** @type {{ id: number, name: string }[] | null} */ catalog: null`)。同じスクリプトの `@typedef` で行の型に名前を付け、`@type {Product[] | null}` と書いてもかまいません。HTML と同じ(または上の)ディレクトリに `application` sidecar を置くと、同じ typo が **error** になります:
70
70
 
71
71
  ```json
72
72
  {
package/README.md CHANGED
@@ -66,7 +66,7 @@ A framework app (React, Vue) that uses the `<wcs-*>` elements has neither: its p
66
66
 
67
67
  ## Declaring a state contract (`stateSchema`)
68
68
 
69
- Without a contract, a path the validator cannot resolve is only a **warning** (`wcs/binding-path-missing`): `count` may well exist at runtime even when the inline script cannot be read statically. Note that a list starting as `[]` does not need a contract just to name its row fields — the analyzer reads them from the row literals in the assignments that add or replace rows (`this.items = this.items.concat({ id, kind: "general" })`, `.toSpliced(i, n, { … })`, `.with(i, { … })`, `[...this.items, { … }]`); only a row passed as a variable (`concat(row)`) is invisible to it. A list that arrives from outside — `null` until `<wcs-fetch>` or `<wcs-storage>` fills it — has no such literal: declare its shape with a JSDoc `@type` before the property (`/** @type {{ id: number, name: string }[] | null} */ catalog: null`), or name the row type with a `@typedef` in the same script and write `@type {Product[] | null}`. Put an `application` sidecar next to (or above) the HTML and the same typo becomes an **error**:
69
+ Without a contract, a path the validator cannot resolve is only a **warning** (`wcs/binding-path-missing`): `count` may well exist at runtime even when the inline script cannot be read statically. Note that a list starting as `[]` does not need a contract just to name its row fields — the analyzer reads them from the row literals in the assignments that add or replace rows (`this.items = this.items.concat({ id, kind: "general" })`, `.toSpliced(i, n, { … })`, `.with(i, { … })`, `[...this.items, { … }]`); only a row passed as a variable (`concat(row)`) is invisible to it. Since 4.9 it also reads an assignment that rebuilds the rows with `map` — `this.rows = [...this.items].map((c) => ({ id: c.id, label: c.name }))`, `.filter(…).map((c) => { return { … }; })` — the way it reads a getter that does, and the keys of an object literal assigned to a key seeded `{}` (`this.fieldErrors = { date: "…" }` gives `fieldErrors.date`; a spread inside the literal is not followed). A list that arrives from outside — `null` until `<wcs-fetch>` or `<wcs-storage>` fills it — has no such literal: declare its shape with a JSDoc `@type` before the property (`/** @type {{ id: number, name: string }[] | null} */ catalog: null`), or name the row type with a `@typedef` in the same script and write `@type {Product[] | null}`. Put an `application` sidecar next to (or above) the HTML and the same typo becomes an **error**:
70
70
 
71
71
  ```json
72
72
  {
package/dist/cli.cjs CHANGED
@@ -144,6 +144,9 @@ var WcsDiagnosticCode = {
144
144
  // (state README「依存追跡の境界」規則 1)。ランタイムは素のアクセスと区別できないので
145
145
  // 静的にしか検出できない。対象はオブジェクトリテラル初期値のルートだけ(配列は `items`
146
146
  // の依存で足りる — 行の置換は `items` 自体を書き換え、in-place 変異は array-mutation が止める)。
147
+ // 読んだパスをページの束縛(組み込みタグの spread・書き戻す束縛・要素の出力)が書くなら error(その書き込みは
148
+ // getter に届かないと断定できる — 継ぎ目アプリ family-ledger)、スクリプトの書き込みだけなら warning(ルートも
149
+ // 置き換えるなら壊れない)。時刻・`location` を読む getter も同じ code(warning)。
147
150
  GetterUntrackedRead: "wcs/getter-untracked-read",
148
151
  OnHandlerThis: "wcs/on-handler-this",
149
152
  // --- <wcs-state> script: $watch declaration ---
@@ -786,7 +789,7 @@ var SENTENCES = {
786
789
  [
787
790
  29
788
791
  /* FilterValueNotDate */
789
- ]: (fn, v) => `filter ${fn} requires a date value (a Date), not ${was(v)}${typeof v === "string" || typeof v === "number" ? " \u2014 make the Date where it is read: a getter returning new Date(\u2026)" : ""}`,
792
+ ]: (fn, v) => `filter ${fn} requires a date value (a Date), not ${was(v)}${typeof v === "string" || typeof v === "number" ? " \u2014 make the Date where it is read: a getter returning new Date(\u2026)" : ""}${typeof v === "string" && /^\d{4}-\d\d-\d\d$/.test(v) ? `. A date-only string is a day, not a moment: new Date(${JSON.stringify(v)}) is midnight UTC, the day before west of Greenwich \u2014 new Date(y, m - 1, d) is that day where the page is` : ""}`,
790
793
  [
791
794
  52
792
795
  /* FilterStyleInvalid */
@@ -2884,10 +2887,10 @@ var RESERVED_WATCH_KEY = "$watch";
2884
2887
  var RESERVED_SCAN_KEY = "$scan";
2885
2888
  var RESERVED_RECURSION_KEY = RECURSION_KEY;
2886
2889
  function analyzeStatePaths(scriptContent) {
2887
- const objectContent = extractDefaultExportObject(scriptContent);
2888
- if (!objectContent) return [];
2890
+ const root = locateDefaultExportObject(scriptContent);
2891
+ if (!root || !root.content) return [];
2889
2892
  const paths = [];
2890
- const topLevelProps = parseTopLevelProperties(objectContent);
2893
+ const topLevelProps = parseTopLevelProperties(root.content);
2891
2894
  const pendingStreamValues = [];
2892
2895
  const pendingListKeys = [];
2893
2896
  const recursionSpec = specFromRecursionValue(topLevelProps.find((p) => p.name === RESERVED_RECURSION_KEY));
@@ -2934,7 +2937,7 @@ function analyzeStatePaths(scriptContent) {
2934
2937
  }
2935
2938
  }
2936
2939
  collectRowShapesFromAssignments(scriptContent, paths);
2937
- collectGetterResultShapes(topLevelProps, effectiveDescriptors, paths);
2940
+ collectGetterResultShapes(scriptContent, root.start, topLevelProps, effectiveDescriptors, paths);
2938
2941
  return paths;
2939
2942
  }
2940
2943
  function specFromRecursionValue(prop) {
@@ -3346,23 +3349,45 @@ var ROW_PRESERVING_METHODS = /* @__PURE__ */ new Set([
3346
3349
  ]);
3347
3350
  var ROW_PICKING_METHODS = /* @__PURE__ */ new Set(["find", "findLast", "at"]);
3348
3351
  var MAX_GETTER_SHAPE_PASSES = 4;
3349
- function collectGetterResultShapes(props, effective, paths) {
3352
+ function collectGetterResultShapes(script, rootStart, props, effective, paths) {
3350
3353
  const getters = /* @__PURE__ */ new Map();
3351
3354
  for (const prop of props) {
3352
3355
  if (prop.kind !== "getter" || prop.accessor !== "get" || prop.value === void 0) continue;
3353
3356
  if (prop.name.startsWith("$") || hasRecursionWildcard(prop.name) || effective.get(prop.name) === "data") continue;
3354
3357
  getters.set(prop.name, prop);
3355
3358
  }
3359
+ const assignments = collectAssignments(script, rootStart, props);
3356
3360
  for (let pass = 0; pass < MAX_GETTER_SHAPE_PASSES; pass++) {
3357
3361
  const before = paths.length;
3358
3362
  for (const [name, prop] of getters) {
3359
3363
  const shape = getterResultShape(prop.value, paths);
3360
3364
  if (shape !== null) applyResultShape(name, shape, paths);
3361
3365
  }
3366
+ const aliasesByBody = /* @__PURE__ */ new Map();
3367
+ for (const assignment of assignments) {
3368
+ let aliases = /* @__PURE__ */ new Map();
3369
+ if (assignment.body !== null) {
3370
+ aliases = aliasesByBody.get(assignment.body) ?? collectAliases(assignment.body, paths);
3371
+ aliasesByBody.set(assignment.body, aliases);
3372
+ }
3373
+ const shape = expressionShape(assignment.expr, paths, aliases);
3374
+ if (shape !== null) applyAssignedShape(assignment.target, shape, paths);
3375
+ }
3362
3376
  if (paths.length === before) break;
3363
3377
  }
3364
3378
  }
3365
3379
  function getterResultShape(body, paths) {
3380
+ const scan = maskCommentsAndStrings(body);
3381
+ const aliases = collectAliases(body, paths);
3382
+ const shapes = [];
3383
+ for (const m of scan.matchAll(/\breturn\b/g)) {
3384
+ const start = m.index + m[0].length;
3385
+ const shape = expressionShape(readExpression(body, scan, start), paths, aliases);
3386
+ if (shape !== null) shapes.push(shape);
3387
+ }
3388
+ return shapes.length === 0 ? null : mergeShapes(shapes);
3389
+ }
3390
+ function collectAliases(body, paths) {
3366
3391
  const scan = maskCommentsAndStrings(body);
3367
3392
  const aliases = /* @__PURE__ */ new Map();
3368
3393
  for (const m of scan.matchAll(/\b(?:const|let|var)\s+([$\w]+)\s*=(?![=>])/g)) {
@@ -3372,13 +3397,36 @@ function getterResultShape(body, paths) {
3372
3397
  const shape = expressionShape(readExpression(body, scan, start), paths, aliases);
3373
3398
  if (shape !== null) aliases.set(name, shape);
3374
3399
  }
3375
- const shapes = [];
3376
- for (const m of scan.matchAll(/\breturn\b/g)) {
3377
- const start = m.index + m[0].length;
3378
- const shape = expressionShape(readExpression(body, scan, start), paths, aliases);
3379
- if (shape !== null) shapes.push(shape);
3400
+ return aliases;
3401
+ }
3402
+ var PLAIN_ASSIGN = new RegExp(String.raw`\bthis\s*(?:\.\s*([$\w]+)|\[\s*["']([^"']+)["']\s*\])\s*=(?![=>])`, "gd");
3403
+ function collectAssignments(script, rootStart, props) {
3404
+ const scan = maskCommentsAndStrings(script);
3405
+ const bodies = props.filter((p) => (p.kind === "getter" || p.kind === "method") && p.value !== void 0 && p.valueStart !== void 0).map((p) => ({ start: rootStart + p.valueStart, body: p.value }));
3406
+ const out = [];
3407
+ PLAIN_ASSIGN.lastIndex = 0;
3408
+ let match;
3409
+ while ((match = PLAIN_ASSIGN.exec(scan)) !== null) {
3410
+ if (/\.\s*$/.test(scan.slice(Math.max(0, match.index - 8), match.index))) continue;
3411
+ const span = match.indices[1] ?? match.indices[2];
3412
+ const target = script.slice(span[0], span[1]);
3413
+ if (target.startsWith("$") || target.includes("*")) continue;
3414
+ const expr = readExpression(script, scan, match.index + match[0].length);
3415
+ const owner = bodies.find((b) => b.start <= match.index && match.index < b.start + b.body.length);
3416
+ out.push({ target, expr, body: owner?.body ?? null });
3417
+ }
3418
+ return out;
3419
+ }
3420
+ function applyAssignedShape(target, shape, paths) {
3421
+ const declared = paths.find((p) => p.path === target);
3422
+ if (declared === void 0 || declared.kind !== "data") return;
3423
+ if (hasPath(paths, `${target}.*`)) {
3424
+ if (shape.isList) applyResultShape(target, shape, paths);
3425
+ return;
3426
+ }
3427
+ if (!shape.isList && declared.rawInitial !== void 0 && isObjectLiteral(declared.rawInitial)) {
3428
+ applyResultShape(target, shape, paths);
3380
3429
  }
3381
- return shapes.length === 0 ? null : mergeShapes(shapes);
3382
3430
  }
3383
3431
  function readExpression(text3, scan, start) {
3384
3432
  let depth = 0;
@@ -3433,9 +3481,7 @@ function expressionShape(text3, paths, aliases) {
3433
3481
  }
3434
3482
  } else if (scan.startsWith("(")) {
3435
3483
  const inner = extractDelimitedContent(expr, scan, 0, "(", ")");
3436
- const base = expressionShape(inner, paths, aliases);
3437
- if (base === null) return null;
3438
- shape = base;
3484
+ shape = expressionShape(inner, paths, aliases) ?? OPAQUE;
3439
3485
  rest = inner.length + 2;
3440
3486
  } else {
3441
3487
  const base = readBase(expr, scan, aliases, paths);
@@ -3784,9 +3830,6 @@ function locateDefaultExportObject(script) {
3784
3830
  const braceIndex = scan.indexOf(match[1], match.index);
3785
3831
  return { content: extractBracedContent(script, scan, braceIndex), start: braceIndex + 1 };
3786
3832
  }
3787
- function extractDefaultExportObject(script) {
3788
- return locateDefaultExportObject(script)?.content ?? null;
3789
- }
3790
3833
  function parseTopLevelProperties(objectContent, allowEmptyDataKeys = false) {
3791
3834
  const props = [];
3792
3835
  const scan = maskCommentsAndStrings(objectContent);
@@ -10981,6 +11024,7 @@ var ja = {
10981
11024
  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`,
10982
11025
  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`,
10983
11026
  getterUntrackedRead: (root, sp) => `\u3053\u3053\u3067\u8FFD\u8DE1\u3055\u308C\u308B\u306E\u306F "${root}" \u3060\u3051\u3067\u3059\u3002"${sp}" \u304C\u5909\u308F\u3063\u3066\u3082\u3053\u306E getter \u306F\u518D\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\uFF08\u30D1\u30B9\u8AAD\u307F\u53D6\u308A\u306E\u5148\u306E\u7D20\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u30A2\u30AF\u30BB\u30B9\u306F\u8FFD\u8DE1\u3055\u308C\u306A\u3044\uFF09\u3002this["${sp}"] \u3067\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044`,
11027
+ getterUntrackedReadBound: (root, sp, binding, tag, written) => `\u3053\u3053\u3067\u8FFD\u8DE1\u3055\u308C\u308B\u306E\u306F "${root}" \u3060\u3051\u3067\u3059\u304C\u3001<${tag}> \u306E\u675F\u7E1B "${binding}" \u306F "${written}" \u3092\u30D1\u30B9\u3067\u66F8\u304D\u307E\u3059\u3002\u305D\u306E\u66F8\u304D\u8FBC\u307F\u306F\u3053\u306E getter \u306B\u5C4A\u304B\u305A\u3001getter \u306F\u524D\u306B\u8A08\u7B97\u3057\u305F\u5024\u3092\u8FD4\u3057\u7D9A\u3051\u307E\u3059\uFF08\u30D1\u30B9\u8AAD\u307F\u53D6\u308A\u306E\u5148\u306E\u7D20\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u30A2\u30AF\u30BB\u30B9\u306F\u8FFD\u8DE1\u3055\u308C\u306A\u3044\uFF09\u3002this["${sp}"] \u3067\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044`,
10984
11028
  handlerFilterNotAllowed: (prop) => `\u30A4\u30D9\u30F3\u30C8\u30CF\u30F3\u30C9\u30E9 "${prop}" \u306B\u30D5\u30A3\u30EB\u30BF\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093`,
10985
11029
  typeExpectation: (label, expected, resultType) => `"${label}" \u306B\u306F${JA_EXPECTED_LABEL[expected]}\u304C\u5FC5\u8981\u3067\u3059\uFF08\u73FE\u5728\u306E\u578B: ${resultType}\uFF09`,
10986
11030
  filterUnknown: (n) => `\u30D5\u30A3\u30EB\u30BF "${n}" \u306F\u7D44\u307F\u8FBC\u307F\u30D5\u30A3\u30EB\u30BF\u306B\u5B58\u5728\u3057\u307E\u305B\u3093`,
@@ -11191,6 +11235,7 @@ var en = {
11191
11235
  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})`,
11192
11236
  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`,
11193
11237
  getterUntrackedRead: (root, sp) => `Only "${root}" is tracked here: the getter is not re-evaluated when "${sp}" changes (plain property access after a path read is not tracked). Read this["${sp}"] instead`,
11238
+ getterUntrackedReadBound: (root, sp, binding, tag, written) => `Only "${root}" is tracked here, but the binding "${binding}" on <${tag}> writes "${written}" by path: that write never reaches this getter, which keeps returning the value it last computed (plain property access after a path read is not tracked). Read this["${sp}"] instead`,
11194
11239
  handlerFilterNotAllowed: (prop) => `Filters cannot be applied to event handler "${prop}"`,
11195
11240
  typeExpectation: (label, expected, resultType) => `"${label}" requires ${EN_EXPECTED_LABEL[expected]} (current type: ${resultType})`,
11196
11241
  filterUnknown: (n) => `Filter "${n}" is not a built-in filter`,
@@ -12120,7 +12165,8 @@ function openTagBefore(html, valueStart) {
12120
12165
  return lt2 === -1 ? "" : html.slice(lt2, valueStart);
12121
12166
  }
12122
12167
  function writesBack(attr, prop, written) {
12123
- if (written.split("#").slice(1).some((modifier) => modifier.trim() === "ro")) return false;
12168
+ const modifiers = written.split("#").slice(1).flatMap((part) => part.split(","));
12169
+ if (modifiers.some((modifier) => modifier.trim() === "ro")) return false;
12124
12170
  if (prop === "radio" || prop === "checkbox") return true;
12125
12171
  const tag = attr.tagName;
12126
12172
  if (tag === void 0 || tag.includes("-")) return false;
@@ -14063,6 +14109,9 @@ var BUILTIN_TAGS = {
14063
14109
  "withCredentials": "with-credentials",
14064
14110
  "events": "events",
14065
14111
  "raw": "raw",
14112
+ "autoReconnect": "auto-reconnect",
14113
+ "reconnectInterval": "reconnect-interval",
14114
+ "maxReconnects": "max-reconnects",
14066
14115
  "staleAfter": "stale-after",
14067
14116
  "manual": "manual",
14068
14117
  "trigger": null
@@ -14190,6 +14239,14 @@ var BUILTIN_TAGS = {
14190
14239
  "abort"
14191
14240
  ]
14192
14241
  },
14242
+ "wcs-upload-header": {
14243
+ "package": "upload",
14244
+ "hasWcBindable": false,
14245
+ "observedAttributes": [],
14246
+ "inputs": {},
14247
+ "properties": [],
14248
+ "commands": []
14249
+ },
14193
14250
  "wcs-view-transition": {
14194
14251
  "package": "view-transition",
14195
14252
  "hasWcBindable": true,
@@ -16478,7 +16535,7 @@ function validateGetterCycles(script, scriptStart, locale2) {
16478
16535
  }
16479
16536
  return out;
16480
16537
  }
16481
- function validateGetterUntrackedReads(script, scriptStart, nestedWriteRoots, locale2) {
16538
+ function validateGetterUntrackedReads(script, scriptStart, mountPath, nestedWriteRoots, bindingWrites, locale2) {
16482
16539
  const getters = analyzeCallableBodies(script).filter((entry) => entry.kind === "getter" && entry.accessor === "get");
16483
16540
  if (getters.length === 0) return [];
16484
16541
  const objectRoots = /* @__PURE__ */ new Set();
@@ -16496,18 +16553,66 @@ function validateGetterUntrackedReads(script, scriptStart, nestedWriteRoots, loc
16496
16553
  if (read.written) continue;
16497
16554
  const segments = read.callee ? read.chain.slice(0, -1) : read.chain;
16498
16555
  if (segments.length < 2 || !objectRoots.has(segments[0])) continue;
16499
- if (!nestedWriteRoots().has(segments[0])) continue;
16556
+ const prefix = mountPath === null ? [] : mountPath.split(".");
16557
+ const write = boundWriteOf([...prefix, ...segments], prefix.length + read.path.split(".").length, bindingWrites());
16558
+ if (write === void 0 && !nestedWriteRoots().has([...prefix, segments[0]].join("."))) continue;
16559
+ const sp = segments.join(".");
16500
16560
  out.push({
16501
16561
  code: WcsDiagnosticCode.GetterUntrackedRead,
16502
16562
  start: scriptStart + getter.bodyStart + read.start,
16503
16563
  end: scriptStart + getter.bodyStart + read.end,
16504
- message: msgs.getterUntrackedRead(segments[0], segments.join(".")),
16505
- severity: "warning"
16564
+ message: write === void 0 ? msgs.getterUntrackedRead(segments[0], sp) : msgs.getterUntrackedReadBound(segments[0], sp, write.binding, write.tag, write.path),
16565
+ severity: write === void 0 ? "warning" : "error"
16506
16566
  });
16507
16567
  }
16508
16568
  }
16509
16569
  return out;
16510
16570
  }
16571
+ function boundWriteOf(segments, tracked, writes) {
16572
+ return writes.find((write) => {
16573
+ const written = write.path.split(".");
16574
+ if (written.length <= tracked || written.length > segments.length) return false;
16575
+ return written.every((s, i) => s === segments[i] || s === "*" && /^\d+$/.test(segments[i]));
16576
+ });
16577
+ }
16578
+ function collectBindingWrites(html, bindAttrName) {
16579
+ const out = [];
16580
+ const ignored = findIgnoredRanges(html, bindAttrName);
16581
+ for (const attr of findAllBindAttributes(html, bindAttrName)) {
16582
+ if (ignored.some(([start, end]) => attr.valueStart >= start && attr.valueStart < end)) continue;
16583
+ const tag = attr.tagName ?? "";
16584
+ const contract = BUILTIN_TAGS[tag];
16585
+ const outputs = contract?.hasWcBindable === true ? contract.properties : null;
16586
+ const bindings = parseBindTextWithPositions(attr.value);
16587
+ bindings.forEach((binding, index) => {
16588
+ const parsed = binding.parsed;
16589
+ if (parsed === null || binding.pathRange === null) return;
16590
+ let path = parsed.statePathName;
16591
+ if (path.startsWith(".")) {
16592
+ const at2 = attr.valueStart + binding.pathRange.start;
16593
+ const list = getRowShorthandForPath(html, at2, bindAttrName) === null ? null : getResolvedForListPath(html, at2, bindAttrName);
16594
+ if (list === null) return;
16595
+ path = path === "." ? `${list}.*` : `${list}.*.${path.slice(1)}`;
16596
+ }
16597
+ const write = (written) => {
16598
+ out.push({ path: written, binding: binding.exprText, tag });
16599
+ };
16600
+ if (parsed.bindingType === "spread") {
16601
+ if (outputs === null) return;
16602
+ const later = new Set(bindings.slice(index + 1).flatMap((b) => b.parsed?.bindingType === "prop" ? [b.parsed.propName] : []));
16603
+ for (const output of outputs) if (!later.has(output)) write(`${path}.${output}`);
16604
+ return;
16605
+ }
16606
+ if (parsed.propModifiers.includes("ro")) return;
16607
+ if (parsed.bindingType === "radio" || parsed.bindingType === "checkbox") {
16608
+ write(path);
16609
+ } else if (parsed.bindingType === "prop" && (writesBack(attr, parsed.propName, parsed.propName) || outputs?.includes(parsed.propName) === true)) {
16610
+ write(path);
16611
+ }
16612
+ });
16613
+ }
16614
+ return out;
16615
+ }
16511
16616
  function validateGetterLocationReads(script, scriptStart, locale2) {
16512
16617
  if (!script.includes("location")) return [];
16513
16618
  const msgs = getMessages(locale2);
@@ -16838,12 +16943,21 @@ function validateSemantics(html, stateTagName = "wcs-state", locale2, bindAttrNa
16838
16943
  const blocks = parseLoadedScriptBlocks(html, stateTagName);
16839
16944
  let nestedWriteRoots = null;
16840
16945
  const getNestedWriteRoots = () => nestedWriteRoots ??= collectNestedWriteRoots(html, stateTagName, bindAttrName, blocks);
16946
+ let bindingWrites = null;
16947
+ const getBindingWrites = () => bindingWrites ??= collectBindingWrites(html, bindAttrName);
16841
16948
  for (const block of blocks) {
16842
16949
  out.push(...validateIndexArity(block.content, block.contentStart, locale2));
16843
16950
  out.push(...validateNameAliases(block.content, block.contentStart, locale2, block.mountPath));
16844
16951
  out.push(...validateIndexParamReads(block.content, block.contentStart, locale2));
16845
16952
  out.push(...validateGetterCycles(block.content, block.contentStart, locale2));
16846
- out.push(...validateGetterUntrackedReads(block.content, block.contentStart, getNestedWriteRoots, locale2));
16953
+ out.push(...validateGetterUntrackedReads(
16954
+ block.content,
16955
+ block.contentStart,
16956
+ block.mountPath,
16957
+ getNestedWriteRoots,
16958
+ getBindingWrites,
16959
+ locale2
16960
+ ));
16847
16961
  out.push(...validateGetterLocationReads(block.content, block.contentStart, locale2));
16848
16962
  out.push(...validateGetterClockReads(block.content, block.contentStart, locale2));
16849
16963
  out.push(...validateOnHandlerThis(block.content, block.contentStart, locale2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/lint",
3
- "version": "4.8.0",
3
+ "version": "4.9.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": {