@wcstack/lint 4.5.0 → 4.6.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/README.ja.md CHANGED
@@ -21,7 +21,7 @@ npm i -D @wcstack/lint
21
21
  npx wcs-validate --errors-only src/**/*.html
22
22
  ```
23
23
 
24
- `.manifest.json` で終わるファイルは sidecar manifest として、それ以外は `data-wcs` バインディングを含む HTML として検査されます。
24
+ `.manifest.json` で終わるファイルは sidecar manifest として、それ以外は `data-wcs` バインディングを含む HTML として検査されます。ただし framework のコンポーネントと script のファイル(`.js`・`.ts`・`.jsx`・`.tsx`・`.vue`・`.svelte`)は読みません(4.6 から。以前は HTML として読み、問題なしと報告していました)。
25
25
 
26
26
  `<wcs-state src="...">` で参照される外部 state(`.json` / `.js` / `.ts`)は HTML ファイルからの相対パスで解決され、パス検証の対象になります。URL・絶対パスは読み込まず、読めないファイルはスキップされ、解決できないパスは warning のままです。なお外部 state が**解決できた**ページには通常の検証面が全て適用されるため、error severity の検出(例: 配列でない値への `for:`)が「これまでパス未解決で沈黙していたビルド」を新たに落とすことがあります。4.4 から、`.js` / `.ts` の state にはスクリプトの規則(`wcs/nested-assign`・`wcs/array-mutation`・`wcs/on-handler-this`・`wcs/updated-callback-unbound` など)もかかります: ファイルの中の指摘はそのファイルで報告し(`state.js:12:5 error wcs/nested-assign …`)、何ページから読まれても 1 回だけ数え、IDE はページの `src` の値の上に出します。4.3 までは、外部 state ではパスだけを検査していました。
27
27
 
@@ -54,6 +54,16 @@ app.manifest.json:1:3 error wcs/manifest-broken Broken manifest JSON: ...
54
54
  | `1` | error severity の診断が 1 件以上。`--strict` 時は error または warning が 1 件以上 |
55
55
  | `2` | usage エラー、またはファイル読み取り失敗 |
56
56
 
57
+ 件数の後に、件数が何も語らないファイルを 2 つの注が挙げます(4.6 から。`--errors-only` でも出し、exit code は変えません):
58
+
59
+ ```
60
+ 0 error(s), 0 warning(s), 0 info
61
+ not read: src/App.tsx — wcs-validate reads HTML pages (data-wcs, <wcs-*> tags), not a framework's components or script files
62
+ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack script in them
63
+ ```
64
+
65
+ `<wcs-*>` の要素を使う framework のアプリ(React・Vue)にはどちらも無く、ページはルートの要素を持つだけで、コンポーネントは読まれません。exit code `0` は、そのようなアプリを検査したという意味ではありません。代わりに見るべきことは [framework 統合の手引き](../../docs/framework-adapter-integration.ja.md) にあります。
66
+
57
67
  ## state の契約を宣言する(`stateSchema`)
58
68
 
59
69
  契約が無いと、validator が解決できないパスは **warning**(`wcs/binding-path-missing`)に留まります: インラインスクリプトが静的に読めなくても `count` は実行時には存在するかもしれないからです。`[]` で始まるリストの行のフィールドは、行を足す・置き換える代入式の行リテラルから読みます。外から届くリスト(`<wcs-fetch>` や `<wcs-storage>` が埋めるまで `null`)にはそのリテラルが無いので、プロパティの直前の JSDoc `@type` で形を宣言してください(`/** @type {{ id: number, name: string }[] | null} */ catalog: null`)。同じスクリプトの `@typedef` で行の型に名前を付け、`@type {Product[] | null}` と書いてもかまいません。HTML と同じ(または上の)ディレクトリに `application` sidecar を置くと、同じ typo が **error** になります:
@@ -84,7 +94,7 @@ app.manifest.json:1:3 error wcs/manifest-broken Broken manifest JSON: ...
84
94
 
85
95
  ## 生成 → 検証 → 修正ループでの利用
86
96
 
87
- 安定した diagnostic code・`source:line:col` range・exit code 契約により、CI のゲートにも AI コード生成フローにもそのまま組み込めます: HTML を生成 → `npx @wcstack/lint --errors-only` → 診断を読んで修正 → exit code `0` になるまで再実行。
97
+ 安定した diagnostic code・`source:line:col` range・exit code 契約により、CI のゲートにも AI コード生成フローにもそのまま組み込めます: HTML を生成 → `npx @wcstack/lint --errors-only` → 診断を読んで修正 → exit code `0` になるまで再実行。このゲートが覆うのは `data-wcs` のページです: 出力が `not read:` や `nothing to check:` で終わるときは、そのファイルは検査されていません。
88
98
 
89
99
  ## VS Code 拡張との関係
90
100
 
package/README.md CHANGED
@@ -21,7 +21,7 @@ npm i -D @wcstack/lint
21
21
  npx wcs-validate --errors-only src/**/*.html
22
22
  ```
