@wcstack/lint 4.0.0-rc.4 → 4.0.0-rc.5
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 +75 -36
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -950,10 +950,11 @@ var SENTENCES = {
|
|
|
950
950
|
1201
|
|
951
951
|
/* CommandRightSide */
|
|
952
952
|
]: (prop, p) => `"${prop}: ${p}": the right-hand side must be $command.<name>`,
|
|
953
|
+
// a native element's command (no hyphen: never a custom element) is the native-commands add-on's
|
|
953
954
|
[
|
|
954
955
|
1202
|
|
955
956
|
/* NoBindable */
|
|
956
|
-
]: (tag, what) => `<${tag}> declares no static wcBindable (${what})
|
|
957
|
+
]: (tag, what) => `<${tag}> declares no static wcBindable (${what}).${!tag.includes("-") && what.startsWith("command.") ? " A native element's command needs the add-on @wcstack/state/features/native-commands." : ""}`,
|
|
957
958
|
[
|
|
958
959
|
1203
|
|
959
960
|
/* NoCommand */
|
|
@@ -962,6 +963,10 @@ var SENTENCES = {
|
|
|
962
963
|
1204
|
|
963
964
|
/* NoProperty */
|
|
964
965
|
]: (tag, prop) => `<${tag}> declares no property "${prop}".`,
|
|
966
|
+
[
|
|
967
|
+
1205
|
|
968
|
+
/* NativeNoCommand */
|
|
969
|
+
]: (tag, method, allowed) => `<${tag}> has no command "${method}" (a native <${tag}>'s commands: ${allowed}).`,
|
|
965
970
|
[
|
|
966
971
|
1301
|
|
967
972
|
/* EventTokenUndeclared */
|
|
@@ -1639,7 +1644,17 @@ var config = {
|
|
|
1639
1644
|
locale: typeof document !== "undefined" ? document.documentElement?.lang || "en" : "en",
|
|
1640
1645
|
enableContractAnalyzer: false
|
|
1641
1646
|
};
|
|
1642
|
-
var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools"];
|
|
1647
|
+
var FEATURE_NAMES = ["formats", "diagnostics", "temporal", "list-keys", "scopes", "recursion", "ssr", "devtools", "native-commands"];
|
|
1648
|
+
var NATIVE_COMMANDS = {
|
|
1649
|
+
"*": ["focus", "blur", "click", "scrollIntoView", "showPopover", "hidePopover", "togglePopover"],
|
|
1650
|
+
"dialog": ["show", "showModal", "close", "requestClose"],
|
|
1651
|
+
"form": ["requestSubmit", "checkValidity", "reportValidity"],
|
|
1652
|
+
"input": ["select", "setSelectionRange", "showPicker", "setCustomValidity", "checkValidity", "reportValidity"],
|
|
1653
|
+
"textarea": ["select", "setSelectionRange", "setCustomValidity", "checkValidity", "reportValidity"],
|
|
1654
|
+
"select": ["showPicker", "setCustomValidity", "checkValidity", "reportValidity"],
|
|
1655
|
+
"audio": ["play", "pause", "load"],
|
|
1656
|
+
"video": ["play", "pause", "load"]
|
|
1657
|
+
};
|
|
1643
1658
|
var WILDCARD2 = "*";
|
|
1644
1659
|
function optionsRequired(fnName) {
|
|
1645
1660
|
raise2(26, [fnName]);
|
|
@@ -2151,10 +2166,18 @@ function getWcsManifest() {
|
|
|
2151
2166
|
],
|
|
2152
2167
|
// every option is a boolean, true when left out (engine.ts `loadTarget`: `typeof … === "boolean"`, `?? true`)
|
|
2153
2168
|
behaviorOptions: Object.fromEntries(BEHAVIOR_OPTION_KEYS.map((key) => [key, { type: "boolean", default: true }])),
|
|
2154
|
-
features: [...FEATURE_NAMES]
|
|
2169
|
+
features: [...FEATURE_NAMES],
|
|
2170
|
+
nativeCommands: Object.fromEntries(Object.entries(NATIVE_COMMANDS).map(([tag, methods]) => [tag, [...methods]]))
|
|
2155
2171
|
};
|
|
2156
2172
|
}
|
|
2157
2173
|
|
|
2174
|
+
// src/service/wcsManifest.ts
|
|
2175
|
+
var NATIVE_COMMANDS2 = getWcsManifest().nativeCommands ?? null;
|
|
2176
|
+
function nativeCommandsOf(tag) {
|
|
2177
|
+
if (NATIVE_COMMANDS2 === null) return null;
|
|
2178
|
+
return [...NATIVE_COMMANDS2["*"] ?? [], ...Object.hasOwn(NATIVE_COMMANDS2, tag) ? NATIVE_COMMANDS2[tag] : []];
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2158
2181
|
// src/service/completionData.ts
|
|
2159
2182
|
var BUILTIN_FILTERS = Object.entries(builtinFilterMeta).map(
|
|
2160
2183
|
([name, meta]) => ({ name, ...meta })
|
|
@@ -2170,6 +2193,41 @@ var STRUCTURAL_DIRECTIVES = [...STRUCTURAL_BINDING_TYPE_SET2].map((name) => ({
|
|
|
2170
2193
|
...STRUCTURAL_DIRECTIVE_INFO[name]
|
|
2171
2194
|
}));
|
|
2172
2195
|
|
|
2196
|
+
// src/service/suggestion.ts
|
|
2197
|
+
function suggestion(input, candidates, msgs) {
|
|
2198
|
+
let best = null;
|
|
2199
|
+
let bestDistance = 3;
|
|
2200
|
+
for (const c of candidates) {
|
|
2201
|
+
const d = editDistance2(input.toLowerCase(), c.toLowerCase(), bestDistance);
|
|
2202
|
+
if (d < bestDistance) {
|
|
2203
|
+
best = c;
|
|
2204
|
+
bestDistance = d;
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
return best !== null ? msgs.didYouMean(best) : "";
|
|
2208
|
+
}
|
|
2209
|
+
function editDistance2(a, b, bound) {
|
|
2210
|
+
if (Math.abs(a.length - b.length) >= bound) return bound;
|
|
2211
|
+
const prev = new Array(b.length + 1);
|
|
2212
|
+
const curr = new Array(b.length + 1);
|
|
2213
|
+
for (let j = 0; j <= b.length; j++) prev[j] = j;
|
|
2214
|
+
for (let i = 1; i <= a.length; i++) {
|
|
2215
|
+
curr[0] = i;
|
|
2216
|
+
let rowMin = curr[0];
|
|
2217
|
+
for (let j = 1; j <= b.length; j++) {
|
|
2218
|
+
curr[j] = Math.min(
|
|
2219
|
+
prev[j] + 1,
|
|
2220
|
+
curr[j - 1] + 1,
|
|
2221
|
+
prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1)
|
|
2222
|
+
);
|
|
2223
|
+
if (curr[j] < rowMin) rowMin = curr[j];
|
|
2224
|
+
}
|
|
2225
|
+
if (rowMin >= bound) return bound;
|
|
2226
|
+
for (let j = 0; j <= b.length; j++) prev[j] = curr[j];
|
|
2227
|
+
}
|
|
2228
|
+
return Math.min(prev[b.length], bound);
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2173
2231
|
// src/service/recursionPaths.ts
|
|
2174
2232
|
var RECURSION_WILDCARD2 = "**";
|
|
2175
2233
|
var RECURSION_KEY = "$recursion";
|
|
@@ -9897,6 +9955,7 @@ var ja = {
|
|
|
9897
9955
|
featuresAttrNotRoot: () => `features \u5C5E\u6027\u3092\u8AAD\u3080\u306E\u306F\u6587\u66F8\u306E root \u306E <wcs-state>\uFF08mount \u3068 bind-component \u3092\u6301\u305F\u306A\u3044\u6700\u521D\u306E\u3082\u306E\uFF09\u3060\u3051\u3067\u3059\u3002\u3053\u306E\u8981\u7D20\u306E features \u306F\u7121\u8996\u3055\u308C\u307E\u3059 \u2014 root \u306E <wcs-state> \u306B\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
|
|
9898
9956
|
onPrefixedMember: (member, tag, modifiers) => `"${member}" \u306F <${tag}> \u306E\u30E1\u30F3\u30D0\u30FC\u3067\u3059\u304C\u3001"on" \u3067\u59CB\u307E\u308B\u540D\u524D\u306F\u30A4\u30D9\u30F3\u30C8\u675F\u7E1B\u306B\u306A\u308A\uFF08"${member.slice(2)}" \u30A4\u30D9\u30F3\u30C8\u3092\u5F85\u3064\uFF09\u3001\u5024\u306F\u5C4A\u304D\u307E\u305B\u3093\u3002\u30D7\u30ED\u30D1\u30C6\u30A3\u3068\u3057\u3066\u675F\u7E1B\u3059\u308B\u306B\u306F ".${member}${modifiers ? `#${modifiers}` : ""}:" \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\uFF08@wcstack/state 3.1\uFF09`,
|
|
9899
9957
|
tagCommandUnknown: (name, tag, declared) => `"${name}" \u306F <${tag}> \u306E command \u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08\u5BA3\u8A00\u6E08\u307F: ${declared}\uFF09`,
|
|
9958
|
+
nativeCommandUnknown: (method, tag, allowed) => `"${method}" \u306F\u30CD\u30A4\u30C6\u30A3\u30D6\u306E <${tag}> \u306B command \u3067\u547C\u3079\u308B\u30E1\u30BD\u30C3\u30C9\u3067\u306F\u3042\u308A\u307E\u305B\u3093\uFF08\u547C\u3079\u308B\u306E\u306F ${allowed}\u3002\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u521D\u671F\u5316\u3067 wcs/token-misconfigured \u3092\u6295\u3052\u307E\u3059\uFF09`,
|
|
9900
9959
|
spreadNoBindable: (tag) => `'...'\uFF08spread\uFF09\u306F <${tag}> \u306B\u6709\u52B9\u306A wcBindable \u5BA3\u8A00\u304C\u5FC5\u8981\u3067\u3059 \u2014 \u3053\u306E\u30BF\u30B0\u306F\u5BA3\u8A00\u3092\u6301\u305F\u306A\u3044\u305F\u3081\u3001\u30E9\u30F3\u30BF\u30A4\u30E0\u306F\u30A8\u30E9\u30FC\u3092\u9001\u51FA\u3057\u307E\u3059`,
|
|
9901
9960
|
tagEventTokenKeyUnknown: (name, tag, declared) => `eventToken \u306E\u30AD\u30FC "${name}" \u306F <${tag}> \u306E wcBindable \u30D7\u30ED\u30D1\u30C6\u30A3\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u751F DOM \u30A4\u30D9\u30F3\u30C8\u540D\u306F\u767A\u706B\u3057\u307E\u305B\u3093 \u2014 \u30D7\u30ED\u30D1\u30C6\u30A3\u540D\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u5BA3\u8A00\u6E08\u307F: ${declared}\uFF09`,
|
|
9902
9961
|
ariaAttrUnknown: (name) => `"${name}" \u306F WAI-ARIA \u306E\u5C5E\u6027\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002setAttribute \u306F\u305D\u306E\u307E\u307E\u66F8\u304D\u8FBC\u307F\u307E\u3059\u304C\u3001\u652F\u63F4\u6280\u8853\u306B\u306F\u9ED9\u3063\u3066\u7121\u8996\u3055\u308C\u307E\u3059`,
|
|
@@ -10082,6 +10141,7 @@ var en = {
|
|
|
10082
10141
|
featuresAttrNotRoot: () => `The features attribute is read only on the document's root <wcs-state> (the first one without mount and bind-component); it is ignored here \u2014 put it on the root <wcs-state>`,
|
|
10083
10142
|
onPrefixedMember: (member, tag, modifiers) => `"${member}" is a member of <${tag}>, but a name starting with "on" makes an event binding (it listens for a "${member.slice(2)}" event) and the value never arrives. Write ".${member}${modifiers ? `#${modifiers}` : ""}:" to bind the property (@wcstack/state 3.1)`,
|
|
10084
10143
|
tagCommandUnknown: (name, tag, declared) => `"${name}" is not a command of <${tag}> (declared: ${declared})`,
|
|
10144
|
+
nativeCommandUnknown: (method, tag, allowed) => `"${method}" is not a command of a native <${tag}> (its commands: ${allowed}; the runtime throws wcs/token-misconfigured at initialization)`,
|
|
10085
10145
|
spreadNoBindable: (tag) => `'...' (spread) requires <${tag}> to expose a valid wcBindable declaration \u2014 this tag declares none, so the runtime raises an error`,
|
|
10086
10146
|
tagEventTokenKeyUnknown: (name, tag, declared) => `eventToken key "${name}" is not a wcBindable property of <${tag}>. Raw DOM event names never fire \u2014 use the property name (declared: ${declared})`,
|
|
10087
10147
|
ariaAttrUnknown: (name) => `"${name}" is not a WAI-ARIA attribute. setAttribute writes it anyway, and assistive technology silently ignores it`,
|
|
@@ -10664,6 +10724,18 @@ function validateBindings(html, attrName, stateTagName = "wcs-state", locale2, f
|
|
|
10664
10724
|
scopedPaths.filter((p) => p.kind === "command").map((p) => p.path)
|
|
10665
10725
|
);
|
|
10666
10726
|
if (propNoMod.startsWith("command.")) {
|
|
10727
|
+
const allowed = attr.tagName !== void 0 && !attr.tagName.includes("-") ? nativeCommandsOf(attr.tagName) : null;
|
|
10728
|
+
const method = propNoMod.slice("command.".length);
|
|
10729
|
+
if (allowed !== null && !allowed.includes(method)) {
|
|
10730
|
+
const methodStart = bindingStart + binding.indexOf("command.") + "command.".length;
|
|
10731
|
+
diagnostics.push({
|
|
10732
|
+
code: WcsDiagnosticCode.TokenMisconfigured,
|
|
10733
|
+
start: methodStart,
|
|
10734
|
+
end: methodStart + method.length,
|
|
10735
|
+
message: msgs.nativeCommandUnknown(method, attr.tagName, allowed.join(", ")) + suggestion(method, allowed, msgs),
|
|
10736
|
+
severity: "error"
|
|
10737
|
+
});
|
|
10738
|
+
}
|
|
10667
10739
|
const tokenPath = parsed.path?.trim() ?? "";
|
|
10668
10740
|
if (tokenPath) {
|
|
10669
10741
|
const pathOffset = binding.indexOf(parsed.path);
|
|
@@ -13274,39 +13346,6 @@ function normalizeSeed(raw) {
|
|
|
13274
13346
|
const compact = raw.replace(/\s+/g, "");
|
|
13275
13347
|
return compact === "" ? raw : compact;
|
|
13276
13348
|
}
|
|
13277
|
-
function suggestion(input, candidates, msgs) {
|
|
13278
|
-
let best = null;
|
|
13279
|
-
let bestDistance = 3;
|
|
13280
|
-
for (const c of candidates) {
|
|
13281
|
-
const d = editDistance2(input.toLowerCase(), c.toLowerCase(), bestDistance);
|
|
13282
|
-
if (d < bestDistance) {
|
|
13283
|
-
best = c;
|
|
13284
|
-
bestDistance = d;
|
|
13285
|
-
}
|
|
13286
|
-
}
|
|
13287
|
-
return best !== null ? msgs.didYouMean(best) : "";
|
|
13288
|
-
}
|
|
13289
|
-
function editDistance2(a, b, bound) {
|
|
13290
|
-
if (Math.abs(a.length - b.length) >= bound) return bound;
|
|
13291
|
-
const prev = new Array(b.length + 1);
|
|
13292
|
-
const curr = new Array(b.length + 1);
|
|
13293
|
-
for (let j = 0; j <= b.length; j++) prev[j] = j;
|
|
13294
|
-
for (let i = 1; i <= a.length; i++) {
|
|
13295
|
-
curr[0] = i;
|
|
13296
|
-
let rowMin = curr[0];
|
|
13297
|
-
for (let j = 1; j <= b.length; j++) {
|
|
13298
|
-
curr[j] = Math.min(
|
|
13299
|
-
prev[j] + 1,
|
|
13300
|
-
curr[j - 1] + 1,
|
|
13301
|
-
prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1)
|
|
13302
|
-
);
|
|
13303
|
-
if (curr[j] < rowMin) rowMin = curr[j];
|
|
13304
|
-
}
|
|
13305
|
-
if (rowMin >= bound) return bound;
|
|
13306
|
-
for (let j = 0; j <= b.length; j++) prev[j] = curr[j];
|
|
13307
|
-
}
|
|
13308
|
-
return Math.min(prev[b.length], bound);
|
|
13309
|
-
}
|
|
13310
13349
|
function findBuiltinTagOccurrences(html) {
|
|
13311
13350
|
const out = [];
|
|
13312
13351
|
const regex = /<(wcs-[a-z0-9-]+)((?:"[^"]*"|'[^']*'|[^>"'])*)>/gi;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/lint",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.5",
|
|
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": {
|