@wcstack/lint 4.0.0-rc.2 → 4.0.0-rc.4
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 +136 -127
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -339,32 +339,8 @@ var LINT_HINT = " Validate statically: npx @wcstack/lint <file>.";
|
|
|
339
339
|
function raiseError(message, subject, candidates) {
|
|
340
340
|
throw new Error(`[@wcstack/state] ${message}${hooks.explain?.(message, subject, candidates) ?? ""}`);
|
|
341
341
|
}
|
|
342
|
-
var CODES = [
|
|
343
|
-
"",
|
|
344
|
-
"binding-syntax",
|
|
345
|
-
"template-syntax",
|
|
346
|
-
"binding-path-missing",
|
|
347
|
-
"binding-type-expectation",
|
|
348
|
-
"filter-unknown",
|
|
349
|
-
"filter-arity",
|
|
350
|
-
"getter-cycle",
|
|
351
|
-
"getter-depth-exceeded",
|
|
352
|
-
"index-arity",
|
|
353
|
-
"index-param-range",
|
|
354
|
-
"recursion-unsupported",
|
|
355
|
-
"token-misconfigured",
|
|
356
|
-
"token-undeclared",
|
|
357
|
-
"wildcard-rank",
|
|
358
|
-
"spread-no-bindable",
|
|
359
|
-
"declaration-alias",
|
|
360
|
-
"name-alias"
|
|
361
|
-
];
|
|
362
|
-
var codeOf = (id) => {
|
|
363
|
-
const c = CODES[id / 100 | 0];
|
|
364
|
-
return c ? `[wcs/${c}] ` : "";
|
|
365
|
-
};
|
|
366
342
|
function text(id, args = []) {
|
|
367
|
-
return hooks.render?.(id, args) ??
|
|
343
|
+
return hooks.render?.(id, args) ?? `#${id}${args.map((a) => ` ${typeof a === "string" ? JSON.stringify(a) : String(a)}`).join("")}`;
|
|
368
344
|
}
|
|
369
345
|
function raise(id, args, subject, candidates) {
|
|
370
346
|
raiseError(text(id, args), subject, candidates);
|
|
@@ -392,7 +368,21 @@ var FORMATS_FILTER_NAMES = [
|
|
|
392
368
|
"time",
|
|
393
369
|
"datetime",
|
|
394
370
|
"ymd",
|
|
395
|
-
"hms"
|
|
371
|
+
"hms",
|
|
372
|
+
"add",
|
|
373
|
+
"sub",
|
|
374
|
+
"mul",
|
|
375
|
+
"div",
|
|
376
|
+
"mod",
|
|
377
|
+
"abs",
|
|
378
|
+
"clamp",
|
|
379
|
+
"int",
|
|
380
|
+
"float",
|
|
381
|
+
"defaults",
|
|
382
|
+
"coalesce",
|
|
383
|
+
"number",
|
|
384
|
+
"string",
|
|
385
|
+
"nullIfEmpty"
|
|
396
386
|
];
|
|
397
387
|
var definitions = /* @__PURE__ */ new Map();
|
|
398
388
|
function hasFilter(name) {
|
|
@@ -584,6 +574,30 @@ function parseStatePart(statePart) {
|
|
|
584
574
|
}
|
|
585
575
|
var MAX_DRAIN_PASSES = 32;
|
|
586
576
|
var MAX_RENDER_CHAIN = 100;
|
|
577
|
+
var CODES = [
|
|
578
|
+
"",
|
|
579
|
+
"binding-syntax",
|
|
580
|
+
"template-syntax",
|
|
581
|
+
"binding-path-missing",
|
|
582
|
+
"binding-type-expectation",
|
|
583
|
+
"filter-unknown",
|
|
584
|
+
"filter-arity",
|
|
585
|
+
"getter-cycle",
|
|
586
|
+
"getter-depth-exceeded",
|
|
587
|
+
"index-arity",
|
|
588
|
+
"index-param-range",
|
|
589
|
+
"recursion-unsupported",
|
|
590
|
+
"token-misconfigured",
|
|
591
|
+
"token-undeclared",
|
|
592
|
+
"wildcard-rank",
|
|
593
|
+
"spread-no-bindable",
|
|
594
|
+
"declaration-alias",
|
|
595
|
+
"name-alias"
|
|
596
|
+
];
|
|
597
|
+
var codeOf = (id) => {
|
|
598
|
+
const c = CODES[id / 100 | 0];
|
|
599
|
+
return c ? `[wcs/${c}] ` : "";
|
|
600
|
+
};
|
|
587
601
|
var MOVED = ["enableMustache", "sameValueGuard", "enableDirectionalInitialSync"];
|
|
588
602
|
var element = (tag, at2) => `<${tag}${at2.map((a, i) => i % 2 ? `="${a}"` : ` ${a}`).join("")}>`;
|
|
589
603
|
var CSP_GUIDE = "https://github.com/wcstack/wcstack/blob/main/docs/csp.md";
|
|
@@ -784,6 +798,10 @@ var SENTENCES = {
|
|
|
784
798
|
50
|
|
785
799
|
/* ConnectedFailed */
|
|
786
800
|
]: (tag, ...at2) => `${element(tag, at2)} $connectedCallback failed.`,
|
|
801
|
+
[
|
|
802
|
+
51
|
|
803
|
+
/* DisconnectedFailed */
|
|
804
|
+
]: (tag, ...at2) => `${element(tag, at2)} $disconnectedCallback failed.`,
|
|
787
805
|
[
|
|
788
806
|
101
|
|
789
807
|
/* BindTextNoColon */
|
|
@@ -1259,26 +1277,26 @@ function findStartTagRegions(html) {
|
|
|
1259
1277
|
let lower2 = null;
|
|
1260
1278
|
let i = 0;
|
|
1261
1279
|
while (i < html.length) {
|
|
1262
|
-
const
|
|
1263
|
-
if (
|
|
1264
|
-
const next = html[
|
|
1265
|
-
if (html.startsWith("<!--",
|
|
1266
|
-
const close = html.indexOf("-->",
|
|
1280
|
+
const lt2 = html.indexOf("<", i);
|
|
1281
|
+
if (lt2 === -1) break;
|
|
1282
|
+
const next = html[lt2 + 1];
|
|
1283
|
+
if (html.startsWith("<!--", lt2)) {
|
|
1284
|
+
const close = html.indexOf("-->", lt2 + 4);
|
|
1267
1285
|
i = close === -1 ? html.length : close + 3;
|
|
1268
1286
|
continue;
|
|
1269
1287
|
}
|
|
1270
1288
|
if (next === "!" || next === "?" || next === "/") {
|
|
1271
|
-
const close = html.indexOf(">",
|
|
1289
|
+
const close = html.indexOf(">", lt2 + 1);
|
|
1272
1290
|
i = close === -1 ? html.length : close + 1;
|
|
1273
1291
|
continue;
|
|
1274
1292
|
}
|
|
1275
1293
|
if (next === void 0 || !/[A-Za-z]/.test(next)) {
|
|
1276
|
-
i =
|
|
1294
|
+
i = lt2 + 1;
|
|
1277
1295
|
continue;
|
|
1278
1296
|
}
|
|
1279
|
-
let n =
|
|
1297
|
+
let n = lt2 + 1;
|
|
1280
1298
|
while (n < html.length && /[^\s/>]/.test(html[n])) n++;
|
|
1281
|
-
const tagName = asciiLowerCase(html.slice(
|
|
1299
|
+
const tagName = asciiLowerCase(html.slice(lt2 + 1, n));
|
|
1282
1300
|
let j = n;
|
|
1283
1301
|
let quote = null;
|
|
1284
1302
|
while (j < html.length) {
|
|
@@ -1292,10 +1310,10 @@ function findStartTagRegions(html) {
|
|
|
1292
1310
|
}
|
|
1293
1311
|
j++;
|
|
1294
1312
|
}
|
|
1295
|
-
const
|
|
1296
|
-
const selfClosing = html[
|
|
1297
|
-
out.push({ tagName, start: n, end: selfClosing ?
|
|
1298
|
-
i =
|
|
1313
|
+
const gt2 = j < html.length ? j : html.length;
|
|
1314
|
+
const selfClosing = html[gt2 - 1] === "/";
|
|
1315
|
+
out.push({ tagName, start: n, end: selfClosing ? gt2 - 1 : gt2 });
|
|
1316
|
+
i = gt2 + 1;
|
|
1299
1317
|
if (tagName === "script" || tagName === "style") {
|
|
1300
1318
|
const close = (lower2 ??= asciiLowerCase(html)).indexOf(`</${tagName}`, i);
|
|
1301
1319
|
i = close === -1 ? html.length : close;
|
|
@@ -1339,8 +1357,8 @@ function matchRawTextElement(html, lower2, pos) {
|
|
|
1339
1357
|
return null;
|
|
1340
1358
|
}
|
|
1341
1359
|
function afterCloseTag(html, closeStart) {
|
|
1342
|
-
const
|
|
1343
|
-
return
|
|
1360
|
+
const gt2 = html.indexOf(">", closeStart);
|
|
1361
|
+
return gt2 === -1 ? html.length : gt2 + 1;
|
|
1344
1362
|
}
|
|
1345
1363
|
function parseWcsStateElements(html, stateTagName = "wcs-state") {
|
|
1346
1364
|
const elements = [];
|
|
@@ -1446,22 +1464,22 @@ function collectTemplateTags(html) {
|
|
|
1446
1464
|
const tags = [];
|
|
1447
1465
|
let pos = 0;
|
|
1448
1466
|
while (pos < html.length) {
|
|
1449
|
-
const
|
|
1450
|
-
if (
|
|
1451
|
-
if (html.startsWith("<!--",
|
|
1452
|
-
const commentEnd = html.indexOf("-->",
|
|
1467
|
+
const lt2 = html.indexOf("<", pos);
|
|
1468
|
+
if (lt2 === -1) break;
|
|
1469
|
+
if (html.startsWith("<!--", lt2)) {
|
|
1470
|
+
const commentEnd = html.indexOf("-->", lt2 + 4);
|
|
1453
1471
|
if (commentEnd === -1) break;
|
|
1454
1472
|
pos = commentEnd + 3;
|
|
1455
1473
|
continue;
|
|
1456
1474
|
}
|
|
1457
|
-
const raw = matchRawTextElement(html, lower2,
|
|
1475
|
+
const raw = matchRawTextElement(html, lower2, lt2);
|
|
1458
1476
|
if (raw !== null) {
|
|
1459
1477
|
pos = raw.closed ? afterCloseTag(html, raw.contentEnd) : html.length;
|
|
1460
1478
|
continue;
|
|
1461
1479
|
}
|
|
1462
|
-
const tag = /^<(\/?)template(?=[\s/>])/i.exec(html.slice(
|
|
1463
|
-
if (tag !== null) tags.push({ at:
|
|
1464
|
-
pos =
|
|
1480
|
+
const tag = /^<(\/?)template(?=[\s/>])/i.exec(html.slice(lt2, lt2 + 11));
|
|
1481
|
+
if (tag !== null) tags.push({ at: lt2, close: tag[1] === "/" });
|
|
1482
|
+
pos = lt2 + 1;
|
|
1465
1483
|
}
|
|
1466
1484
|
return tags;
|
|
1467
1485
|
}
|
|
@@ -1605,32 +1623,8 @@ var hooks2 = {};
|
|
|
1605
1623
|
function raiseError2(message, subject, candidates) {
|
|
1606
1624
|
throw new Error(`[@wcstack/state] ${message}${hooks2.explain?.(message, subject, candidates) ?? ""}`);
|
|
1607
1625
|
}
|
|
1608
|
-
var CODES2 = [
|
|
1609
|
-
"",
|
|
1610
|
-
"binding-syntax",
|
|
1611
|
-
"template-syntax",
|
|
1612
|
-
"binding-path-missing",
|
|
1613
|
-
"binding-type-expectation",
|
|
1614
|
-
"filter-unknown",
|
|
1615
|
-
"filter-arity",
|
|
1616
|
-
"getter-cycle",
|
|
1617
|
-
"getter-depth-exceeded",
|
|
1618
|
-
"index-arity",
|
|
1619
|
-
"index-param-range",
|
|
1620
|
-
"recursion-unsupported",
|
|
1621
|
-
"token-misconfigured",
|
|
1622
|
-
"token-undeclared",
|
|
1623
|
-
"wildcard-rank",
|
|
1624
|
-
"spread-no-bindable",
|
|
1625
|
-
"declaration-alias",
|
|
1626
|
-
"name-alias"
|
|
1627
|
-
];
|
|
1628
|
-
var codeOf2 = (id) => {
|
|
1629
|
-
const c = CODES2[id / 100 | 0];
|
|
1630
|
-
return c ? `[wcs/${c}] ` : "";
|
|
1631
|
-
};
|
|
1632
1626
|
function text2(id, args = []) {
|
|
1633
|
-
return hooks2.render?.(id, args) ??
|
|
1627
|
+
return hooks2.render?.(id, args) ?? `#${id}${args.map((a) => ` ${typeof a === "string" ? JSON.stringify(a) : String(a)}`).join("")}`;
|
|
1634
1628
|
}
|
|
1635
1629
|
function raise2(id, args, subject, candidates) {
|
|
1636
1630
|
raiseError2(text2(id, args), subject, candidates);
|
|
@@ -1734,42 +1728,6 @@ var numeric = (name, op) => ({
|
|
|
1734
1728
|
var truthy = () => (value) => !!value;
|
|
1735
1729
|
var falsy = () => (value) => !value;
|
|
1736
1730
|
var boolean = () => (value) => Boolean(value);
|
|
1737
|
-
var abs = () => (value) => {
|
|
1738
|
-
if (typeof value !== "number") {
|
|
1739
|
-
valueMustBeNumber("abs");
|
|
1740
|
-
}
|
|
1741
|
-
return Math.abs(value);
|
|
1742
|
-
};
|
|
1743
|
-
var clamp = (options) => {
|
|
1744
|
-
const min = requiredNumberOption(options, 0, "clamp");
|
|
1745
|
-
const max = requiredNumberOption(options, 1, "clamp");
|
|
1746
|
-
return (value) => {
|
|
1747
|
-
if (typeof value !== "number") {
|
|
1748
|
-
valueMustBeNumber("clamp");
|
|
1749
|
-
}
|
|
1750
|
-
return Math.min(Math.max(value, min), max);
|
|
1751
|
-
};
|
|
1752
|
-
};
|
|
1753
|
-
var number = () => (value) => Number(value);
|
|
1754
|
-
var string = () => (value) => String(value);
|
|
1755
|
-
var int = () => (value) => parseInt(String(value), 10);
|
|
1756
|
-
var float = () => (value) => parseFloat(String(value));
|
|
1757
|
-
var defaults = (options, literals) => {
|
|
1758
|
-
const opt = options?.[0] ?? optionsRequired("defaults");
|
|
1759
|
-
const fallback = firstLiteral(opt, literals);
|
|
1760
|
-
return (value) => {
|
|
1761
|
-
if (!value) {
|
|
1762
|
-
return fallback;
|
|
1763
|
-
}
|
|
1764
|
-
return value;
|
|
1765
|
-
};
|
|
1766
|
-
};
|
|
1767
|
-
var coalesce = (options, literals) => {
|
|
1768
|
-
const opt = options?.[0] ?? optionsRequired("coalesce");
|
|
1769
|
-
const fallback = firstLiteral(opt, literals);
|
|
1770
|
-
return (value) => value ?? fallback;
|
|
1771
|
-
};
|
|
1772
|
-
var nullIfEmpty = () => (value) => value === "" ? null : value;
|
|
1773
1731
|
var coreFilters = {
|
|
1774
1732
|
eq: { factory: eq, arity: [1, 1] },
|
|
1775
1733
|
ne: { factory: ne, arity: [1, 1] },
|
|
@@ -1778,23 +1736,9 @@ var coreFilters = {
|
|
|
1778
1736
|
le: numeric("le", (value, opt) => value <= opt),
|
|
1779
1737
|
gt: numeric("gt", (value, opt) => value > opt),
|
|
1780
1738
|
ge: numeric("ge", (value, opt) => value >= opt),
|
|
1781
|
-
add: numeric("add", (value, opt) => value + opt),
|
|
1782
|
-
sub: numeric("sub", (value, opt) => value - opt),
|
|
1783
|
-
mul: numeric("mul", (value, opt) => value * opt),
|
|
1784
|
-
div: numeric("div", (value, opt) => value / opt),
|
|
1785
|
-
mod: numeric("mod", (value, opt) => value % opt),
|
|
1786
|
-
abs: { factory: abs, arity: [0, 0] },
|
|
1787
|
-
clamp: { factory: clamp, arity: [2, 2] },
|
|
1788
|
-
int: { factory: int, arity: [0, 0] },
|
|
1789
|
-
float: { factory: float, arity: [0, 0] },
|
|
1790
1739
|
falsy: { factory: falsy, arity: [0, 0] },
|
|
1791
1740
|
truthy: { factory: truthy, arity: [0, 0] },
|
|
1792
|
-
|
|
1793
|
-
coalesce: { factory: coalesce, arity: [1, 1] },
|
|
1794
|
-
boolean: { factory: boolean, arity: [0, 0] },
|
|
1795
|
-
number: { factory: number, arity: [0, 0] },
|
|
1796
|
-
string: { factory: string, arity: [0, 0] },
|
|
1797
|
-
nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] }
|
|
1741
|
+
boolean: { factory: boolean, arity: [0, 0] }
|
|
1798
1742
|
};
|
|
1799
1743
|
var nullishPassthrough = (factory) => (options) => {
|
|
1800
1744
|
const filterFn = factory(options);
|
|
@@ -1979,7 +1923,44 @@ var hms = (options) => {
|
|
|
1979
1923
|
return `${hours}${opt}${minutes}${opt}${seconds}`;
|
|
1980
1924
|
};
|
|
1981
1925
|
};
|
|
1982
|
-
var
|
|
1926
|
+
var abs = () => (value) => {
|
|
1927
|
+
if (typeof value !== "number") {
|
|
1928
|
+
valueMustBeNumber("abs");
|
|
1929
|
+
}
|
|
1930
|
+
return Math.abs(value);
|
|
1931
|
+
};
|
|
1932
|
+
var clamp = (options) => {
|
|
1933
|
+
const min = requiredNumberOption(options, 0, "clamp");
|
|
1934
|
+
const max = requiredNumberOption(options, 1, "clamp");
|
|
1935
|
+
return (value) => {
|
|
1936
|
+
if (typeof value !== "number") {
|
|
1937
|
+
valueMustBeNumber("clamp");
|
|
1938
|
+
}
|
|
1939
|
+
return Math.min(Math.max(value, min), max);
|
|
1940
|
+
};
|
|
1941
|
+
};
|
|
1942
|
+
var number = () => (value) => Number(value);
|
|
1943
|
+
var string = () => (value) => String(value);
|
|
1944
|
+
var int = () => (value) => parseInt(String(value), 10);
|
|
1945
|
+
var float = () => (value) => parseFloat(String(value));
|
|
1946
|
+
var defaults = (options, literals) => {
|
|
1947
|
+
const opt = options?.[0] ?? optionsRequired("defaults");
|
|
1948
|
+
const fallback = firstLiteral(opt, literals);
|
|
1949
|
+
return (value) => {
|
|
1950
|
+
if (!value) {
|
|
1951
|
+
return fallback;
|
|
1952
|
+
}
|
|
1953
|
+
return value;
|
|
1954
|
+
};
|
|
1955
|
+
};
|
|
1956
|
+
var coalesce = (options, literals) => {
|
|
1957
|
+
const opt = options?.[0] ?? optionsRequired("coalesce");
|
|
1958
|
+
const fallback = firstLiteral(opt, literals);
|
|
1959
|
+
return (value) => value ?? fallback;
|
|
1960
|
+
};
|
|
1961
|
+
var nullIfEmpty = () => (value) => value === "" ? null : value;
|
|
1962
|
+
var { eq: eq2, ne: ne2, not: not2, lt, le, gt, ge, falsy: falsy2, truthy: truthy2, boolean: boolean2 } = coreFilters;
|
|
1963
|
+
var registered = {
|
|
1983
1964
|
toFixed: { factory: toFixed, arity: [0, 1] },
|
|
1984
1965
|
locale: { factory: locale, arity: [0, 1] },
|
|
1985
1966
|
// The `String(value)` family passes an absent value through (B8 — see nullishPassthrough)
|
|
@@ -2005,8 +1986,36 @@ var formatFilters = {
|
|
|
2005
1986
|
time: { factory: time, arity: [0, 1] },
|
|
2006
1987
|
datetime: { factory: datetime, arity: [0, 1] },
|
|
2007
1988
|
ymd: { factory: ymd, arity: [0, 1] },
|
|
2008
|
-
hms: { factory: hms, arity: [0, 1] }
|
|
1989
|
+
hms: { factory: hms, arity: [0, 1] },
|
|
1990
|
+
// the core set of 4.0.0-rc.3 (the core's own: eq ne not lt le gt ge falsy truthy boolean)
|
|
1991
|
+
eq: eq2,
|
|
1992
|
+
ne: ne2,
|
|
1993
|
+
not: not2,
|
|
1994
|
+
lt,
|
|
1995
|
+
le,
|
|
1996
|
+
gt,
|
|
1997
|
+
ge,
|
|
1998
|
+
add: numeric("add", (value, opt) => value + opt),
|
|
1999
|
+
sub: numeric("sub", (value, opt) => value - opt),
|
|
2000
|
+
mul: numeric("mul", (value, opt) => value * opt),
|
|
2001
|
+
div: numeric("div", (value, opt) => value / opt),
|
|
2002
|
+
mod: numeric("mod", (value, opt) => value % opt),
|
|
2003
|
+
abs: { factory: abs, arity: [0, 0] },
|
|
2004
|
+
clamp: { factory: clamp, arity: [2, 2] },
|
|
2005
|
+
int: { factory: int, arity: [0, 0] },
|
|
2006
|
+
float: { factory: float, arity: [0, 0] },
|
|
2007
|
+
falsy: falsy2,
|
|
2008
|
+
truthy: truthy2,
|
|
2009
|
+
defaults: { factory: defaults, arity: [1, 1] },
|
|
2010
|
+
coalesce: { factory: coalesce, arity: [1, 1] },
|
|
2011
|
+
boolean: boolean2,
|
|
2012
|
+
number: { factory: number, arity: [0, 0] },
|
|
2013
|
+
string: { factory: string, arity: [0, 0] },
|
|
2014
|
+
nullIfEmpty: { factory: nullIfEmpty, arity: [0, 0] }
|
|
2009
2015
|
};
|
|
2016
|
+
var formatFilters = /* @__PURE__ */ Object.fromEntries(
|
|
2017
|
+
/* @__PURE__ */ Object.entries(registered).filter(([name]) => !(name in coreFilters))
|
|
2018
|
+
);
|
|
2010
2019
|
var STRUCTURAL_BINDING_TYPE_SET2 = /* @__PURE__ */ new Set([
|
|
2011
2020
|
"if",
|
|
2012
2021
|
"elseif",
|
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.4",
|
|
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": {
|