@wcstack/lint 4.32.0 → 4.34.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 +14 -0
- package/README.md +14 -0
- package/dist/cli.cjs +580 -120
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -223,6 +223,20 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
|
|
|
223
223
|
|
|
224
224
|
新しい warning は `--strict` で落ち、新しい error は `--errors-only` でも出ます。
|
|
225
225
|
|
|
226
|
+
## ストリームと呼び出し表示のページに言うこと
|
|
227
|
+
|
|
228
|
+
4.33 から。継ぎ目アプリ counter-assist — LLM の回答を `$stream` で流すコンソール・ワーカーでの CSV の取り込み・1 本の SSE を読む呼び出し表示(片方のページは `@wcstack/signals`、片方は state で書いた)から。作者がわざとした 25 の誤りのどれにも、この lint は何も言いませんでした。signals のページは「検査するものが無い」と挙げていました。いま言うこと:
|
|
229
|
+
|
|
230
|
+
- **`wcs/stream-declaration`**(error) — オブジェクトリテラルで書いた `$stream` のエントリに、`fold` があって `initial` が無い(`answer: { args, source, fold: foldAnswer }`)か、`source` が無い。ランタイムは state を取り込むときに拒みます(`$stream entry "answer": fold needs an initial value.`): ページは初期化に失敗し、コンソールのすべてのルートが死んでいました。`initial: undefined` も、ランタイムと同じく初期値です。確かなものだけ: 名前や呼び出しのエントリ・spread か計算されたキーのあるエントリ・後に書いた spread が置き換えうるエントリには言いません。ボリューム(`wcs/volume-declaration` が言う)と `bind-component` の state も見ません。`src=` のファイルの state はそのファイルに報告します。
|
|
231
|
+
- **`wcs/html-sink-input`**(warning) — HTML の書き込み先(`html:`・`innerHTML:`・`outerHTML:`・`srcdoc:`)に、ページのフォームの部品が双方向の `value:` で書き戻すパスを束ねた — `<textarea data-wcs="value: question">` と `<p data-wcs="html: question">`。利用者が打った文字がマークアップとしてページに入ります: `<b>` は太字になり、`<img src=x onerror=…>` は走ります — フィルタが消毒するのでなければ。なので書き込み先のフィルタでは黙りません。テキストとして束ねてください(`textContent:`)。パスは state のパスとして比べます: `for: turns` の行の `.q` は `turns.*.q`。別のパスを通って届く文字(打った質問をメソッドが表示する一覧へ写す — 継ぎ目アプリ自身の形)は辿りません。書き込み先の束縛ごとに 1 回。
|
|
232
|
+
- **`wcs/v5-migration`**(info。4.34 から) — 5.0 で変わるもののうち、マークアップとスクリプトから読めるもの: リテラルのパスに `*` を含む `$postUpdate`(4.x は呼んだ側の行、5.0 はすべての行)、`<wcs-storage key="…">` とその `key:` の束縛(5.0 は `storage-key` / `storageKey:` だけ)、`attr.on*:`(5.0 は文字列で書いたハンドラを拒む)、同じ要素のほかの入力より前に書いた `trigger:`(5.0 は入力を先に当てる)、`$behavior` の `sameValueGuard: false` / `enableDirectionalInitialSync: false`(5.0 で無くなる)。どの文面も、4.x と 5.0 のどちらでも動く書き方と、[5.0 への準備](https://github.com/wcstack/wcstack/blob/main/docs/migration-v5.ja.md) の節を言います。走らせないと分からないもの — 同じ id で取り直した一覧、最初の同期が上書きする保存値、ブラウザが送ったフォーム — は、`@wcstack/state` の `v5-migration` add-on が実行時に `[wcs/v5-migration]` で言います。5.0 が設計で消す罠をすでに名指している規則(`wcs/submit-without-prevent`・`wcs/storage-seed-clobber`・`wcs/storage-init-seed`・`wcs/trigger-seeded-truthy`・`wcs/number-written-as-string`・`wcs/radio-before-value`・`wcs/command-event-argument`・`wcs/handle-bound-as-value`・`wcs/delegated-current-target`・`wcs/base-href-missing`)は、文面で 5.0 がどうするかを言います。
|
|
233
|
+
- **`wcs/signals-dual-entry`**(error)は、ページが走らせるローカルの module を読み、それぞれの URL が何を運ぶかで判断するようになりました: それぞれがリアクティブなコアを持つ `@wcstack/signals` の 2 つの読み込み — 2 つのエントリ(`.` と `./dom`)で、片方がエントリごとに束ねる CDN(`esm.run`・jsDelivr の `…/+esm`・`esm.sh`)から来るか、両方がビルドの違う `dist` のファイル(`.esm.js` と `.esm.min.js` はコアのチャンクが別)。または、どこからでも 2 つの版。呼び出し表示は、ページが読む module で `signal` を `…/@wcstack/signals@4.32.0/+esm` から、残りを `…/dist/dom.esm.min.js` から import していました: 時計を描く effect はその signal を追わず、時計は動きませんでした。1 つのビルドのファイルとして配る 2 つのエントリは 1 つのコアを共有するので通ります。裸の名前は import map を通して読みます(どのエントリも与えない名前はバンドラのもので、通ります)。module の中の所見は、その module のその行に報告します。すべての名前を `@wcstack/signals/dom` から import してください。
|
|
234
|
+
- **ローカルの module が `@wcstack/signals` を読み込むか wcstack の版を固定するページは検査され**、`nothing to check:` には載りません — `wcs/signals-dual-entry` と `wcs/lint-version-behind` が読みます。`wcs/lint-version-behind` は、それらの module の固定も読みます。`/` から始まる module は `--root=<dir>` があるときだけ読みます。
|
|
235
|
+
- **`wcs/event-before-binding`**(warning) — リテラルの `url` を持つ `<wcs-sse>` / `<wcs-ws>`、リテラルの `name` を持つ `<wcs-broadcast>` の `eventToken.message:`(要素の契約が `semantics: "event"` と宣言する出力)。要素はパッケージが定義した時点で接続し、state のファイルが読み込まれてトークンを束ねるより前です: ストリームの最初のイベント — 待ち行列のスナップショット — は誰にも届かず、8 人待ちで 0 人と出ていました。`url` を state から与える(`url: streamUrl`)とページを束ねてから始まります。または出力をプロパティとしても束ねてください(`message: lastEvent`、または spread)。要素の値で state に種を入れます。`manual`・`<template>` の中(挿入と同時に束ねる)・`<wcs-state>` の無いファイルでは言いません。ランタイムの同じ code の警告の静的な対です。
|
|
236
|
+
- **`wcs/input-nested-write`** は 2 つ目の直し方も言います: 要素には別のキーを束ねて、保存したいときにそのキーへコピーを代入する。これまで勧めていた getter は、パスの下への書き込みのたびに読み直され、`<wcs-storage>` はそのたびに保存します — コンソールでは、流れてくるトークンごとに。
|
|
237
|
+
|
|
238
|
+
新しい error は `--errors-only` でも出て、新しい warning は `--strict` で落ちます。
|
|
239
|
+
|
|
226
240
|
## 生成 → 検証 → 修正ループでの利用
|
|
227
241
|
|
|
228
242
|
安定した 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:` で終わるときは、そのファイルは検査されていません。
|
package/README.md
CHANGED
|
@@ -223,6 +223,20 @@ Since 4.31, from an outside evaluation — the record of a 25-day Advent Calenda
|
|
|
223
223
|
|
|
224
224
|
The new warnings fail `--strict`; the new error shows with `--errors-only`.
|
|
225
225
|
|
|
226
|
+
## What a page with streams and a call display is told
|
|
227
|
+
|
|
228
|
+
Since 4.33, from the counter-assist seam app — an answer console that streams an LLM's answer with `$stream`, a CSV import in a worker, and a call display fed by one SSE stream (one page written with `@wcstack/signals`, one with the state). Its author made 25 mistakes on purpose, and this lint said nothing about any of them; it listed the signals page as having nothing to check. What it says now:
|
|
229
|
+
|
|
230
|
+
- **`wcs/stream-declaration`** (error) — a `$stream` entry written as an object literal with a `fold` and no `initial` (`answer: { args, source, fold: foldAnswer }`), or with no `source`. The runtime refuses the state when it takes it in (`$stream entry "answer": fold needs an initial value.`): the page fails to initialize, and every route of the console was dead. `initial: undefined` is an initial value, as at runtime. Only what is certain: not an entry that is a name or a call, has a spread or a computed key, or may be replaced by a spread written after it; not in a volume (`wcs/volume-declaration` says so) or a `bind-component` state. A `src=` file's state is reported in the file.
|
|
231
|
+
- **`wcs/html-sink-input`** (warning) — an HTML sink (`html:`, `innerHTML:`, `outerHTML:`, `srcdoc:`) bound to the path a form control on the page writes back through a two-way `value:` — `<textarea data-wcs="value: question">` with `<p data-wcs="html: question">`. What the user types goes onto the page as markup: `<b>` turns bold, `<img src=x onerror=…>` runs — unless a filter sanitizes it, so a filter on the sink does not silence it. Bind it as text (`textContent:`). Paths are compared as state paths: `.q` in a `for: turns` row is `turns.*.q`. Text that reaches the sink through another path (a method that copies the question into the list the page shows — the seam app's own shape) is not followed. Once per sink binding.
|
|
232
|
+
- **`wcs/v5-migration`** (info; since 4.34) — what 5.0 changes, as far as the markup and the scripts show it: a `$postUpdate` whose literal path has a `*` (the caller's row in 4.x, every row in 5.0), `<wcs-storage key="…">` and `key:` bound on one (5.0 takes `storage-key` / `storageKey:` only), `attr.on*:` (5.0 refuses a handler written as a string), `trigger:` written before another input of the same element (5.0 applies the inputs first), and `$behavior`'s `sameValueGuard: false` / `enableDirectionalInitialSync: false` (5.0 removes both). Each message gives the form that works on 4.x and on 5.0, and the section of [Preparing for 5.0](https://github.com/wcstack/wcstack/blob/main/docs/migration-v5.md). What only a running page shows — a list fetched again with the same ids, a stored value the first sync writes over, a form the browser sent — is said at run time by `@wcstack/state`'s `v5-migration` add-on, as `[wcs/v5-migration]`. The rules that already name a trap 5.0 designs out (`wcs/submit-without-prevent`, `wcs/storage-seed-clobber`, `wcs/storage-init-seed`, `wcs/trigger-seeded-truthy`, `wcs/number-written-as-string`, `wcs/radio-before-value`, `wcs/command-event-argument`, `wcs/handle-bound-as-value`, `wcs/delegated-current-target`, `wcs/base-href-missing`) say in their message what 5.0 does.
|
|
233
|
+
- **`wcs/signals-dual-entry`** (error) now reads the local modules a page runs, and judges by what each URL carries: two loads of `@wcstack/signals` that each have their own reactive core — the two entries (`.` and `./dom`) where one comes from a CDN that bundles each entry (`esm.run`, jsDelivr's `…/+esm`, `esm.sh`) or both are `dist` files of two builds (`.esm.js` and `.esm.min.js` have separate core chunks), or two versions from any source. The display imported `signal` from `…/@wcstack/signals@4.32.0/+esm` and the rest from `…/dist/dom.esm.min.js` in a module its page loads: the effect that drew the clock never saw its signal, and the clock never moved. Two entries served as files of one build share one core and pass; a bare name is read through the import map (one no entry gives is a bundler's, and passes). A finding in a module is reported in the module, at its line. Import every name from `@wcstack/signals/dom`.
|
|
234
|
+
- **A page whose local modules load `@wcstack/signals` or pin a wcstack version is checked**, not listed under `nothing to check:` — `wcs/signals-dual-entry` and `wcs/lint-version-behind` read it. `wcs/lint-version-behind` also reads the pins in those modules. A module from `/` is read only with `--root=<dir>`.
|
|
235
|
+
- **`wcs/event-before-binding`** (warning) — `eventToken.message:` on a `<wcs-sse>` / `<wcs-ws>` with a literal `url`, or a `<wcs-broadcast>` with a literal `name` (an output the element's contract declares `semantics: "event"`). The element connects as soon as its package defines it, before the state's file has loaded and bound the token: the stream's first event — the queue's snapshot — was dispatched to nobody, and the page showed 0 waiting with 8 waiting. Give it the `url` from the state (`url: streamUrl`) so it starts once the page is bound, or bind the output as a property too (`message: lastEvent`, or a spread), which seeds the state from the element. Not with `manual`, nor inside a `<template>` (bound as it is inserted), nor in a file without a `<wcs-state>`. The static twin of the runtime warning of the same code.
|
|
236
|
+
- **`wcs/input-nested-write`** also names a second way out: bind a separate key to the element and assign it a copy when the value should be stored. The getter it suggested is re-read, and `<wcs-storage>` saves, on every write below the path — every streamed token, in the console.
|
|
237
|
+
|
|
238
|
+
The new errors are printed with `--errors-only` too; the new warnings fail `--strict`.
|
|
239
|
+
|
|
226
240
|
## Use in generate–validate–fix loops
|
|
227
241
|
|
|
228
242
|
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.
|