23
23
 
24
- Files ending in `.manifest.json` are validated as sidecar manifests; everything else is validated as HTML with `data-wcs` bindings.
24
+ Files ending in `.manifest.json` are validated as sidecar manifests; everything else is validated as HTML with `data-wcs` bindings, except a framework's components and script files (`.js`, `.ts`, `.jsx`, `.tsx`, `.vue`, `.svelte`), which are not read (since 4.6; before, they were read as HTML and reported clean).
25
25
 
26
26
  External state referenced via `<wcs-state src="...">` (`.json` / `.js` / `.ts`) is resolved relative to the HTML file and included in path validation. URLs and absolute paths are never read, unreadable files are skipped, and unresolved paths stay warnings. Note that once external state *does* resolve, the full validation surface applies to those pages — error-severity findings (e.g. `for:` bound to a non-array) can fail a build that was previously silent because the paths could not be checked. Since 4.4 that includes the script rules (`wcs/nested-assign`, `wcs/array-mutation`, `wcs/on-handler-this`, `wcs/updated-callback-unbound` and the rest) on a `.js` / `.ts` state: a finding in the file is reported in the file (`state.js:12:5 error wcs/nested-assign …`), once however many pages load it, and the IDE shows it on the page's `src` value. Up to 4.3 only the paths of an external state were checked.
27
27
 
@@ -54,6 +54,16 @@ app.manifest.json:1:3 error wcs/manifest-broken Broken manifest JSON: ...
54
54
  | `1` | At least one error-severity diagnostic; with `--strict`, at least one error or warning |
55
55
  | `2` | Usage error or unreadable file |
56
56
 
57
+ After the counts, two notes name the files the counts say nothing about (since 4.6; printed with `--errors-only` too, and they do not change the exit code):
58
+
59
+ ```
60
+ 0 error(s), 0 warning(s), 0 info
61
+ not read: src/App.tsx — wcs-validate reads HTML pages (data-wcs, <wcs-*> tags), not a framework's components or script files
62
+ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack script in them
63
+ ```
64
+
65
+ A framework app (React, Vue) that uses the `<wcs-*>` elements has neither: its page holds the root element and its components are not read. Exit code `0` does not mean such an app was checked; [the framework integration guide](../../docs/framework-adapter-integration.md) lists what to look for instead.
66
+
57
67
  ## Declaring a state contract (`stateSchema`)
58
68
 
59
69
  Without a contract, a path the validator cannot resolve is only a **warning** (`wcs/binding-path-missing`): `count` may well exist at runtime even when the inline script cannot be read statically. Note that a list starting as `[]` does not need a contract just to name its row fields — the analyzer reads them from the row literals in the assignments that add or replace rows (`this.items = this.items.concat({ id, kind: "general" })`, `.toSpliced(i, n, { … })`, `.with(i, { … })`, `[...this.items, { … }]`); only a row passed as a variable (`concat(row)`) is invisible to it. A list that arrives from outside — `null` until `<wcs-fetch>` or `<wcs-storage>` fills it — has no such literal: declare its shape with a JSDoc `@type` before the property (`/** @type {{ id: number, name: string }[] | null} */ catalog: null`), or name the row type with a `@typedef` in the same script and write `@type {Product[] | null}`. Put an `application` sidecar next to (or above) the HTML and the same typo becomes an **error**:
