@wcstack/lint 4.15.0 → 4.16.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/dist/cli.cjs +78 -17
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -125,7 +125,7 @@ var WcsDiagnosticCode = {
|
|
|
125
125
|
ReadPathMissing: "wcs/read-path-missing",
|
|
126
126
|
NestedAssign: "wcs/nested-assign",
|
|
127
127
|
// --- 意味論(構文・存在検査では捕まらない取り違え。service/semanticValidator.ts) ---
|
|
128
|
-
// `$getAll` / `$setAll` / `$resolve` の添字の本数がパスの `*` の本数と噛み合わない。
|
|
128
|
+
// `$getAll` / `$setAll` / `$resolve` / `$update` の添字の本数がパスの `*` の本数と噛み合わない。
|
|
129
129
|
// ランタイムは #901 / #902 で throw する(diagnostics の後付けがあれば同じ code の文面。超過は 3.x では
|
|
130
130
|
// 黙って無視されていた)。error。
|
|
131
131
|
IndexArity: "wcs/index-arity",
|
|
@@ -1132,7 +1132,7 @@ var GUIDES = [
|
|
|
1132
1132
|
[/\[wcs\/wildcard-rank\] .* ranges over the rows of/, ' A "*" in a binding is the row of the loop around it: read a row of another list in a getter, with $resolve(path, indexes).'],
|
|
1133
1133
|
[/\[wcs\/binding-type-expectation\] class\.([^ ]+)/, ' Write "class.$1: path|truthy" to toggle on truthiness.'],
|
|
1134
1134
|
[/path segments — the limit/, " Every prefix of a path is interned, so the cost grows with the square of the depth."],
|
|
1135
|
-
[/\[wcs\/index-arity\] \$resolve/, ' $resolve
|
|
1135
|
+
[/\[wcs\/index-arity\] \$(?:resolve|update)/, ' $resolve and $update take one index per "*"; $getAll / $setAll take at most that many (fewer expands the rest).'],
|
|
1136
1136
|
[/"([^"#]+)#[^"]*" is not a filter name: "#" cannot appear in one/, ' Modifiers belong on the left side of the binding, before the ":" \u2014 write "$1" here.']
|
|
1137
1137
|
];
|
|
1138
1138
|
var RENAMED_FILTERS = {
|
|
@@ -2403,7 +2403,7 @@ function getWcsManifest() {
|
|
|
2403
2403
|
}
|
|
2404
2404
|
|
|
2405
2405
|
// ../state/package.json
|
|
2406
|
-
var version = "4.
|
|
2406
|
+
var version = "4.16.0";
|
|
2407
2407
|
|
|
2408
2408
|
// src/service/wcsManifest.ts
|
|
2409
2409
|
var ENGINE_VERSION = version;
|
|
@@ -10838,7 +10838,9 @@ var SUFFIX = "\n})";
|
|
|
10838
10838
|
var PATH_ARG_APIS = /* @__PURE__ */ new Set(["$getAll", "$resolve", "$dependOn", "$trackDependency"]);
|
|
10839
10839
|
var TRACK_APIS = /* @__PURE__ */ new Set(["$dependOn", "$trackDependency"]);
|
|
10840
10840
|
var UNTRACK_APIS = /* @__PURE__ */ new Set(["$untracked", "$untrackDependency"]);
|
|
10841
|
-
|
|
10841
|
+
var WRITE_APIS = /* @__PURE__ */ new Set(["$setAll", "$update"]);
|
|
10842
|
+
var collecting = {};
|
|
10843
|
+
function collectGetterReads(body, options = {}) {
|
|
10842
10844
|
let program;
|
|
10843
10845
|
try {
|
|
10844
10846
|
program = parse3(PREFIX + body + SUFFIX, { ecmaVersion: "latest", sourceType: "module" });
|
|
@@ -10849,7 +10851,12 @@ function collectGetterReads(body) {
|
|
|
10849
10851
|
if (fn === null) return null;
|
|
10850
10852
|
const out = [];
|
|
10851
10853
|
const root = { thisIsState: true, aliases: /* @__PURE__ */ new Set() };
|
|
10852
|
-
|
|
10854
|
+
collecting = options;
|
|
10855
|
+
try {
|
|
10856
|
+
visit(fn.body, enterFunction(fn, root, true), out);
|
|
10857
|
+
} finally {
|
|
10858
|
+
collecting = {};
|
|
10859
|
+
}
|
|
10853
10860
|
return out;
|
|
10854
10861
|
}
|
|
10855
10862
|
function unwrapWrapper(program) {
|
|
@@ -10954,6 +10961,21 @@ function enterFunction(fn, outer, thisIsState) {
|
|
|
10954
10961
|
function isThisRoot(node, scope) {
|
|
10955
10962
|
return node.type === "ThisExpression" && scope.thisIsState || node.type === "Identifier" && scope.aliases.has(node.name);
|
|
10956
10963
|
}
|
|
10964
|
+
function templateKey(node) {
|
|
10965
|
+
let path = "";
|
|
10966
|
+
const lists = [];
|
|
10967
|
+
for (let k = 0; k < node.quasis.length; k++) {
|
|
10968
|
+
const quasi = node.quasis[k].value.cooked;
|
|
10969
|
+
if (quasi === null || quasi === void 0) return null;
|
|
10970
|
+
if (k > 0 && quasi !== "" && !quasi.startsWith(".")) return null;
|
|
10971
|
+
path += quasi;
|
|
10972
|
+
if (k === node.expressions.length) break;
|
|
10973
|
+
if (!path.endsWith(".")) return null;
|
|
10974
|
+
lists.push(path.slice(0, -1));
|
|
10975
|
+
path += "*";
|
|
10976
|
+
}
|
|
10977
|
+
return lists.length === 0 ? null : { path, lists };
|
|
10978
|
+
}
|
|
10957
10979
|
function literalString(node) {
|
|
10958
10980
|
if (node.type === "Literal" && typeof node.value === "string") return node.value;
|
|
10959
10981
|
if (node.type === "TemplateLiteral" && node.expressions.length === 0 && node.quasis.length === 1) {
|
|
@@ -10971,6 +10993,10 @@ function segmentOf(member) {
|
|
|
10971
10993
|
}
|
|
10972
10994
|
const text3 = literalString(property);
|
|
10973
10995
|
if (text3 !== null) return { text: text3, dynamic: null };
|
|
10996
|
+
if (collecting.templates && property.type === "TemplateLiteral") {
|
|
10997
|
+
const key = templateKey(property);
|
|
10998
|
+
if (key !== null) return { text: key.path, dynamic: property, lists: key.lists };
|
|
10999
|
+
}
|
|
10974
11000
|
return property.type === "PrivateIdentifier" ? { text: null, dynamic: null } : { text: null, dynamic: property };
|
|
10975
11001
|
}
|
|
10976
11002
|
function unwrapChain(node) {
|
|
@@ -10998,12 +11024,14 @@ function emit(out, segments, options, start, end) {
|
|
|
10998
11024
|
}
|
|
10999
11025
|
chain.push(text3);
|
|
11000
11026
|
}
|
|
11027
|
+
const lists = segments[0].lists;
|
|
11001
11028
|
out.push({
|
|
11002
11029
|
path: root,
|
|
11003
11030
|
chain,
|
|
11004
11031
|
form: options.form,
|
|
11005
11032
|
callee: options.callee,
|
|
11006
11033
|
written: options.written,
|
|
11034
|
+
...lists !== void 0 ? { indexed: lists } : {},
|
|
11007
11035
|
start: start - PREFIX.length,
|
|
11008
11036
|
end: end - PREFIX.length
|
|
11009
11037
|
});
|
|
@@ -11080,6 +11108,23 @@ function visitCall(node, scope, out) {
|
|
|
11080
11108
|
for (const argument of node.arguments) visit(argument, scope, out);
|
|
11081
11109
|
return;
|
|
11082
11110
|
}
|
|
11111
|
+
if (collecting.writes && WRITE_APIS.has(api)) {
|
|
11112
|
+
const first = node.arguments[0];
|
|
11113
|
+
const path = first !== void 0 && first.type !== "SpreadElement" ? literalString(first) : null;
|
|
11114
|
+
if (path !== null && path.length > 0 && !path.startsWith("$")) {
|
|
11115
|
+
out.push({
|
|
11116
|
+
path,
|
|
11117
|
+
chain: null,
|
|
11118
|
+
form: "api-write",
|
|
11119
|
+
callee: false,
|
|
11120
|
+
written: false,
|
|
11121
|
+
start: first.start - PREFIX.length,
|
|
11122
|
+
end: first.end - PREFIX.length
|
|
11123
|
+
});
|
|
11124
|
+
}
|
|
11125
|
+
for (const argument of node.arguments) visit(argument, scope, out);
|
|
11126
|
+
return;
|
|
11127
|
+
}
|
|
11083
11128
|
}
|
|
11084
11129
|
visitMember(callee, scope, out, { form: "member", callee: true, written: false });
|
|
11085
11130
|
} else {
|
|
@@ -11095,6 +11140,7 @@ function visitWriteTarget(target, scope, out) {
|
|
|
11095
11140
|
}
|
|
11096
11141
|
const { segments, base } = resolveChain(unwrapped);
|
|
11097
11142
|
if (!isThisRoot(base, scope)) visit(base, scope, out);
|
|
11143
|
+
else if (collecting.writes) emit(out, segments, { form: "write", callee: false, written: false }, unwrapped.start, unwrapped.end);
|
|
11098
11144
|
for (const segment of segments) {
|
|
11099
11145
|
if (segment.dynamic !== null) visit(segment.dynamic, scope, out);
|
|
11100
11146
|
}
|
|
@@ -11527,6 +11573,7 @@ var ja = {
|
|
|
11527
11573
|
updatedCallbackUnknownPath: (p) => `"${p}" \u306F state \u306E\u30D1\u30B9\u3067\u306F\u306A\u3044\u306E\u3067 $renderedCallback \u306E paths \u306B\u73FE\u308C\u305A\u3001\u3053\u306E\u5206\u5C90\u306F\u4E00\u5EA6\u3082\u5B9F\u884C\u3055\u308C\u307E\u305B\u3093`,
|
|
11528
11574
|
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`,
|
|
11529
11575
|
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`,
|
|
11576
|
+
nestedWritePathMissing: (p) => `\u30D1\u30B9 "${p}" \u306F\u72B6\u614B\u5B9A\u7FA9\u306B\u5B58\u5728\u3057\u307E\u305B\u3093\u3002\u66F8\u304D\u8FBC\u307F\u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306B\u65B0\u3057\u3044\u30AD\u30FC\u3092\u4F5C\u308B\u3060\u3051\u3067\u3001\u5BA3\u8A00\u3057\u305F\u30D1\u30B9\u306E\u675F\u7E1B\u306B\u306F\u5C4A\u304D\u307E\u305B\u3093`,
|
|
11530
11577
|
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`,
|
|
11531
11578
|
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\uFF08URL \u306F\u8AAD\u307E\u305A\u3001/ \u304B\u3089\u59CB\u307E\u308B\u30D1\u30B9\u306F wcs-validate --root=<\u30B5\u30A4\u30C8\u306E\u30EB\u30FC\u30C8> \u306E\u3068\u304D\u3060\u3051\u305D\u306E\u4E0B\u3067\u8AAD\u307F\u307E\u3059\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\u3059\u304B\u3001--root \u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
11532
11579
|
pathDynamicUnknownValue: (path, n, name, from) => `"${path}" \u306E\u5024${name === void 0 ? "" : from === void 0 ? `\uFF08${name}\uFF09` : `\uFF08${name}\u3002"${from}" \u304B\u3089 import\uFF09`}\u306F\u9759\u7684\u306B\u8AAD\u3081\u306A\u3044\u306E\u3067\u3001\u305D\u306E\u4E0B\u306B\u675F\u306D\u305F\u30D1\u30B9\uFF08${n} \u4EF6\uFF09\u306F\u691C\u67FB\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u30AD\u30FC\u306B JSDoc \u306E @type \u2014 \u5F62\u304B\u3001\u30E2\u30B8\u30E5\u30FC\u30EB\u306E\u30EA\u30C6\u30E9\u30EB\u3092\u6307\u3059 typeof import("./file.js").name\uFF08\u8F9E\u66F8\u306A\u3089\u5168\u90E8\u306E\u30AD\u30FC\u3092\u6301\u3064\u65E2\u5B9A\u306E\u8A00\u8A9E\u306E\u30D5\u30A1\u30A4\u30EB\uFF09\u2014 \u3092\u4ED8\u3051\u308B\u304B\u3001wcstack.manifest.json \u306E stateSchema \u306B\u5BA3\u8A00\u3059\u308B\u3068\u691C\u67FB\u3055\u308C\u307E\u3059`,
|
|
@@ -11628,6 +11675,8 @@ var ja = {
|
|
|
11628
11675
|
return `$watch \u306E\u30AD\u30FC "${p}" \u306B "**" \u306F\u4F7F\u3048\u307E\u305B\u3093\u3002\u76E3\u8996\u306F\u5177\u4F53\u30D1\u30B9\uFF08\u56FA\u5B9A\u672C\u6570\u306E "*"\uFF09\u306B\u5BFE\u3057\u3066\u306E\u307F\u6210\u7ACB\u3057\u307E\u3059`;
|
|
11629
11676
|
case "resolve":
|
|
11630
11677
|
return `$resolve("${p}") \u306B "**" \u306F\u6E21\u305B\u307E\u305B\u3093\u3002$resolve \u306F\u5C55\u958B\u5F8C\u306E\u5177\u4F53\u30D1\u30B9\u3068\u6DFB\u5B57\u30BF\u30D7\u30EB\u306E\u53B3\u5BC6\u4E00\u81F4\u3060\u3051\u3092\u53D7\u3051\u4ED8\u3051\u307E\u3059`;
|
|
11678
|
+
case "update":
|
|
11679
|
+
return `$update("${p}") \u306B "**" \u306F\u6E21\u305B\u307E\u305B\u3093\u3002$update \u306F 1 \u3064\u306E\u30A2\u30C9\u30EC\u30B9\uFF08\u5C55\u958B\u5F8C\u306E\u5177\u4F53\u30D1\u30B9\u3068\u6DFB\u5B57\u30BF\u30D7\u30EB\u306E\u53B3\u5BC6\u4E00\u81F4\uFF09\u3060\u3051\u3092\u66F8\u304D\u63DB\u3048\u307E\u3059 \u2014 \u5168\u6DF1\u3055\u3078\u306F $setAll("${p}", [], value) \u3067\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`;
|
|
11631
11680
|
case "assignment":
|
|
11632
11681
|
return `this["${p}"] \u3078\u306E\u4EE3\u5165\u306B "**" \u306F\u4F7F\u3048\u307E\u305B\u3093\uFF08\u518D\u5E30 setter \u306F\u521D\u7248\u3067\u306F\u6301\u3066\u305A\u3001\u4EE3\u5165\u306F\u5C55\u958B\u5F8C\u306E\u5177\u4F53\u30D1\u30B9\u306B\u3057\u304B\u6210\u7ACB\u3057\u307E\u305B\u3093\uFF09\u3002$setAll("${p}", [], value) \u3067\u5168\u6DF1\u3055\u3078\u30D6\u30ED\u30FC\u30C9\u30AD\u30E3\u30B9\u30C8\u3059\u308B\u304B\u3001\u5177\u4F53\u30D1\u30B9\u3078\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`;
|
|
11633
11682
|
case "postUpdate":
|
|
@@ -11744,6 +11793,7 @@ var en = {
|
|
|
11744
11793
|
updatedCallbackUnknownPath: (p) => `"${p}" is not a path of this state, so it is never in $renderedCallback's paths and this branch never runs`,
|
|
11745
11794
|
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})`,
|
|
11746
11795
|
writePathMissing: (k) => `"${k}" is not a key the state declares. The write creates a new key and reaches no binding of a declared one`,
|
|
11796
|
+
nestedWritePathMissing: (p) => `Path "${p}" does not exist in the state definition. The write creates a new key in the object and reaches no binding of a declared path`,
|
|
11747
11797
|
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`,
|
|
11748
11798
|
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 URL is not read, and a path from / only under wcs-validate --root=<the site's root>): point it at the file laid out as on the server, relative to this file, or pass --root`,
|
|
11749
11799
|
pathDynamicUnknownValue: (path, n, name, from) => `The value of "${path}"${name === void 0 ? "" : from === void 0 ? ` (${name})` : ` (${name}, imported from "${from}")`} cannot be read statically, so the ${n === 1 ? "path" : `${n} paths`} bound under it ${n === 1 ? "is" : "are"} not checked. Give the key a JSDoc @type \u2014 its shape, or typeof import("./file.js").name for a module's literal (for a dictionary, the default language's file, which has every key) \u2014 or declare it in the stateSchema of wcstack.manifest.json to have them checked`,
|
|
@@ -11845,6 +11895,8 @@ var en = {
|
|
|
11845
11895
|
return `$watch key "${p}" cannot contain "**" \u2014 watching is defined against a concrete path (a fixed number of "*")`;
|
|
11846
11896
|
case "resolve":
|
|
11847
11897
|
return `$resolve("${p}") cannot take "**" \u2014 it accepts only an expanded concrete path with an exactly matching index tuple`;
|
|
11898
|
+
case "update":
|
|
11899
|
+
return `$update("${p}") cannot take "**" \u2014 it changes one address (an expanded concrete path with an exactly matching index tuple). Write every depth with $setAll("${p}", [], value)`;
|
|
11848
11900
|
case "assignment":
|
|
11849
11901
|
return `this["${p}"] = \u2026 cannot use "**" (there are no recursive setters in this version; an assignment only resolves against an expanded concrete path). Broadcast with $setAll("${p}", [], value), or write a concrete path`;
|
|
11850
11902
|
case "postUpdate":
|
|
@@ -16428,9 +16480,10 @@ function validateScanDeclarations(html, stateTagName = "wcs-state", locale2) {
|
|
|
16428
16480
|
}
|
|
16429
16481
|
|
|
16430
16482
|
// src/service/recursionValidator.ts
|
|
16431
|
-
var RECURSION_APIS = ["getAll", "setAll", "resolve", "postUpdate", "dependOn", "trackDependency"];
|
|
16483
|
+
var RECURSION_APIS = ["getAll", "setAll", "resolve", "update", "postUpdate", "dependOn", "trackDependency"];
|
|
16432
16484
|
var UNSUPPORTED_API_SITE = {
|
|
16433
16485
|
$resolve: "resolve",
|
|
16486
|
+
$update: "update",
|
|
16434
16487
|
$postUpdate: "postUpdate",
|
|
16435
16488
|
$dependOn: "dependOn",
|
|
16436
16489
|
$trackDependency: "trackDependency"
|
|
@@ -16680,7 +16733,7 @@ function validateApiCalls(script, offset2, spec, getterSuffixes, undeclared, msg
|
|
|
16680
16733
|
const start = offset2 + parsed.starts[0] + leading;
|
|
16681
16734
|
const end = offset2 + parsed.starts[0] + pathArg.trimEnd().length;
|
|
16682
16735
|
if (!hasRecursionWildcard(path)) {
|
|
16683
|
-
const writes = api === "$setAll" || api === "$resolve" && parsed.args.length >= 3;
|
|
16736
|
+
const writes = api === "$setAll" || api === "$update" || api === "$resolve" && parsed.args.length >= 3;
|
|
16684
16737
|
if (writes && spec !== null) {
|
|
16685
16738
|
const owning = owningGetterSuffix(spec, getterSuffixes, path);
|
|
16686
16739
|
if (owning !== null) {
|
|
@@ -17431,7 +17484,7 @@ function validateNameAliases(script, scriptStart, locale2, mountPath = null) {
|
|
|
17431
17484
|
for (const span of spans) pushDeclaration(span.name, span.start, span.end, "error");
|
|
17432
17485
|
return out;
|
|
17433
17486
|
}
|
|
17434
|
-
var API_CALL = /\.\s*\$(getAll|setAll|resolve)\s*\(/g;
|
|
17487
|
+
var API_CALL = /\.\s*\$(getAll|setAll|resolve|update)\s*\(/g;
|
|
17435
17488
|
function validateIndexArity(script, scriptStart, locale2) {
|
|
17436
17489
|
const msgs = getMessages(locale2);
|
|
17437
17490
|
const out = [];
|
|
@@ -17450,7 +17503,7 @@ function validateIndexArity(script, scriptStart, locale2) {
|
|
|
17450
17503
|
const actual = literalArrayLength(parsed.args[1]);
|
|
17451
17504
|
if (actual === null) continue;
|
|
17452
17505
|
const wildcardCount = countWildcardSegments(path);
|
|
17453
|
-
const requirement = api === "$resolve" ? "exact" : "atMost";
|
|
17506
|
+
const requirement = api === "$resolve" || api === "$update" ? "exact" : "atMost";
|
|
17454
17507
|
const mismatched = requirement === "exact" ? actual !== wildcardCount : actual > wildcardCount;
|
|
17455
17508
|
if (!mismatched) continue;
|
|
17456
17509
|
const argText = parsed.args[1];
|
|
@@ -17808,7 +17861,7 @@ function collectNestedWriteRoots(html, stateTagName, bindAttrName, blocks) {
|
|
|
17808
17861
|
API_CALL.lastIndex = parsed.end;
|
|
17809
17862
|
const path = parsed.args.length > 0 ? literalString2(parsed.args[0]) : null;
|
|
17810
17863
|
if (path === null) continue;
|
|
17811
|
-
if (api === "setAll" || parsed.args.length >= 3) addPrefixes(path, false);
|
|
17864
|
+
if (api === "setAll" || api === "update" || parsed.args.length >= 3) addPrefixes(path, false);
|
|
17812
17865
|
}
|
|
17813
17866
|
}
|
|
17814
17867
|
return roots;
|
|
@@ -18145,9 +18198,12 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
|
|
|
18145
18198
|
}
|
|
18146
18199
|
}
|
|
18147
18200
|
for (const callable of analyzeCallableBodies(block.content)) {
|
|
18148
|
-
for (const read of collectGetterReads(callable.body) ?? []) {
|
|
18149
|
-
|
|
18201
|
+
for (const read of collectGetterReads(callable.body, { templates: true, writes: true }) ?? []) {
|
|
18202
|
+
const write = read.written || read.form === "write" || read.form === "api-write";
|
|
18203
|
+
if (write && read.form !== "api-write" && !read.path.includes(".")) continue;
|
|
18204
|
+
if (read.path.split(".").some((s) => s === "" || s.startsWith("$")) || hasRecursionWildcard(read.path)) continue;
|
|
18150
18205
|
const path = prefix + read.path;
|
|
18206
|
+
if (read.indexed !== void 0 && !read.indexed.every((list) => isList(prefix + list, candidates, candidateSet))) continue;
|
|
18151
18207
|
if (pathExistsInCandidates(path, candidates, candidateSet)) continue;
|
|
18152
18208
|
if (applicationSchema !== void 0 ? resolveIndexedSchemaPath(applicationSchema, path).kind !== "nonexistent" : isUnresolvedPath(path, index.scopes)) continue;
|
|
18153
18209
|
const near = nearName(path, tree ??= treeOf(candidates));
|
|
@@ -18155,19 +18211,24 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
|
|
|
18155
18211
|
const said = suggestion(near.segment, near.names, msgs);
|
|
18156
18212
|
if (said === "") continue;
|
|
18157
18213
|
const at2 = block.contentStart + callable.bodyStart;
|
|
18214
|
+
const member = read.form === "member" || read.form === "write";
|
|
18158
18215
|
out.push({
|
|
18159
|
-
code: WcsDiagnosticCode.ReadPathMissing,
|
|
18216
|
+
code: write ? WcsDiagnosticCode.WritePathMissing : WcsDiagnosticCode.ReadPathMissing,
|
|
18160
18217
|
start: at2 + read.start,
|
|
18161
|
-
end:
|
|
18162
|
-
message: msgs.readPathMissing(read.path, !read.path.includes(".")) + said,
|
|
18163
|
-
// a stateSchema says the path is not there, as for a binding's `wcs/path-nonexistent`
|
|
18164
|
-
|
|
18218
|
+
end: member ? at2 + read.start + statePart(callable.body.slice(read.start, read.end)) : at2 + read.end,
|
|
18219
|
+
message: (write ? msgs.nestedWritePathMissing(read.path) : msgs.readPathMissing(read.path, !read.path.includes("."))) + said,
|
|
18220
|
+
// a stateSchema says the path is not there, as for a binding's `wcs/path-nonexistent` (a write stays a
|
|
18221
|
+
// warning, as the top-level one: a key the state adds on purpose is not a mistake)
|
|
18222
|
+
severity: !write && applicationSchema !== void 0 ? "error" : "warning"
|
|
18165
18223
|
});
|
|
18166
18224
|
}
|
|
18167
18225
|
}
|
|
18168
18226
|
}
|
|
18169
18227
|
return out;
|
|
18170
18228
|
}
|
|
18229
|
+
function isList(path, candidates, candidateSet) {
|
|
18230
|
+
return candidateSet.has(`${path}.*`) || candidates.some((c) => c.path === path && c.kind === "list");
|
|
18231
|
+
}
|
|
18171
18232
|
var THIS_PART = /^this\s*(?:\?\.\s*|\.\s*)(?:[A-Za-z_$][\w$]*)|^this\s*(?:\?\.)?\s*\[\s*(["'`])[^"'`]*\1\s*\]/;
|
|
18172
18233
|
function statePart(text3) {
|
|
18173
18234
|
return THIS_PART.exec(text3)?.[0].length ?? text3.length;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/lint",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.16.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": {
|