@wcstack/lint 4.14.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 +115 -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",
|
|
@@ -302,6 +302,11 @@ var WcsDiagnosticCode = {
|
|
|
302
302
|
// router。router は自前の outlet を直後に作り、ページはそこに描かれ、置いた outlet は空のまま。
|
|
303
303
|
// ランタイムも同じ code で警告する(docs/router-outlet-placement.md)。
|
|
304
304
|
RouterOutletMisplaced: "wcs/router-outlet-misplaced",
|
|
305
|
+
// `query-keys` を持つ `<wcs-link>` の `to` が付けるキーが、どれも `query-keys` に無い。リンクは名指したキーだけを
|
|
306
|
+
// 比べるので、自分のクエリは判定に効かず、名指したキーが合えばどこでも現在になる(そう書いたタブは同時にすべて
|
|
307
|
+
// 現在)。`to` のキーの一部だけを比べない形(`to="?cat=a&page=1" query-keys="cat"`)は意図どおりなので黙る
|
|
308
|
+
// (docs/formal-methods-study.md §4.2)。warning。
|
|
309
|
+
LinkQueryKeyIgnored: "wcs/link-query-key-ignored",
|
|
305
310
|
// @wcstack/signals と /dom エントリの同一ページ混在(リアクティブコア二重化)。
|
|
306
311
|
SignalsDualEntry: "wcs/signals-dual-entry",
|
|
307
312
|
// wcstack を自分で読み込むページが、あるパッケージのタグ(`<wcs-upload>`・`<wcs-upload-header>`)を書くのに、その
|
|
@@ -1127,7 +1132,7 @@ var GUIDES = [
|
|
|
1127
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).'],
|
|
1128
1133
|
[/\[wcs\/binding-type-expectation\] class\.([^ ]+)/, ' Write "class.$1: path|truthy" to toggle on truthiness.'],
|
|
1129
1134
|
[/path segments — the limit/, " Every prefix of a path is interned, so the cost grows with the square of the depth."],
|
|
1130
|
-
[/\[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).'],
|
|
1131
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.']
|
|
1132
1137
|
];
|
|
1133
1138
|
var RENAMED_FILTERS = {
|
|
@@ -2398,7 +2403,7 @@ function getWcsManifest() {
|
|
|
2398
2403
|
}
|
|
2399
2404
|
|
|
2400
2405
|
// ../state/package.json
|
|
2401
|
-
var version = "4.
|
|
2406
|
+
var version = "4.16.0";
|
|
2402
2407
|
|
|
2403
2408
|
// src/service/wcsManifest.ts
|
|
2404
2409
|
var ENGINE_VERSION = version;
|
|
@@ -10833,7 +10838,9 @@ var SUFFIX = "\n})";
|
|
|
10833
10838
|
var PATH_ARG_APIS = /* @__PURE__ */ new Set(["$getAll", "$resolve", "$dependOn", "$trackDependency"]);
|
|
10834
10839
|
var TRACK_APIS = /* @__PURE__ */ new Set(["$dependOn", "$trackDependency"]);
|
|
10835
10840
|
var UNTRACK_APIS = /* @__PURE__ */ new Set(["$untracked", "$untrackDependency"]);
|
|
10836
|
-
|
|
10841
|
+
var WRITE_APIS = /* @__PURE__ */ new Set(["$setAll", "$update"]);
|
|
10842
|
+
var collecting = {};
|
|
10843
|
+
function collectGetterReads(body, options = {}) {
|
|
10837
10844
|
let program;
|
|
10838
10845
|
try {
|
|
10839
10846
|
program = parse3(PREFIX + body + SUFFIX, { ecmaVersion: "latest", sourceType: "module" });
|
|
@@ -10844,7 +10851,12 @@ function collectGetterReads(body) {
|
|
|
10844
10851
|
if (fn === null) return null;
|
|
10845
10852
|
const out = [];
|
|
10846
10853
|
const root = { thisIsState: true, aliases: /* @__PURE__ */ new Set() };
|
|
10847
|
-
|
|
10854
|
+
collecting = options;
|
|
10855
|
+
try {
|
|
10856
|
+
visit(fn.body, enterFunction(fn, root, true), out);
|
|
10857
|
+
} finally {
|
|
10858
|
+
collecting = {};
|
|
10859
|
+
}
|
|
10848
10860
|
return out;
|
|
10849
10861
|
}
|
|
10850
10862
|
function unwrapWrapper(program) {
|
|
@@ -10949,6 +10961,21 @@ function enterFunction(fn, outer, thisIsState) {
|
|
|
10949
10961
|
function isThisRoot(node, scope) {
|
|
10950
10962
|
return node.type === "ThisExpression" && scope.thisIsState || node.type === "Identifier" && scope.aliases.has(node.name);
|
|
10951
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
|
+
}
|
|
10952
10979
|
function literalString(node) {
|
|
10953
10980
|
if (node.type === "Literal" && typeof node.value === "string") return node.value;
|
|
10954
10981
|
if (node.type === "TemplateLiteral" && node.expressions.length === 0 && node.quasis.length === 1) {
|
|
@@ -10966,6 +10993,10 @@ function segmentOf(member) {
|
|
|
10966
10993
|
}
|
|
10967
10994
|
const text3 = literalString(property);
|
|
10968
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
|
+
}
|
|
10969
11000
|
return property.type === "PrivateIdentifier" ? { text: null, dynamic: null } : { text: null, dynamic: property };
|
|
10970
11001
|
}
|
|
10971
11002
|
function unwrapChain(node) {
|
|
@@ -10993,12 +11024,14 @@ function emit(out, segments, options, start, end) {
|
|
|
10993
11024
|
}
|
|
10994
11025
|
chain.push(text3);
|
|
10995
11026
|
}
|
|
11027
|
+
const lists = segments[0].lists;
|
|
10996
11028
|
out.push({
|
|
10997
11029
|
path: root,
|
|
10998
11030
|
chain,
|
|
10999
11031
|
form: options.form,
|
|
11000
11032
|
callee: options.callee,
|
|
11001
11033
|
written: options.written,
|
|
11034
|
+
...lists !== void 0 ? { indexed: lists } : {},
|
|
11002
11035
|
start: start - PREFIX.length,
|
|
11003
11036
|
end: end - PREFIX.length
|
|
11004
11037
|
});
|
|
@@ -11075,6 +11108,23 @@ function visitCall(node, scope, out) {
|
|
|
11075
11108
|
for (const argument of node.arguments) visit(argument, scope, out);
|
|
11076
11109
|
return;
|
|
11077
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
|
+
}
|
|
11078
11128
|
}
|
|
11079
11129
|
visitMember(callee, scope, out, { form: "member", callee: true, written: false });
|
|
11080
11130
|
} else {
|
|
@@ -11090,6 +11140,7 @@ function visitWriteTarget(target, scope, out) {
|
|
|
11090
11140
|
}
|
|
11091
11141
|
const { segments, base } = resolveChain(unwrapped);
|
|
11092
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);
|
|
11093
11144
|
for (const segment of segments) {
|
|
11094
11145
|
if (segment.dynamic !== null) visit(segment.dynamic, scope, out);
|
|
11095
11146
|
}
|
|
@@ -11522,6 +11573,7 @@ var ja = {
|
|
|
11522
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`,
|
|
11523
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`,
|
|
11524
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`,
|
|
11525
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`,
|
|
11526
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`,
|
|
11527
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`,
|
|
@@ -11592,6 +11644,7 @@ var ja = {
|
|
|
11592
11644
|
devtoolsAfterState: () => `@wcstack/devtools/auto \u306F @wcstack/state/auto \u3088\u308A\u5148\u306B\u8AAD\u307F\u8FBC\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u5F8C\u304B\u3089\u3060\u3068\u3001DevTools \u306E\u30BF\u30A4\u30E0\u30E9\u30A4\u30F3\u306F\u4ED8\u3044\u305F\u6642\u70B9\u304B\u3089\u59CB\u307E\u308A\u307E\u3059\u3002\u65E2\u306B\u3042\u308B\u914D\u7DDA\u306F 4.0 \u304C\u9001\u308A\u76F4\u3057\u307E\u3059\uFF09`,
|
|
11593
11645
|
baseHrefMissing: () => `@wcstack/router \u3092\u4F7F\u3046 SPA \u306B\u306F <head> \u5185\u306E <base href="/">\uFF08\u307E\u305F\u306F\u305D\u308C\u3092\u4F5C\u308B <head> \u306E\u540C\u671F\u30B9\u30AF\u30EA\u30D7\u30C8 \u2014 basename \u306B\u30ED\u30B1\u30FC\u30EB\u3092\u7F6E\u304F\u5F62\uFF09\u304C\u5FC5\u8981\u3067\u3059\uFF08\u7121\u3044\u3068\u30C7\u30A3\u30FC\u30D7\u30EA\u30F3\u30AF\u3067 basename \u304C\u8AA4\u5C0E\u51FA\u3055\u308C\u307E\u3059\uFF09`,
|
|
11594
11646
|
routerOutletMisplaced: () => `\u3053\u306E <wcs-outlet> \u306F <wcs-router> \u306E\u76F4\u5F8C\u306B\u7121\u3044\u306E\u3067\u3001\u3069\u306E router \u3082\u4F7F\u3044\u307E\u305B\u3093\u3002router \u306F\u81EA\u5206\u306E\u76F4\u5F8C\u306E\u8981\u7D20\u3060\u3051\u3092 outlet \u3068\u3057\u3066\u4F7F\u3044\u3001\u305D\u3053\u306B <wcs-outlet> \u304C\u7121\u3051\u308C\u3070\u81EA\u524D\u306E outlet \u3092\u4F5C\u308A\u307E\u3059\u3002\u30EB\u30FC\u30C8\u306F router \u306E\u76F4\u5F8C\u306B\u63CF\u304B\u308C\u3001\u3053\u306E outlet \u306F\u7A7A\u306E\u307E\u307E\u3067\u3059 \u2014 <wcs-router> \u306E\u76F4\u5F8C\u3078\u79FB\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
11647
|
+
linkQueryKeyIgnored: (toKeys, named) => `\u3053\u306E <wcs-link> \u306E to \u304C\u4ED8\u3051\u308B\u30AD\u30FC\uFF08${toKeys}\uFF09\u306F\u3001\u3069\u308C\u3082 query-keys\uFF08${named}\uFF09\u306B\u3042\u308A\u307E\u305B\u3093\u3002query-keys \u306E\u3042\u308B\u30EA\u30F3\u30AF\u306F\u540D\u6307\u3057\u305F\u30AD\u30FC\u3060\u3051\u3092\u6BD4\u3079\u308B\u306E\u3067\u3001\u30EA\u30F3\u30AF\u81EA\u8EAB\u306E\u30AF\u30A8\u30EA\u306F\u5224\u5B9A\u306B\u52B9\u304B\u305A\u3001${named} \u304C\u5408\u3048\u3070 ${toKeys} \u304C\u4F55\u3067\u3082\u73FE\u5728\u306E\u30EA\u30F3\u30AF\u306B\u306A\u308A\u307E\u3059 \u2014 \u3053\u3046\u66F8\u3044\u305F\u30BF\u30D6\u306F\u540C\u6642\u306B\u3059\u3079\u3066\u73FE\u5728\u306B\u306A\u308A\u307E\u3059\u3002\u30EA\u30F3\u30AF\u304C\u8868\u3059\u30AD\u30FC\u3092\u540D\u6307\u3057\u3066\u304F\u3060\u3055\u3044\uFF08query-keys="${toKeys}"\uFF09`,
|
|
11595
11648
|
signalsDualEntry: () => `@wcstack/signals \u3068 @wcstack/signals/dom \u304C\u540C\u4E00\u30DA\u30FC\u30B8\u304B\u3089 import \u3055\u308C\u3066\u3044\u307E\u3059\u3002CDN \u3067\u306F\u5404\u30A8\u30F3\u30C8\u30EA\u304C\u81EA\u5DF1\u5B8C\u7D50\u30D0\u30F3\u30C9\u30EB\u306E\u305F\u3081\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u30B3\u30A2\u304C\u4E8C\u91CD\u5316\u3057\u3001\u5883\u754C\u3067\u53CD\u5FDC\u304C\u58CA\u308C\u307E\u3059 \u2014 \u3059\u3079\u3066 /dom \u30A8\u30F3\u30C8\u30EA\u304B\u3089 import \u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
11596
11649
|
signalsImportMapBoth: () => `\u3053\u306E import map \u306F @wcstack/signals \u3068 @wcstack/signals/dom \u306E\u4E21\u65B9\u3092\u5272\u308A\u5F53\u3066\u3066\u3044\u307E\u3059\u3002CDN \u3067\u306F\u5404\u30A8\u30F3\u30C8\u30EA\u304C\u30EA\u30A2\u30AF\u30C6\u30A3\u30D6\u30B3\u30A2\u3092\u6301\u3064\u306E\u3067\u3001@wcstack/signals \u3092 import \u3059\u308B\u30E2\u30B8\u30E5\u30FC\u30EB\uFF08\u3053\u306E\u30DA\u30FC\u30B8\u306E\u3082\u306E\u3067\u3082\u3001\u8AAD\u307F\u8FBC\u3080 .js \u3067\u3082\uFF09\u304C 2 \u3064\u76EE\u306E\u30B3\u30A2\u3092\u6301\u3061\u3001\u5883\u754C\u3067\u53CD\u5FDC\u304C\u58CA\u308C\u307E\u3059\u3002@wcstack/signals/dom \u3060\u3051\u3092\u5272\u308A\u5F53\u3066\u3066\u304F\u3060\u3055\u3044\uFF08\u30B3\u30A2\u306E\u5168\u90E8\u3092 export \u3057\u307E\u3059\uFF09`,
|
|
11597
11650
|
tagPackageMissing: (tags, pkg, url) => `${tags.map((t) => `<${t}>`).join("\u30FB")} \u306F ${pkg} \u306E\u30BF\u30B0\u3067\u3059\u304C\u3001\u3053\u306E\u30DA\u30FC\u30B8\u306F ${pkg} \u306E\u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u305B\u3093\u3002\u8981\u7D20\u306F\u5B9A\u7FA9\u3055\u308C\u306A\u3044\u306E\u3067\u3001\u305D\u306E\u675F\u7E1B\u306F\u5F85\u3061\u7D9A\u3051\u3066\u4F55\u3082\u8D77\u304D\u305A\u3001\u30B3\u30F3\u30BD\u30FC\u30EB\u306B\u3082\u4F55\u3082\u51FA\u307E\u305B\u3093 \u2014 <script type="module" src="${url}"></script> \u3067\u8AAD\u307F\u8FBC\u3093\u3067\u304F\u3060\u3055\u3044`,
|
|
@@ -11622,6 +11675,8 @@ var ja = {
|
|
|
11622
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`;
|
|
11623
11676
|
case "resolve":
|
|
11624
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`;
|
|
11625
11680
|
case "assignment":
|
|
11626
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`;
|
|
11627
11682
|
case "postUpdate":
|
|
@@ -11738,6 +11793,7 @@ var en = {
|
|
|
11738
11793
|
updatedCallbackUnknownPath: (p) => `"${p}" is not a path of this state, so it is never in $renderedCallback's paths and this branch never runs`,
|
|
11739
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})`,
|
|
11740
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`,
|
|
11741
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`,
|
|
11742
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`,
|
|
11743
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`,
|
|
@@ -11808,6 +11864,7 @@ var en = {
|
|
|
11808
11864
|
devtoolsAfterState: () => `Load @wcstack/devtools/auto before @wcstack/state/auto (loaded later, the DevTools timeline starts when it attaches; 4.0 sends it the wiring that is there already)`,
|
|
11809
11865
|
baseHrefMissing: () => `An SPA using @wcstack/router needs <base href="/"> in <head>, or a synchronous <head> script that creates one \u2014 the form for a locale in the basename (without it, deep links misderive the basename)`,
|
|
11810
11866
|
routerOutletMisplaced: () => `This <wcs-outlet> is not right after a <wcs-router>, so no router uses it: a router uses only the element right after it as its outlet, and makes an outlet of its own there when that is not a <wcs-outlet>. The routes render right after the router and this outlet stays empty \u2014 move it right after the <wcs-router>`,
|
|
11867
|
+
linkQueryKeyIgnored: (toKeys, named) => `None of the keys this <wcs-link>'s to sets (${toKeys}) is named in query-keys (${named}). A link with query-keys compares only the keys it names, so its own query plays no part: it is current wherever ${named} match, whatever ${toKeys} is \u2014 tabs written this way are all current at once. Name the keys the link is for (query-keys="${toKeys}")`,
|
|
11811
11868
|
signalsDualEntry: () => `Both @wcstack/signals and @wcstack/signals/dom are imported on this page. On a CDN each entry is a self-contained bundle, so the reactive core is duplicated and reactivity breaks at the seam \u2014 import everything from the single /dom entry`,
|
|
11812
11869
|
signalsImportMapBoth: () => `This import map maps both @wcstack/signals and @wcstack/signals/dom. On a CDN each entry carries its own reactive core, so a module that imports @wcstack/signals \u2014 this page's, or a .js file it loads \u2014 gets a second core and reactivity breaks at the seam. Map only @wcstack/signals/dom (it exports the whole core)`,
|
|
11813
11870
|
tagPackageMissing: (tags, pkg, url) => `${tags.map((t) => `<${t}>`).join(", ")} ${tags.length === 1 ? "is a tag" : "are tags"} of ${pkg}, and this page loads no script of ${pkg}: the element is never defined, so its bindings wait and nothing happens, without a word in the console. Load it with <script type="module" src="${url}"></script>`,
|
|
@@ -11838,6 +11895,8 @@ var en = {
|
|
|
11838
11895
|
return `$watch key "${p}" cannot contain "**" \u2014 watching is defined against a concrete path (a fixed number of "*")`;
|
|
11839
11896
|
case "resolve":
|
|
11840
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)`;
|
|
11841
11900
|
case "assignment":
|
|
11842
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`;
|
|
11843
11902
|
case "postUpdate":
|
|
@@ -15544,6 +15603,15 @@ function validateDocumentEnv(html, locale2) {
|
|
|
15544
15603
|
message: msgs.routerOutletMisplaced()
|
|
15545
15604
|
});
|
|
15546
15605
|
}
|
|
15606
|
+
for (const link of findLinksIgnoringOwnQuery(scanText)) {
|
|
15607
|
+
diagnostics.push({
|
|
15608
|
+
code: WcsDiagnosticCode.LinkQueryKeyIgnored,
|
|
15609
|
+
start: link.start,
|
|
15610
|
+
end: link.end,
|
|
15611
|
+
severity: "warning",
|
|
15612
|
+
message: msgs.linkQueryKeyIgnored(link.toKeys.join(" "), link.named.join(" "))
|
|
15613
|
+
});
|
|
15614
|
+
}
|
|
15547
15615
|
const refs = collectSignalsRefs(scanText);
|
|
15548
15616
|
const dom = refs.find((r) => r.kind === "dom");
|
|
15549
15617
|
const bare = refs.find((r) => r.kind === "bare");
|
|
@@ -15836,6 +15904,27 @@ function findMisplacedOutlets(html) {
|
|
|
15836
15904
|
});
|
|
15837
15905
|
return routerWithoutOutlet ? misplaced : [];
|
|
15838
15906
|
}
|
|
15907
|
+
var LINK_TAG = "wcs-link";
|
|
15908
|
+
function findLinksIgnoringOwnQuery(html) {
|
|
15909
|
+
const found = [];
|
|
15910
|
+
for (const region of findStartTagRegions(html)) {
|
|
15911
|
+
if (region.tagName !== LINK_TAG) continue;
|
|
15912
|
+
const content = html.slice(region.start, region.end);
|
|
15913
|
+
const to = extractAttribute(content, "to");
|
|
15914
|
+
const span = extractAttributeSpan(content, "query-keys", region.start);
|
|
15915
|
+
if (to === null || span === null) continue;
|
|
15916
|
+
const named = html.slice(span.valueStart, span.valueEnd).split(/[\s,]+/).filter((key) => key !== "");
|
|
15917
|
+
const target = to.replace(/&/gi, "&");
|
|
15918
|
+
const hash = target.indexOf("#");
|
|
15919
|
+
const beforeHash = hash === -1 ? target : target.slice(0, hash);
|
|
15920
|
+
const question = beforeHash.indexOf("?");
|
|
15921
|
+
if (question === -1 || named.length === 0) continue;
|
|
15922
|
+
const toKeys = [...new Set(new URLSearchParams(beforeHash.slice(question + 1)).keys())];
|
|
15923
|
+
if (toKeys.length === 0 || toKeys.some((key) => named.includes(key))) continue;
|
|
15924
|
+
found.push({ start: span.start, end: span.end, toKeys, named });
|
|
15925
|
+
}
|
|
15926
|
+
return found;
|
|
15927
|
+
}
|
|
15839
15928
|
|
|
15840
15929
|
// src/service/packageLoadValidator.ts
|
|
15841
15930
|
var CORE_TAG_PACKAGES = {
|
|
@@ -16391,9 +16480,10 @@ function validateScanDeclarations(html, stateTagName = "wcs-state", locale2) {
|
|
|
16391
16480
|
}
|
|
16392
16481
|
|
|
16393
16482
|
// src/service/recursionValidator.ts
|
|
16394
|
-
var RECURSION_APIS = ["getAll", "setAll", "resolve", "postUpdate", "dependOn", "trackDependency"];
|
|
16483
|
+
var RECURSION_APIS = ["getAll", "setAll", "resolve", "update", "postUpdate", "dependOn", "trackDependency"];
|
|
16395
16484
|
var UNSUPPORTED_API_SITE = {
|
|
16396
16485
|
$resolve: "resolve",
|
|
16486
|
+
$update: "update",
|
|
16397
16487
|
$postUpdate: "postUpdate",
|
|
16398
16488
|
$dependOn: "dependOn",
|
|
16399
16489
|
$trackDependency: "trackDependency"
|
|
@@ -16643,7 +16733,7 @@ function validateApiCalls(script, offset2, spec, getterSuffixes, undeclared, msg
|
|
|
16643
16733
|
const start = offset2 + parsed.starts[0] + leading;
|
|
16644
16734
|
const end = offset2 + parsed.starts[0] + pathArg.trimEnd().length;
|
|
16645
16735
|
if (!hasRecursionWildcard(path)) {
|
|
16646
|
-
const writes = api === "$setAll" || api === "$resolve" && parsed.args.length >= 3;
|
|
16736
|
+
const writes = api === "$setAll" || api === "$update" || api === "$resolve" && parsed.args.length >= 3;
|
|
16647
16737
|
if (writes && spec !== null) {
|
|
16648
16738
|
const owning = owningGetterSuffix(spec, getterSuffixes, path);
|
|
16649
16739
|
if (owning !== null) {
|
|
@@ -17394,7 +17484,7 @@ function validateNameAliases(script, scriptStart, locale2, mountPath = null) {
|
|
|
17394
17484
|
for (const span of spans) pushDeclaration(span.name, span.start, span.end, "error");
|
|
17395
17485
|
return out;
|
|
17396
17486
|
}
|
|
17397
|
-
var API_CALL = /\.\s*\$(getAll|setAll|resolve)\s*\(/g;
|
|
17487
|
+
var API_CALL = /\.\s*\$(getAll|setAll|resolve|update)\s*\(/g;
|
|
17398
17488
|
function validateIndexArity(script, scriptStart, locale2) {
|
|
17399
17489
|
const msgs = getMessages(locale2);
|
|
17400
17490
|
const out = [];
|
|
@@ -17413,7 +17503,7 @@ function validateIndexArity(script, scriptStart, locale2) {
|
|
|
17413
17503
|
const actual = literalArrayLength(parsed.args[1]);
|
|
17414
17504
|
if (actual === null) continue;
|
|
17415
17505
|
const wildcardCount = countWildcardSegments(path);
|
|
17416
|
-
const requirement = api === "$resolve" ? "exact" : "atMost";
|
|
17506
|
+
const requirement = api === "$resolve" || api === "$update" ? "exact" : "atMost";
|
|
17417
17507
|
const mismatched = requirement === "exact" ? actual !== wildcardCount : actual > wildcardCount;
|
|
17418
17508
|
if (!mismatched) continue;
|
|
17419
17509
|
const argText = parsed.args[1];
|
|
@@ -17771,7 +17861,7 @@ function collectNestedWriteRoots(html, stateTagName, bindAttrName, blocks) {
|
|
|
17771
17861
|
API_CALL.lastIndex = parsed.end;
|
|
17772
17862
|
const path = parsed.args.length > 0 ? literalString2(parsed.args[0]) : null;
|
|
17773
17863
|
if (path === null) continue;
|
|
17774
|
-
if (api === "setAll" || parsed.args.length >= 3) addPrefixes(path, false);
|
|
17864
|
+
if (api === "setAll" || api === "update" || parsed.args.length >= 3) addPrefixes(path, false);
|
|
17775
17865
|
}
|
|
17776
17866
|
}
|
|
17777
17867
|
return roots;
|
|
@@ -18108,9 +18198,12 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
|
|
|
18108
18198
|
}
|
|
18109
18199
|
}
|
|
18110
18200
|
for (const callable of analyzeCallableBodies(block.content)) {
|
|
18111
|
-
for (const read of collectGetterReads(callable.body) ?? []) {
|
|
18112
|
-
|
|
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;
|
|
18113
18205
|
const path = prefix + read.path;
|
|
18206
|
+
if (read.indexed !== void 0 && !read.indexed.every((list) => isList(prefix + list, candidates, candidateSet))) continue;
|
|
18114
18207
|
if (pathExistsInCandidates(path, candidates, candidateSet)) continue;
|
|
18115
18208
|
if (applicationSchema !== void 0 ? resolveIndexedSchemaPath(applicationSchema, path).kind !== "nonexistent" : isUnresolvedPath(path, index.scopes)) continue;
|
|
18116
18209
|
const near = nearName(path, tree ??= treeOf(candidates));
|
|
@@ -18118,19 +18211,24 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
|
|
|
18118
18211
|
const said = suggestion(near.segment, near.names, msgs);
|
|
18119
18212
|
if (said === "") continue;
|
|
18120
18213
|
const at2 = block.contentStart + callable.bodyStart;
|
|
18214
|
+
const member = read.form === "member" || read.form === "write";
|
|
18121
18215
|
out.push({
|
|
18122
|
-
code: WcsDiagnosticCode.ReadPathMissing,
|
|
18216
|
+
code: write ? WcsDiagnosticCode.WritePathMissing : WcsDiagnosticCode.ReadPathMissing,
|
|
18123
18217
|
start: at2 + read.start,
|
|
18124
|
-
end:
|
|
18125
|
-
message: msgs.readPathMissing(read.path, !read.path.includes(".")) + said,
|
|
18126
|
-
// a stateSchema says the path is not there, as for a binding's `wcs/path-nonexistent`
|
|
18127
|
-
|
|
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"
|
|
18128
18223
|
});
|
|
18129
18224
|
}
|
|
18130
18225
|
}
|
|
18131
18226
|
}
|
|
18132
18227
|
return out;
|
|
18133
18228
|
}
|
|
18229
|
+
function isList(path, candidates, candidateSet) {
|
|
18230
|
+
return candidateSet.has(`${path}.*`) || candidates.some((c) => c.path === path && c.kind === "list");
|
|
18231
|
+
}
|
|
18134
18232
|
var THIS_PART = /^this\s*(?:\?\.\s*|\.\s*)(?:[A-Za-z_$][\w$]*)|^this\s*(?:\?\.)?\s*\[\s*(["'`])[^"'`]*\1\s*\]/;
|
|
18135
18233
|
function statePart(text3) {
|
|
18136
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": {
|