@@ -84,7 +94,7 @@ Without a contract, a path the validator cannot resolve is only a **warning** (`
84
94
 
85
95
  ## Use in generate–validate–fix loops
86
96
 
87
- Stable diagnostic codes, `source:line:col` ranges, and the exit-code contract make this CLI a drop-in gate for CI and for AI code-generation flows: generate HTML → `npx @wcstack/lint --errors-only` → read the diagnostics, fix, and re-run until exit code `0`.
97
+ Stable diagnostic codes, `source:line:col` ranges, and the exit-code contract make this CLI a drop-in gate for CI and for AI code-generation flows: generate HTML → `npx @wcstack/lint --errors-only` → read the diagnostics, fix, and re-run until exit code `0`. The gate covers `data-wcs` pages: when the output ends with `not read:` or `nothing to check:`, those files were not checked.
88
98
 
89
99
  ## Relationship to the VS Code extension
90
100
 
package/dist/cli.cjs CHANGED
@@ -14051,10 +14051,12 @@ var BUILTIN_TAGS = {
14051
14051
  "hasWcBindable": true,
14052
14052
  "observedAttributes": [
14053
14053
  "key",
14054
+ "storage-key",
14054
14055
  "type"
14055
14056
  ],
14056
14057
  "inputs": {
14057
14058
  "key": null,
14059
+ "storageKey": null,
14058
14060
  "type": null,
14059
14061
  "value": null,
14060
14062
  "manual": null,
@@ -17625,6 +17627,13 @@ function escapePtr(key) {
17625
17627
  }
17626
17628
 
17627
17629
  // src/core/cli/runValidation.ts
17630
+ function inputKindOf(path) {
17631
+ if (path.endsWith(".manifest.json")) return "manifest";
17632
+ return /\.(?:[cm]?[jt]sx?|vue|svelte)$/i.test(path) ? "other" : "html";
17633
+ }
17634
+ function hasAnythingToCheck(text3, bindAttribute, stateTagName) {
17635
+ return text3.includes(bindAttribute) || /<wcs-/i.test(text3) || text3.includes(`<${stateTagName}`) || /@wcstack\/|\bwcstack(?:@[\w.-]+)?\/auto\b/.test(text3);
17636
+ }
17628
17637
  var severityLabel = { error: "error", warning: "warning", info: "info" };
17629
17638
  function runValidation(inputs, options = {}) {
17630
17639
  const diagnosticsBySource = /* @__PURE__ */ new Map();
@@ -17646,8 +17655,12 @@ function runValidation(inputs, options = {}) {
17646
17655
  }
17647
17656
  }
17648
17657
  const inFiles = /* @__PURE__ */ new Map();
17658
+ const nothingToCheck = [];
17649
17659
  for (const input of inputs) {
17650
17660
  if (input.kind !== "html") continue;
17661
+ if (!hasAnythingToCheck(input.text, options.bindAttribute ?? "data-wcs", options.stateTagName ?? "wcs-state")) {
17662
+ nothingToCheck.push(input.source);
17663
+ }
17651
17664
  let applicationSchema = explicitSchema;
17652
17665
  if (!haveExplicitApplication && input.fileReader !== void 0) {
17653
17666
  const discovered = discoverApplicationManifest(input.fileReader);
@@ -17699,20 +17712,28 @@ function runValidation(inputs, options = {}) {
17699
17712
  lines.push(`${source}:${pos.line}:${pos.column} ${severityLabel[d.severity]} ${d.code} ${d.message}`);
17700
17713
  }
17701
17714
  }
17715
+ const notRead = inputs.filter((i) => i.kind === "other").map((i) => i.source);
17716
+ const notes = [];
17717
+ if (notRead.length > 0) {
17718
+ notes.push(`not read: ${notRead.join(", ")} \u2014 wcs-validate reads HTML pages (data-wcs, <wcs-*> tags), not a framework's components or script files`);
17719
+ }
17720
+ if (nothingToCheck.length > 0) {
17721
+ notes.push(`nothing to check: ${nothingToCheck.join(", ")} \u2014 no data-wcs binding, <wcs-*> tag or wcstack script in them`);
17722
+ }
17702
17723
  return {
17703
17724
  lines,
17704
17725
  errorCount,
17705
17726
  warningCount,
17706
17727
  infoCount,
17707
17728
  exitCode: errorCount > 0 || options.strict === true && warningCount > 0 ? 1 : 0,
17708
- diagnosticsBySource
17729
+ diagnosticsBySource,
17730
+ notRead,
17731
+ nothingToCheck,
17732
+ notes
17709
17733
  };
17710
17734
  }
17711
17735
 
17712
17736
  // src/cli.ts
17713
- function classify(path) {
17714
- return path.endsWith(".manifest.json") ? "manifest" : "html";
17715
- }
17716
17737
  function parseArgs(argv) {
17717
17738
  const options = {};
17718
17739
  const files = [];
@@ -17753,7 +17774,7 @@ function main(argv) {
17753
17774
  `);
17754
17775
  return 2;
17755
17776
  }
17756
- const kind = classify(path);
17777
+ const kind = inputKindOf(path);
17757
17778
  inputs.push({ source: path, text: text3, kind, fileReader: kind === "html" ? createFileReader(path) : void 0 });
17758
17779
  }
17759
17780
  const result = runValidation(inputs, { ...options, locale: locale2 });
@@ -17765,6 +17786,7 @@ function main(argv) {
17765
17786
  ${result.errorCount} error(s), ${result.warningCount} warning(s), ${result.infoCount} info${options.strict ? " (strict)" : ""}
17766
17787
  `
17767
17788
  );
17789
+ for (const note of result.notes) process.stdout.write(note + "\n");
17768
17790
  return result.exitCode;
17769
17791
  }
17770
17792
  if (typeof require !== "undefined" && typeof module !== "undefined" && require.main === module) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/lint",
3
- "version": "4.5.0",
3
+ "version": "4.6.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": {