@wcstack/lint 4.0.4 → 4.1.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 +63 -32
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -148,6 +148,7 @@ var WcsDiagnosticCode = {
|
|
|
148
148
|
// 静的にしか検出できない。対象はオブジェクトリテラル初期値のルートだけ(配列は `items`
|
|
149
149
|
// の依存で足りる — 行の置換は `items` 自体を書き換え、in-place 変異は array-mutation が止める)。
|
|
150
150
|
GetterUntrackedRead: "wcs/getter-untracked-read",
|
|
151
|
+
OnHandlerThis: "wcs/on-handler-this",
|
|
151
152
|
// --- <wcs-state> script: $watch declaration ---
|
|
152
153
|
// ランタイム(watch/processWatchDeclaration.ts)が raiseError で落とす宣言。
|
|
153
154
|
// 越境 `@` / `$` 始まり / 空キー・空セグメント / 明らかな非関数ハンドラ。
|
|
@@ -2812,9 +2813,15 @@ function analyzeWatchEntries(scriptContent) {
|
|
|
2812
2813
|
}));
|
|
2813
2814
|
}
|
|
2814
2815
|
function analyzeWatchHandlerSources(scriptContent) {
|
|
2816
|
+
return analyzeHandlerSources(scriptContent, RESERVED_WATCH_KEY);
|
|
2817
|
+
}
|
|
2818
|
+
function analyzeOnHandlerSources(scriptContent) {
|
|
2819
|
+
return analyzeHandlerSources(scriptContent, "$on");
|
|
2820
|
+
}
|
|
2821
|
+
function analyzeHandlerSources(scriptContent, key) {
|
|
2815
2822
|
const root = locateDefaultExportObject(scriptContent);
|
|
2816
2823
|
if (!root) return [];
|
|
2817
|
-
const prop = parseTopLevelProperties(root.content).find((p) => p.name ===
|
|
2824
|
+
const prop = parseTopLevelProperties(root.content).find((p) => p.name === key);
|
|
2818
2825
|
if (!prop || prop.kind !== "data" || !prop.value || !isObjectLiteral(prop.value) || prop.valueStart === void 0) {
|
|
2819
2826
|
return [];
|
|
2820
2827
|
}
|
|
@@ -2824,6 +2831,7 @@ function analyzeWatchHandlerSources(scriptContent) {
|
|
|
2824
2831
|
for (const entry of parseTopLevelProperties(extractObjectContent(prop.value))) {
|
|
2825
2832
|
if (entry.value === void 0 || entry.valueStart === void 0) continue;
|
|
2826
2833
|
out.push({
|
|
2834
|
+
name: entry.name,
|
|
2827
2835
|
kind: entry.kind === "data" ? "value" : "body",
|
|
2828
2836
|
text: entry.value,
|
|
2829
2837
|
start: innerStart + entry.valueStart
|
|
@@ -10518,6 +10526,7 @@ var ja = {
|
|
|
10518
10526
|
delegatedCurrentTarget: (suggested, eventName, handler) => `"${eventName}" \u30A4\u30D9\u30F3\u30C8\u306E\u675F\u7E1B\u306F root \u3078\u59D4\u8B72\u3055\u308C\u308B\u306E\u3067\u3001"${handler}" \u306E\u4E2D\u306E event.currentTarget \u306F\u3053\u306E\u8981\u7D20\u3067\u306F\u306A\u304F root \u306B\u306A\u308A\u307E\u3059\u3002\u8981\u7D20\u306B\u30EA\u30B9\u30CA\u30FC\u3092\u4ED8\u3051\u308B\u306B\u306F "${suggested}:" \u3068\u66F8\u304F\u304B\u3001event.target.closest(...) \u3067\u8981\u7D20\u3092\u63A2\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
10519
10527
|
getterCycle: (cycle) => `\u30D1\u30B9 getter \u304C\u5FAA\u74B0\u53C2\u7167\u3057\u3066\u3044\u307E\u3059: ${cycle}`,
|
|
10520
10528
|
updatedCallbackUnbound: (p) => `$renderedCallback \u306F binding \u99C6\u52D5\u3067\u3059\u3002"${p}" \u306F\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u3069\u306E\u30D0\u30A4\u30F3\u30C7\u30A3\u30F3\u30B0\u306B\u3082\u73FE\u308C\u306A\u3044\u305F\u3081\u3001\u3053\u306E\u5206\u5C90\u306F\u4E00\u5EA6\u3082\u5B9F\u884C\u3055\u308C\u307E\u305B\u3093\u3002\u63CF\u753B\u306B\u4F9D\u5B58\u305B\u305A\u53CD\u5FDC\u3059\u308B\u306A\u3089 $watch \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044`,
|
|
10529
|
+
onHandlerThis: (name) => `$on \u306E\u30CF\u30F3\u30C9\u30E9 "${name}" \u304C this \u3092\u4F7F\u3063\u3066\u3044\u307E\u3059\u3002$on \u306E\u30CF\u30F3\u30C9\u30E9\u306F state \u3092\u7B2C 1 \u5F15\u6570\u3067\u53D7\u3051\u53D6\u308A\uFF08\`${name}(state, event) { state.x = \u2026 }\`\uFF09\u3001this \u306F undefined \u306A\u306E\u3067\u3001this.\u2026 \u306F\u547C\u3070\u308C\u305F\u3068\u304D\u306B\u4F8B\u5916\u306B\u306A\u308A\u307E\u3059\u3002$watch \u3084\u30E1\u30BD\u30C3\u30C9\u3068\u9055\u3046\u70B9\u306B\u6CE8\u610F`,
|
|
10521
10530
|
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`,
|
|
10522
10531
|
handlerFilterNotAllowed: (prop) => `\u30A4\u30D9\u30F3\u30C8\u30CF\u30F3\u30C9\u30E9 "${prop}" \u306B\u30D5\u30A3\u30EB\u30BF\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093`,
|
|
10523
10532
|
typeExpectation: (label, expected, resultType) => `"${label}" \u306B\u306F${JA_EXPECTED_LABEL[expected]}\u304C\u5FC5\u8981\u3067\u3059\uFF08\u73FE\u5728\u306E\u578B: ${resultType}\uFF09`,
|
|
@@ -10568,7 +10577,7 @@ var ja = {
|
|
|
10568
10577
|
didYouMean: (c) => `\u3002\u3082\u3057\u304B\u3057\u3066: "${c}"`,
|
|
10569
10578
|
none: () => `\u306A\u3057`,
|
|
10570
10579
|
triggerSeededTruthy: (path) => `trigger \u30D0\u30A4\u30F3\u30C9\u5148 "${path}" \u304C true \u3067\u30B7\u30FC\u30C9\u3055\u308C\u3066\u3044\u307E\u3059\u3002trigger \u306F\u30A8\u30C3\u30B8\u691C\u51FA\u306A\u3057\uFF08truthy \u66F8\u304D\u8FBC\u307F\u3067\u5373\u767A\u706B\u30FBmanual \u3082\u30D0\u30A4\u30D1\u30B9\uFF09\u306E\u305F\u3081\u3001\u30D0\u30A4\u30F3\u30C9\u6642\u306B\u5373\u767A\u706B\u3057\u307E\u3059\u3002false \u3067\u30B7\u30FC\u30C9\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
10571
|
-
storageSeedClobber: (path, raw) => `<wcs-storage> \u306E value \u30D0\u30A4\u30F3\u30C9\u5148 "${path}" \u304C ${raw} \u3067\u30B7\u30FC\u30C9\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u8AAD\u307F\u8FBC\u307F\u306E\u305F\u3073\u306B\u521D\u671F\u66F8\u304D\u623B\u3057\u304C\u4FDD\u5B58\u5024\u3092\u4E0A\u66F8\u304D\u3057\u307E\u3059 \u2014 \u30D0\u30A4\u30F3\u30C9\u306B #init=element \u3092\u4ED8\u3051\u3066\uFF08\`value#init=element: ${path}\`\uFF09\u4FDD\u5B58\u5024\u3092\u52DD\u305F\u305B\u3001\u30B9\u30ED\u30C3\u30C8\u306F null\uFF08\u7A7A\u306E\u30AD\u30FC\u304C\u8AAD\u3080\u5024\uFF09\u3067\u30B7\u30FC\u30C9\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
10580
|
+
storageSeedClobber: (path, raw) => `<wcs-storage> \u306E value \u30D0\u30A4\u30F3\u30C9\u5148 "${path}" \u304C ${shortSeed(raw)} \u3067\u30B7\u30FC\u30C9\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u8AAD\u307F\u8FBC\u307F\u306E\u305F\u3073\u306B\u521D\u671F\u66F8\u304D\u623B\u3057\u304C\u4FDD\u5B58\u5024\u3092\u4E0A\u66F8\u304D\u3057\u307E\u3059 \u2014 \u30D0\u30A4\u30F3\u30C9\u306B #init=element \u3092\u4ED8\u3051\u3066\uFF08\`value#init=element: ${path}\`\uFF09\u4FDD\u5B58\u5024\u3092\u52DD\u305F\u305B\u3001\u30B9\u30ED\u30C3\u30C8\u306F null\uFF08\u7A7A\u306E\u30AD\u30FC\u304C\u8AAD\u3080\u5024\uFF09\u3067\u30B7\u30FC\u30C9\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
10572
10581
|
storageInitSeed: (path, raw) => `<wcs-storage> \u306E value \u30D0\u30A4\u30F3\u30C9\u5148 "${path}" \u304C ${shortSeed(raw)} \u3067\u30B7\u30FC\u30C9\u3055\u308C\u3066\u3044\u307E\u3059\u304C\u3001#init=element \u306F\u8981\u7D20\u306E\u5024\u3092\u3053\u306E\u30B9\u30ED\u30C3\u30C8\u3078\u5F15\u304D\u8FBC\u307F\u307E\u3059\u3002\u521D\u56DE\uFF08\u7A7A\u306E\u30AD\u30FC\uFF09\u306F null \u306A\u306E\u3067\u3001\u30B7\u30FC\u30C9\u306F null \u306B\u7F6E\u304D\u63DB\u308F\u308A\u307E\u3059 \u2014 null \u3067\u30B7\u30FC\u30C9\u3057\u3066\u8AAD\u3080\u5074\u3067\u65E2\u5B9A\u5024\u3092\u88DC\u3046\uFF08\`this.${path} ?? \u2026\`\uFF09\u304B\u3001null \u3092\u7121\u8996\u3059\u308B setter \u3092\u6301\u3064\u30A2\u30AF\u30BB\u30B5\u30DA\u30A2\u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044`,
|
|
10573
10582
|
storagePairClobber: (path) => `<wcs-storage> \u306E value \u3092 #init=element \u306A\u3057\u3067\u30A2\u30AF\u30BB\u30B5\u30DA\u30A2 "${path}" \u306B\u675F\u306D\u3066\u3044\u307E\u3059\u3002state \u306E\u5074\u304C\u5148\u306B\u66F8\u304F\u306E\u3067\u3001\u8AAD\u307F\u8FBC\u307F\u306E\u305F\u3073\u306B getter \u306E\u6700\u521D\u306E\u5024\u304C\u4FDD\u5B58\u5024\u306E\u4E0A\u306B\u4FDD\u5B58\u3055\u308C\u3001setter \u306F\u4FDD\u5B58\u5024\u3092\u53D7\u3051\u53D6\u308C\u307E\u305B\u3093 \u2014 #init=element \u3092\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\uFF08\`value#init=element: ${path}\`\uFF09`,
|
|
10574
10583
|
inputNestedWrite: (tag, input, path, example) => `<${tag}> \u306E\u5165\u529B "${input}" \u306B "${path}" \u3092\u675F\u306D\u3066\u3044\u307E\u3059\u304C\u3001\u30DA\u30FC\u30B8\u306F\u305D\u306E\u4E0B\uFF08"${example}"\uFF09\u3078\u66F8\u304D\u8FBC\u3093\u3067\u3044\u307E\u3059\u3002\u675F\u7E1B\u306F "${path}" \u81EA\u8EAB\u3078\u306E\u4EE3\u5165\u3067\u3057\u304B\u5F53\u3066\u76F4\u3055\u308C\u306A\u3044\u306E\u3067\u3001\u4E0B\u3078\u306E\u66F8\u304D\u8FBC\u307F\u306F <${tag}> \u306B\u5C4A\u304D\u307E\u305B\u3093 \u2014 \u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u30D1\u30B9\u3067\u8AAD\u3093\u3067\u65B0\u3057\u3044\u5024\u3092\u8FD4\u3059 getter\uFF08\`this["${example}"]\`\u30FB\`$getAll\`\uFF09\u3092\u675F\u306D\u308B\u304B\u3001\u4E0B\u3078\u66F8\u304B\u305A\u306B "${path}" \u3092\u5DEE\u3057\u66FF\u3048\u3066\u304F\u3060\u3055\u3044`,
|
|
@@ -10709,6 +10718,7 @@ var en = {
|
|
|
10709
10718
|
delegatedCurrentTarget: (suggested, eventName, handler) => `"${eventName}" bindings are delegated to the root, so event.currentTarget in "${handler}" is the root, not this element. Write "${suggested}:" to keep the listener on the element, or find the element with event.target.closest(...)`,
|
|
10710
10719
|
getterCycle: (cycle) => `Path getters form a dependency cycle: ${cycle}`,
|
|
10711
10720
|
updatedCallbackUnbound: (p) => `$renderedCallback is binding-driven. "${p}" is not bound anywhere in this document, so this branch never runs. Use $watch to react without depending on what is rendered`,
|
|
10721
|
+
onHandlerThis: (name) => `The $on handler "${name}" uses this. A $on handler receives the state as its first argument (\`${name}(state, event) { state.x = \u2026 }\`) and this is undefined, so this.\u2026 throws when it is called \u2014 unlike $watch handlers and methods`,
|
|
10712
10722
|
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`,
|
|
10713
10723
|
handlerFilterNotAllowed: (prop) => `Filters cannot be applied to event handler "${prop}"`,
|
|
10714
10724
|
typeExpectation: (label, expected, resultType) => `"${label}" requires ${EN_EXPECTED_LABEL[expected]} (current type: ${resultType})`,
|
|
@@ -10759,7 +10769,7 @@ var en = {
|
|
|
10759
10769
|
didYouMean: (c) => `. Did you mean "${c}"?`,
|
|
10760
10770
|
none: () => `none`,
|
|
10761
10771
|
triggerSeededTruthy: (path) => `The trigger-bound slot "${path}" is seeded with true. trigger has no edge detection (any truthy write fires, and it bypasses manual), so it fires immediately at bind. Seed it with false`,
|
|
10762
|
-
storageSeedClobber: (path, raw) => `The <wcs-storage> value-bound slot "${path}" is seeded with ${raw}. The initial write-back overwrites the persisted value on every load \u2014 add #init=element to the binding (\`value#init=element: ${path}\`) so the stored value wins, and seed the slot with null (what an empty key loads as)`,
|
|
10772
|
+
storageSeedClobber: (path, raw) => `The <wcs-storage> value-bound slot "${path}" is seeded with ${shortSeed(raw)}. The initial write-back overwrites the persisted value on every load \u2014 add #init=element to the binding (\`value#init=element: ${path}\`) so the stored value wins, and seed the slot with null (what an empty key loads as)`,
|
|
10763
10773
|
storageInitSeed: (path, raw) => `The <wcs-storage> value-bound slot "${path}" is seeded with ${shortSeed(raw)}, but #init=element pulls the element's value into it. On a first visit (an empty key) that is null, so the seed is replaced by null \u2014 seed it with null and supply the default where you read it (\`this.${path} ?? \u2026\`), or bind an accessor pair whose setter ignores null`,
|
|
10764
10774
|
storagePairClobber: (path) => `The <wcs-storage> value is bound to the accessor pair "${path}" without #init=element. The state's side goes first, so on every load the getter's starting value is saved over the stored one, and the setter never receives it \u2014 add #init=element (\`value#init=element: ${path}\`)`,
|
|
10765
10775
|
inputNestedWrite: (tag, input, path, example) => `"${path}" is bound to the input "${input}" of <${tag}>, but the page writes below it ("${example}"). A binding is re-applied only when "${path}" itself is assigned, so those writes never reach <${tag}> \u2014 bind a getter that reads the fields by path (\`this["${example}"]\`, \`$getAll\`) and returns a new value, or replace "${path}" instead of writing below it`,
|
|
@@ -13820,7 +13830,6 @@ var EXPLICIT_PROPERTY_REJECTED_HEADS2 = /* @__PURE__ */ new Set([
|
|
|
13820
13830
|
var EXPLICIT_PROPERTY_REJECTED_HEADS_RE = new RegExp(
|
|
13821
13831
|
`^(?:${[...EXPLICIT_PROPERTY_REJECTED_HEADS2].map((w) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})(\\.|$)`
|
|
13822
13832
|
);
|
|
13823
|
-
var EMPTYISH_SEEDS = /* @__PURE__ */ new Set(["''", '""', "``", "null", "[]", "{}"]);
|
|
13824
13833
|
function validateIoNodes(html, bindAttribute = "data-wcs", stateTagName = "wcs-state", locale2, fileReader) {
|
|
13825
13834
|
const diagnostics = [];
|
|
13826
13835
|
const msgs = getMessages(locale2);
|
|
@@ -13967,12 +13976,12 @@ function validateBindingAgainstContract(tagName, contract, parsed, property, sta
|
|
|
13967
13976
|
if (tagName === "wcs-storage" && property === "value" && !hasManual && parsed.path && !/(?:^|,)init=(?:element|auto)\b/.test(modifiers)) {
|
|
13968
13977
|
const paths = getPaths();
|
|
13969
13978
|
const cand = findDataSlot(paths, parsed.path);
|
|
13970
|
-
if (cand?.rawInitial !== void 0 &&
|
|
13979
|
+
if (cand?.rawInitial !== void 0 && (cand.rawInitial.trim() === "null" || isNonNullLiteralSeed(cand.rawInitial))) {
|
|
13971
13980
|
diagnostics.push({
|
|
13972
13981
|
code: WcsDiagnosticCode.StorageSeedClobber,
|
|
13973
13982
|
start,
|
|
13974
13983
|
end,
|
|
13975
|
-
severity: "
|
|
13984
|
+
severity: "error",
|
|
13976
13985
|
tag: tagName,
|
|
13977
13986
|
statePath: parsed.path,
|
|
13978
13987
|
message: msgs.storageSeedClobber(parsed.path, cand.rawInitial)
|
|
@@ -13982,7 +13991,7 @@ function validateBindingAgainstContract(tagName, contract, parsed, property, sta
|
|
|
13982
13991
|
code: WcsDiagnosticCode.StorageSeedClobber,
|
|
13983
13992
|
start,
|
|
13984
13993
|
end,
|
|
13985
|
-
severity: "
|
|
13994
|
+
severity: "error",
|
|
13986
13995
|
tag: tagName,
|
|
13987
13996
|
statePath: parsed.path,
|
|
13988
13997
|
message: msgs.storagePairClobber(parsed.path)
|
|
@@ -14011,10 +14020,6 @@ function isNonNullLiteralSeed(raw) {
|
|
|
14011
14020
|
function findDataSlot(paths, path) {
|
|
14012
14021
|
return paths.find((c) => c.kind === "data" && c.path === path);
|
|
14013
14022
|
}
|
|
14014
|
-
function normalizeSeed(raw) {
|
|
14015
|
-
const compact = raw.replace(/\s+/g, "");
|
|
14016
|
-
return compact === "" ? raw : compact;
|
|
14017
|
-
}
|
|
14018
14023
|
function findBuiltinTagOccurrences(html) {
|
|
14019
14024
|
const out = [];
|
|
14020
14025
|
const regex = /<(wcs-[a-z0-9-]+)((?:"[^"]*"|'[^']*'|[^>"'])*)>/gi;
|
|
@@ -14157,7 +14162,8 @@ function validateDocumentEnv(html, locale2) {
|
|
|
14157
14162
|
});
|
|
14158
14163
|
}
|
|
14159
14164
|
}
|
|
14160
|
-
const
|
|
14165
|
+
const hasRouterTag = /<wcs-router\b/i.test(scanText);
|
|
14166
|
+
const router = autos.find((a) => a.pkgs.includes("router") && (!a.bundle || hasRouterTag)) ?? (hasRouterTag ? collectInlineImports(scanText).find((i) => /@wcstack\/router\b/.test(i.spec) || BUNDLE_AUTO.test(i.spec)) : void 0);
|
|
14161
14167
|
if (router && !/<base\b[^>]*\bhref\s*=/i.test(scanText)) {
|
|
14162
14168
|
diagnostics.push({
|
|
14163
14169
|
code: WcsDiagnosticCode.BaseHrefMissing,
|
|
@@ -14215,35 +14221,41 @@ function findWcstackAutoScripts(html) {
|
|
|
14215
14221
|
}
|
|
14216
14222
|
function collectSignalsRefs(html) {
|
|
14217
14223
|
const refs = [];
|
|
14218
|
-
const scriptRegex = /<script\b((?:"[^"]*"|'[^']*'|[^>"'])*)
|
|
14224
|
+
const scriptRegex = /<script\b((?:"[^"]*"|'[^']*'|[^>"'])*)>/gi;
|
|
14219
14225
|
let match;
|
|
14220
14226
|
while ((match = scriptRegex.exec(html)) !== null) {
|
|
14221
|
-
const
|
|
14222
|
-
const
|
|
14223
|
-
if (src) {
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
end: match.index + src.offsetInTag + src.value.length
|
|
14230
|
-
});
|
|
14231
|
-
}
|
|
14232
|
-
continue;
|
|
14227
|
+
const src = extractSrc(match[0]);
|
|
14228
|
+
const kind = src ? classifySignalsSpecifier(src.value) : null;
|
|
14229
|
+
if (src && kind) {
|
|
14230
|
+
refs.push({
|
|
14231
|
+
kind,
|
|
14232
|
+
start: match.index + src.offsetInTag,
|
|
14233
|
+
end: match.index + src.offsetInTag + src.value.length
|
|
14234
|
+
});
|
|
14233
14235
|
}
|
|
14234
|
-
|
|
14236
|
+
}
|
|
14237
|
+
for (const im of collectInlineImports(html)) {
|
|
14238
|
+
const kind = classifySignalsSpecifier(im.spec);
|
|
14239
|
+
if (kind) refs.push({ kind, start: im.start, end: im.end });
|
|
14240
|
+
}
|
|
14241
|
+
return refs.sort((a, b) => a.start - b.start);
|
|
14242
|
+
}
|
|
14243
|
+
function collectInlineImports(html) {
|
|
14244
|
+
const out = [];
|
|
14245
|
+
const scriptRegex = /<script\b((?:"[^"]*"|'[^']*'|[^>"'])*)>([\s\S]*?)<\/script\s*>/gi;
|
|
14246
|
+
let match;
|
|
14247
|
+
while ((match = scriptRegex.exec(html)) !== null) {
|
|
14248
|
+
if (extractSrc(`<script${match[1]}>`) || !/\btype\s*=\s*(["'])module\1/i.test(match[1])) continue;
|
|
14235
14249
|
const bodyStart = match.index + match[0].indexOf(">") + 1;
|
|
14236
14250
|
const body = blankJsComments(match[2]);
|
|
14237
|
-
const importRegex = /(?:\bfrom\s*|\bimport\s*\(?\s*)(["'])([^"']
|
|
14251
|
+
const importRegex = /(?:\bfrom\s*|\bimport\s*\(?\s*)(["'])([^"']*)\1/g;
|
|
14238
14252
|
let im;
|
|
14239
14253
|
while ((im = importRegex.exec(body)) !== null) {
|
|
14240
|
-
const
|
|
14241
|
-
|
|
14242
|
-
const specStart = bodyStart + im.index + im[0].indexOf(im[1]) + 1;
|
|
14243
|
-
refs.push({ kind, start: specStart, end: specStart + im[2].length });
|
|
14254
|
+
const start = bodyStart + im.index + im[0].indexOf(im[1]) + 1;
|
|
14255
|
+
out.push({ spec: im[2], start, end: start + im[2].length });
|
|
14244
14256
|
}
|
|
14245
14257
|
}
|
|
14246
|
-
return
|
|
14258
|
+
return out;
|
|
14247
14259
|
}
|
|
14248
14260
|
function classifySignalsSpecifier(spec) {
|
|
14249
14261
|
if (!spec.includes("@wcstack/signals")) return null;
|
|
@@ -15906,6 +15918,24 @@ function hasOutOfRangeIndexName(script) {
|
|
|
15906
15918
|
}
|
|
15907
15919
|
return false;
|
|
15908
15920
|
}
|
|
15921
|
+
var ANY_MEMBER = { has: () => true };
|
|
15922
|
+
function validateOnHandlerThis(script, scriptStart, locale2) {
|
|
15923
|
+
const msgs = getMessages(locale2);
|
|
15924
|
+
const out = [];
|
|
15925
|
+
for (const handler of analyzeOnHandlerSources(script)) {
|
|
15926
|
+
const refs = handler.kind === "body" ? collectThisMemberRefs(handler.text, ANY_MEMBER) : collectThisMemberRefsInValue(handler.text, ANY_MEMBER);
|
|
15927
|
+
const first = refs?.[0];
|
|
15928
|
+
if (first === void 0) continue;
|
|
15929
|
+
out.push({
|
|
15930
|
+
code: WcsDiagnosticCode.OnHandlerThis,
|
|
15931
|
+
start: scriptStart + handler.start + first.start,
|
|
15932
|
+
end: scriptStart + handler.start + first.end,
|
|
15933
|
+
severity: "error",
|
|
15934
|
+
message: msgs.onHandlerThis(handler.name)
|
|
15935
|
+
});
|
|
15936
|
+
}
|
|
15937
|
+
return out;
|
|
15938
|
+
}
|
|
15909
15939
|
function validateSemantics(html, stateTagName = "wcs-state", locale2, bindAttrName = "data-wcs") {
|
|
15910
15940
|
const out = [];
|
|
15911
15941
|
const blocks = parseLoadedScriptBlocks(html, stateTagName);
|
|
@@ -15917,6 +15947,7 @@ function validateSemantics(html, stateTagName = "wcs-state", locale2, bindAttrNa
|
|
|
15917
15947
|
out.push(...validateIndexParamReads(block.content, block.contentStart, locale2));
|
|
15918
15948
|
out.push(...validateGetterCycles(block.content, block.contentStart, locale2));
|
|
15919
15949
|
out.push(...validateGetterUntrackedReads(block.content, block.contentStart, getNestedWriteRoots, locale2));
|
|
15950
|
+
out.push(...validateOnHandlerThis(block.content, block.contentStart, locale2));
|
|
15920
15951
|
}
|
|
15921
15952
|
out.push(...validateInputNestedWrites(html, stateTagName, bindAttrName, getNestedWriteRoots, locale2));
|
|
15922
15953
|
out.push(...validateUpdatedCallbackDemand(html, stateTagName, bindAttrName, locale2));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/lint",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.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": {
|