@wcstack/lint 4.7.0 → 4.8.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.
Files changed (2) hide show
  1. package/dist/cli.cjs +26 -5
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -2598,7 +2598,7 @@ function tokenize(text3) {
2598
2598
  i += 2;
2599
2599
  continue;
2600
2600
  }
2601
- if ("{}[]<>()|,;:?!*.=".includes(ch)) {
2601
+ if ("{}[]<>()|&,;:?!*.=".includes(ch)) {
2602
2602
  tokens.push({ t: "punct", v: ch });
2603
2603
  i++;
2604
2604
  continue;
@@ -2647,6 +2647,7 @@ function parseJsDocType(text3) {
2647
2647
  const member = parsePostfix();
2648
2648
  if (member === null) return null;
2649
2649
  members.push(member);
2650
+ if (expect("&")) continue;
2650
2651
  if (!expect("|")) break;
2651
2652
  }
2652
2653
  if (isPunct("=>")) {
@@ -2810,12 +2811,21 @@ function readBracedType(comment, tag) {
2810
2811
  return null;
2811
2812
  }
2812
2813
  function readJsDocTypeBefore(content, propIndex) {
2814
+ const comment = jsDocCommentBefore(content, propIndex);
2815
+ return comment === void 0 ? void 0 : readBracedType(comment, "type")?.type.trim();
2816
+ }
2817
+ function readJsDocReturnsBefore(content, propIndex) {
2818
+ const comment = jsDocCommentBefore(content, propIndex);
2819
+ if (comment === void 0) return void 0;
2820
+ return (readBracedType(comment, "returns") ?? readBracedType(comment, "return"))?.type.trim();
2821
+ }
2822
+ function jsDocCommentBefore(content, propIndex) {
2813
2823
  let end = propIndex;
2814
2824
  while (end > 0 && /\s/.test(content[end - 1])) end--;
2815
2825
  if (!content.startsWith("*/", end - 2)) return void 0;
2816
2826
  const start = content.lastIndexOf("/*", end - 2);
2817
2827
  if (start === -1 || content[start + 2] !== "*") return void 0;
2818
- return readBracedType(content.slice(start, end), "type")?.type.trim();
2828
+ return content.slice(start, end);
2819
2829
  }
2820
2830
  function collectJsDocTypedefs(script, scan) {
2821
2831
  const typedefs = /* @__PURE__ */ new Map();
@@ -2902,6 +2912,7 @@ function analyzeStatePaths(scriptContent) {
2902
2912
  const settable = !recursive && effective !== "data" && effective.set;
2903
2913
  paths.push({ path: prop.name, kind: recursive ? "recursive" : "computed", ...settable ? { settable } : {} });
2904
2914
  }
2915
+ if (prop.declaredType !== void 0) pushDeclaredShapePaths(prop.name, prop.declaredType, paths, 0, typedefs);
2905
2916
  continue;
2906
2917
  }
2907
2918
  pushDataPropertyPaths(prop, paths, typedefs);
@@ -3779,7 +3790,12 @@ function extractDefaultExportObject(script) {
3779
3790
  function parseTopLevelProperties(objectContent, allowEmptyDataKeys = false) {
3780
3791
  const props = [];
3781
3792
  const scan = maskCommentsAndStrings(objectContent);
3782
- const regex = allowEmptyDataKeys ? /(?:(?:get|set)\s+(?:"([^"]+)"|'([^']+)'|([$\w]+))\s*\([^)]*\)\s*\{)|(?:(?:async\s+)?(?:"([^"]+)"|'([^']+)'|([$\w]+))\s*\([^)]*\)\s*\{)|(?:(?:"([^"]*)"|'([^']*)'|([$\w]+))\s*:\s*)/gd : /(?:(?:get|set)\s+(?:"([^"]+)"|'([^']+)'|([$\w]+))\s*\([^)]*\)\s*\{)|(?:(?:async\s+)?(?:"([^"]+)"|'([^']+)'|([$\w]+))\s*\([^)]*\)\s*\{)|(?:(?:"([^"]+)"|'([^']+)'|([$\w]+))\s*:\s*)/gd;
3793
+ const params = String.raw`\((?:[^()]|\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\))*\)`;
3794
+ const dataKey = allowEmptyDataKeys ? String.raw`(?:"([^"]*)"|'([^']*)'|([$\w]+))` : String.raw`(?:"([^"]+)"|'([^']+)'|([$\w]+))`;
3795
+ const regex = new RegExp(
3796
+ String.raw`(?:(?:get|set)\s+(?:"([^"]+)"|'([^']+)'|([$\w]+))\s*${params}\s*\{)|(?:(?:async\s+)?(?:"([^"]+)"|'([^']+)'|([$\w]+))\s*${params}\s*\{)|(?:${dataKey}\s*:\s*)`,
3797
+ "gd"
3798
+ );
3783
3799
  let match;
3784
3800
  while ((match = regex.exec(scan)) !== null) {
3785
3801
  const indices = match.indices;
@@ -3800,6 +3816,8 @@ function parseTopLevelProperties(objectContent, allowEmptyDataKeys = false) {
3800
3816
  if (accessorName) {
3801
3817
  const { body, bodyStart } = skipBody();
3802
3818
  const accessor = match[0].startsWith("set") ? "set" : "get";
3819
+ const returnsText = accessor === "get" ? readJsDocReturnsBefore(objectContent, match.index) : void 0;
3820
+ const declaredType = returnsText === void 0 ? null : parseJsDocType(returnsText);
3803
3821
  props.push({
3804
3822
  name: accessorName,
3805
3823
  kind: "getter",
@@ -3807,7 +3825,8 @@ function parseTopLevelProperties(objectContent, allowEmptyDataKeys = false) {
3807
3825
  value: body,
3808
3826
  valueStart: bodyStart,
3809
3827
  nameStart: nameSpan[0],
3810
- nameEnd: nameSpan[1]
3828
+ nameEnd: nameSpan[1],
3829
+ ...declaredType !== null ? { declaredType } : {}
3811
3830
  });
3812
3831
  continue;
3813
3832
  }
@@ -11681,7 +11700,7 @@ function forEachStateMethod(elements, html, fileReader, spelling, fn) {
11681
11700
  for (const callable of analyzeCallableBodies(script)) {
11682
11701
  if (callable.kind !== "method" || spelling !== null && !callable.body.includes(spelling)) continue;
11683
11702
  const head = script.slice(callable.end, callable.bodyStart - 1);
11684
- const params = /\(([^)]*)\)\s*$/.exec(head);
11703
+ const params = /\(([\s\S]*)\)\s*$/.exec(head);
11685
11704
  if (params === null) continue;
11686
11705
  fn(volume === null ? callable.name : `${volume}.${callable.name}`, params[1], callable.body);
11687
11706
  }
@@ -14044,6 +14063,7 @@ var BUILTIN_TAGS = {
14044
14063
  "withCredentials": "with-credentials",
14045
14064
  "events": "events",
14046
14065
  "raw": "raw",
14066
+ "staleAfter": "stale-after",
14047
14067
  "manual": "manual",
14048
14068
  "trigger": null
14049
14069
  },
@@ -14234,6 +14254,7 @@ var BUILTIN_TAGS = {
14234
14254
  "reconnectInterval": "reconnect-interval",
14235
14255
  "maxReconnects": "max-reconnects",
14236
14256
  "binaryType": "binary-type",
14257
+ "staleAfter": "stale-after",
14237
14258
  "manual": "manual",
14238
14259
  "trigger": null,
14239
14260
  "send": null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/lint",
3
- "version": "4.7.0",
3
+ "version": "4.8.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": {