@wcstack/lint 4.28.0 → 4.30.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 (4) hide show
  1. package/README.ja.md +39 -1
  2. package/README.md +39 -1
  3. package/dist/cli.cjs +3847 -2638
  4. package/package.json +1 -1
package/README.ja.md CHANGED
@@ -40,7 +40,7 @@ wcs-validate [--attr=data-wcs] [--state-tag=wcs-state] [--lang=ja|en] [--root=<d
40
40
  | `--lang=ja\|en` | 診断メッセージの言語。未指定時は環境ロケール(`LC_ALL` / `LC_MESSAGES` / `LANG` → OS ロケール)に従う。code / range は言語に依らず不変 |
41
41
  | `--root=<dir>`(`--root <dir>` も) | 4.10 から: サイトのルートのディレクトリ。/ から始まるパスをその下で読む — `<base href="/ja/">` の下の `<wcs-state src="/app.js">`(`docs/csp.md` と `examples/router-i18n` の形)や、state のファイルの `/…` からの import は `<dir>/app.js` として読む。ディレクトリの外へ出るもの(`/../x.js`)は読まない。無ければ / から始まるパスは読まない(`wcs/state-src-unread`、info)。そうしたファイルの指摘はディレクトリの下のパスで出す(`public/app.js:12:5 …`) |
42
42
  | `--errors-only`(別名 `--quiet`) | error severity の行だけ表示。warning / info の件数と exit code は不変 |
43
- | `--strict` | warning severity の診断でも exit `1` にする。severity 自体は不変(IDE の表示と同じ)で、exit code の閾値だけを error → warning に下げる。summary 行の末尾に `(strict)` が付く。パスの typo(`wcs/binding-path-missing` は warning)で CI を落としたいときに使う — ただし先に `<wcs-state src>` を全て解決可能にしておくこと(解決できない外部 state が残す warning でも落ちるようになる)。`--errors-only` と併用可: 表示は error のみのまま、exit code は warning を反映する |
43
+ | `--strict` | warning severity の診断でも exit `1` にする。severity 自体は不変(IDE の表示と同じ)で、exit code の閾値だけを error → warning に下げる。summary 行の末尾に `(strict)` が付く。パスの typo(`wcs/binding-path-missing` は warning)で CI を落としたいときに使う — ただし先に `<wcs-state src>` を全て解決可能にしておくこと(解決できない外部 state が残す warning でも落ちるようになる)。`--errors-only` と併用可: 表示は error のみのまま、exit code は warning を反映する。4.30 から、state をまるごと読めなかったと言う info(`wcs/state-src-unread` と、state の先頭の `...spread` の `wcs/path-dynamic-unknown`)も warning と同じく数え、`--errors-only` でも表示する |
44
44
 
45
45
  ## 出力と exit code
46
46
 
@@ -125,6 +125,7 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
125
125
 
126
126
  - **値を読めないキーの下は「分からない」で、「存在しない」ではありません。** `const init = emptyEntry()` の `team: init.team`、`errs: emptyErrs()`、条件式、`[1, 2].map(…)`、`[newRunner()]` の行: そうしたキーの下のパスは検査せず、キーの上の `wcs/path-dynamic-unknown`(info)が 1 回だけそう言います — その下に束ねたパスの数(キーの `for:` の行の `.name` も数えます)と、検査させる方法(キーの JSDoc の `@type` か `stateSchema`)付きで。4.22 までは、そのパスが 1 件ずつ `wcs/binding-path-missing` の誤報で、本物の打ち間違いと同じ code でした。オブジェクトリテラルを束縛する `const` のメンバー(`team: DEFAULTS.team`。モジュールの中のものも import したものも)は読み、その下のパスを検査します。
127
127
  - **`wcs/radio-name-shared`**(warning) — `for:` の行の中の、`name` をリテラルで書いた、行の値を束ねたラジオ(`<input type="radio" name="sex" data-wcs="radio: .sex">`)。どの行のラジオも同じ name になるので、ブラウザは全部の行を 1 つのグループにします: ページ全体で 1 つしか選ばれた状態にならず、表示は最初の描画から行ごとの値と食い違います。行ごとに違う name を束ねる(`attr.name: .<行のフィールド>`)か、name を外してください — `radio:` は name が無くても、同じパスに束ねたラジオを選択に合わせます。name を束ねてあるとき、行のものでないパス(`value: .id; radio: selectedId` — 行をまたぐ 1 つの選択)、行ごとに `<form>` があるときは報告しません。
128
+ - **`wcs/radio-before-value`**(warning) — `radio:` / `checkbox:` を、その要素に値を与える束縛より前に書いた(`<input type="radio" data-wcs="radio: theme; attr.value: .value">`)。束縛は書いた順に当たり、`radio:` は当たるときに要素の `value` を比べるので、まだブラウザの既定の `"on"` と比べる: 最初の描画ではどのラジオも選ばれず、実行時は何も言わない(後から state に書くと正しいものが選ばれるので、値がページを描いた後に届く所では隠れる)。値を先に書く: `attr.value: .value; radio: theme`。値の束縛が前にあるとき・値がマークアップのリテラルだけのとき(`value="red"`)は黙る。4.29 から。
128
129
  - **`wcs/number-written-as-string`**(warning) — 書き戻すときに変換しない双方向の `value:` が、state が数値で持つパスを指す: `count: 0` と `<input type="number" data-wcs="value: count">`(JSDoc の `@type {number}`・`stateSchema`・行のフィールド `value: .qty` も)。要素の `value` は文字列なので、5 と入力した後の state は `"5"` で、`count + 1` は `"51"` になります。`valueAsNumber: count` か、左辺の入力フィルタ `value|number: count`(`|int`・`|float`)と書いてください。
129
130
  - **`wcs/two-way-output-filter`**(warning) — 双方向の `value:` / `valueAsNumber:` の出力フィルタ(`value: code|upper`・`value: price|locale`)。打つ欄では、フィルタが 1 打鍵ごとに state の値を整形して欄へ書き直します: 入力中の欄が書き換わり(キャレットは末尾へ飛び、IME の変換は途切れます)、state が受け取るのも欄の整形済みの文字です — 出力フィルタは書き戻しで元に戻りません。整形した文字は別の要素に表示する、欄の確定で書き戻して setter で整形する(`value#onchange:`)、または一方向にしてください(`value#ro:`)。確定した値を書き戻す束縛(`#onchange`・`<select>`・スライダー)は、出力を元に戻す入力フィルタが無いときだけ報告します: `value#onchange|number: price|toFixed(2)` は報告しません。要素の書いた文字をそのまま返すフィルタ(`string`・`nullIfEmpty`・`coalesce(…)`・`defaults('')`)も報告しません。
130
131
  - **`attr.*` に束ねた boolean**(`wcs/binding-type-expectation`)には、起きることを言います: ランタイムは `String(value)` — `"true"` / `"false"` — を書き、属性を外すのは `null` / `undefined` だけです。その語が属性の値であるもの — ARIA の状態(`attr.aria-invalid: flag|truthy`)・`contenteditable`・`draggable`・`spellcheck` — は、もう報告しません(`"attr.aria-invalid" には文字列型が必要です` は誤報でした)。ネイティブ要素の論理属性(`attr.disabled: flag`)には、`disabled="false"` でも無効のままであることと、代わりに束ねるプロパティ(`disabled: flag`)を言います。ほかの属性(`attr.data-open: flag`)には、文字として書かれて外れないことと、false の間は外す `|defaults(null)`・文字が意図のときの `|string` を言います。
@@ -175,6 +176,43 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
175
176
 
176
177
  `--errors-only` には TypeScript で新たに見つかる error(`.ts` のモジュールで定義した要素の `wcs/tag-member-unknown`・型付きの getter の `wcs/getter-untracked-read` …)が出ます。`--strict` は新しい 2 つの warning と、広がった `wcs/filter-input-type` でも失敗します。
177
178
 
179
+ ## 部品で組み立てたページに言うこと
180
+
181
+ 4.29 から。継ぎ目アプリ garden-plots — 市の共通部品で組み立てた画面: デザイナーの部品は HTML だけ(宣言的カスタムコンポーネント)、開発者の部品はページのデータにマウントするクラス。4.28 までの lint は部品を何も知らず、作者がわざとした 45 通りの間違いのうち捕まえたのは 2 つでした。
182
+
183
+ **宣言的カスタムコンポーネント(DCC)**(`<my-pager data-wc-definition><template shadowrootmode="open"> … <wcs-state> … </wcs-state></template></my-pager>`):
184
+
185
+ - **定義は、それ自身の範囲です。** テンプレートの中のマークアップは定義の `<wcs-state>` に対して、ページのマークアップはページの state に対して検査します。4.28 までは両方のキーが 1 つの集合で、部品だけが持つキーへのページの束縛も、ページだけが持つキーへの部品の束縛も通っていました。部品のファイル(`parts/my-pager.html`)も、コマンドラインで名指せば同じに検査します。
186
+ - **`wcs/dcc-declaration`**(error) — 実行時がタグを定義するときに拒む定義。条件は実行時と同じです: リストでない `$bindables` / `$commands`、空・`$` で始まる・2 回書いた・state のメンバーでない項目、`$bindables` のメソッド、`$commands` の値、定義の中の `<wcs-state bind-component>`、定義自身の 2 つ目の `<wcs-state>`。拒まれた定義は何も定義しないので、どのページのどのインスタンスも未知の要素のままです。確かなときだけ言います: リテラルでないリスト、`export default { … }` のリテラルでない state、lint が読めない state のファイルには触れません。
187
+ - **`wcs/tag-member-unknown`**(error)が DCC も見ます: `<my-pager data-wcs="totl: n">` や `command.nxt:` を、部品の `$bindables` と `$commands` に突き合わせ、近い名前を添えます。定義は、ページが言う場所から読みます — ページの中、または import map が autoloader の `dcc` ローダーに名指すファイル: `.html` で終わるか `|dcc` と書いた eager のキー、`|dcc/` と書いた名前空間。lint が読めないファイルからは契約が出ず、そのタグの束縛は検査しません: `/` から始まるパスは `--root=<dir>` を渡したときだけ読みます。
188
+ - **`wcs/dcc-attribute`**(warning) — 部品の `$bindables` のメンバーを属性で書いたインスタンス(`<my-pager total="120">`)。DCC の入力はプロパティで、属性は読まれません: 部品は既定のままです。実行時も 4.28 から同じ code で警告します。タグと名前ごとに 1 回。
189
+
190
+
191
+ **クラスの部品**(テンプレートに `<wcs-state bind-component="state">`、インスタンスに `state = { … }` を持つ `class XCard extends HTMLElement`。`<x-card data-wcs="state: user">` でマウントする):
192
+
193
+ - **クラスは、ページが言う場所から読みます** — import map が autoloader に名指すファイル(`"@components/x-card": "./parts/x-card.js"`、または名前空間: `"@components/x/": "./parts/"` と `<x-card>` → `./parts/card.js`)、またはページが読み込むモジュールのうち `customElements.define("x-card", XCard)` を呼ぶもの。部品のテンプレートの中でマウントしている部品も、そこから辿って読みます。`.ts` のファイルは型を消して読みます。
194
+ - **部品が公開する getter は、ページのパスです。** 部品の state の getter は、部品をマウントした所のパスで読めます — `user.display`、行にマウントしたなら行の中の `.display`。部品の中の部品も同じです。4.28 までは、それを読むページに「パスが存在しない」(`wcs/binding-path-missing`)と言い、回避策 — ページのデータの JSDoc の型に getter を手で宣言する — は、後の改名を隠していました。部品から無くなった getter は、ほかの無いパスと同じに報告します。
195
+ - **部品のメソッドは、ページと同じに検査します**: `this.tenant.name = v`(`wcs/nested-assign`)と `this.plots.push(p)`(`wcs/array-mutation`)は、部品でもエラーです。所見は部品のファイルの、その行に出ます。
196
+ - **部品のテンプレートのパスで、先頭のキーをどこも与えないもの**は `wcs/binding-path-missing`(warning)で、部品のファイルに出ます: そのキーが部品自身の state のものでなく、ページが渡してもおらず(`state.view:`)、マウント先のオブジェクトにも無いとき — テンプレートの `nmae`、ページが `state.veiw:` と書いた所の `view.x`、部品の中で読んだページのパス(`pageTitle`: 渡してください)。部品の中では、そういう読みはマウント先へ落ちて何も失敗しません。実行時は 4.28 から報告していて、これは同じ基準です。マウント先のオブジェクトは、形が分かるとき(種・JSDoc の型・スキーマ)だけ判定します: 空で始まるリストの行には何も言いません。先頭のキーより深い所は言いません。
197
+ - 確かなときだけ読みます: オブジェクトリテラルの `state = { … }`(フィールドか、コンストラクタの `this.state = { … }`)で、スプレッドも計算されたキーも無いもの。テンプレートは、モジュールの中の 1 つの文字列。lint が読めないファイル(`--root` なしの `/` から始まるパス)、呼び出しで作る state、見つからないクラスには、これまでどおり何も言いません。
198
+
199
+
200
+ ## ほかのフレームワークの癖で書いたページに言うこと
201
+
202
+ 4.30 から。継ぎ目アプリ street-reports — 初めての作者が React のアプリを wcstack に移した。React(JSX)の作者が持ち込む癖は何も言われずに動くか、lint が別のものとして言いました: 式は「存在しないパス」と言われ、束縛の右辺のテンプレートリテラルや引用符の文字列は何も言われませんでした。ランタイムが拒むか黙って落とすものは error、ほかは warning で、確かなことだけを言います。
203
+
204
+ - **`wcs/binding-expression`**(error) — 束縛の右辺はパスとフィルタで、式ではありません: `hidden: !loading`・`textContent: count + 1`・`class.active: status === 'new'`・`class.is-new: .status === 'new'`・`textContent: done ? '完了' : '未完了'`・`` attr.href: `/reports/${id}` ``・`textContent: '件数: ' + count`・`textContent: formatDate(reportedAt)`・`if: items.length > 0`・`{{ count + 1 }}`・`<!--@@: count + 1 -->`。式とは、右辺(最初の `|` より前)に空白か `` ! ? = < > + ( ) ' " ` & , `` のどれかがあるもの — パスはどれも持てません。メッセージは、形にフィルタがあればそれを示し(`!x` → `x|not`・`x > 0` → `x|gt(0)`・`x === 'new'` → `x|eq(new)`・`x + 1` → `x|add(1)`)、無ければ getter を勧めます。引数付きやアロー関数のイベントの束縛(`onclick: remove(.id)`・`onchange: () => toggleRow(.id)`)には、ハンドラはメソッドの名前で `(event, ...ループの添字)` で呼ばれると言います。1 つの文字列に 1 件: 同じ文字列のパスが無いという報告(`wcs/binding-path-missing`・`wcs/path-nonexistent`)は重ねません。引数付きのフィルタ・修飾子・行のパス・ワイルドカードと添字のパス・スプレッド・`else:`・`state.key:`・`command.x:`・`eventToken.x:` は式ではありません。`a || b` は既に error です(`wcs/binding-syntax`、空のフィルタ)。`<wcs-state>` の無いファイルの `{{ }}` はほかのテンプレートエンジンのもの(`{{#each}}`)で、読みません。
205
+ - **`wcs/attribute-mustache`**(warning) — 束縛属性以外の属性の値の `{{ }}`: `href="/reports/{{ id }}"`・`class="row {{ kind }}"`・`alt="{{ title }}"`・`<wcs-link to="/reports/{{ .id }}">`。`{{ }}` はテキストでしか読まれないので、属性には波括弧が残ります。属性を束ねてください(`attr.href: <パス>`。文字列を組み立てる getter を書いて)。ページを返す前にサーバーのテンプレートが埋めるのなら正しいので warning です。`<wcs-state>` のあるファイル(または DCC の定義)だけで、state が `$behavior: { enableMustache: false }` を宣言しているとき・`data-wcs-ignore` の中では言いません。属性ごとに 1 回。
206
+ - **`wcs/structural-element`**(error) — `<template>` でない要素の `data-wcs` に単独で書いた `if:` / `elseif:` / `else:` / `for:`(`<p data-wcs="if: open">`・`<li data-wcs="for: items">`): ランタイムはその名前のプロパティを書くだけで、要素は常に表示され、一覧は 1 つの要素です。要素を `<template data-wcs="if: …">` の中に入れてください。ほかの束縛と並べたものは、これまでどおり `wcs/template-syntax` が言います。
207
+ - **`wcs/collection-mutation`**(error) — state のメソッド・setter・`$watch` と `$on` のハンドラ(`wcs/array-mutation` が見る所)で、state のリテラルでの初期値が `new Set(…)` / `new Map(…)` のキーへの `this.selected.add(id)`・`.delete(…)`・`.clear()`・`this.byId.set(k, v)`。state はそれを見ません。新しいものを代入する(`this.selected = new Set([...this.selected, id])`)か、配列 / オブジェクトで持ってください。メソッドがキーを代入し直すときは言いません。
208
+ - **`wcs/row-id-shared`**(warning) — `for:` の行の要素のリテラルの `id="…"` で、束縛(`attr.id:` / `id:`)が与えないもの: すべての行が同じ id になり、`<label for>` や `aria-labelledby` は最初の行にしか届きません。束ねてください(`attr.id: .domId` — 行のキーから組み立てる行の getter を書いて)。ループと id ごとに 1 回。行の中の `if:` の枝の下(1 行だけで描かれることがある)と shadow root の中では言いません。
209
+ - **`wcs/event-name-case`**(warning) — `onSubmit:`・`onClick:`・`onChange:`(JSX の綴り): `Submit` という名前のイベントのリスナーが付き、それを送るものはありません。DOM のイベントなら `onsubmit:`。部品のコールバック("prop")は部品が送るイベントで、`eventToken.<メンバー>:` で束ねます。
210
+ - **`wcs/inline-import`**(error) — インラインの `<wcs-state>` や `<wcs-guard-handler>` のスクリプトの静的な `import … from "./x.js"`(`../`・`/`): `blob:` URL から評価されるので、import は解決しません。`src=` のファイル・完全な URL・import map の名前を使ってください。完全な URL・裸の指定子・`src=` の state には言いません。
211
+ - **`wcs/key-binding`**(warning) — ネイティブ要素の `key:`(React の `key`): `key` という名前のプロパティを書くだけで、何もしません。key は要りません — 行は行のオブジェクトで突き合わされ、取り直したデータで行を保つのは `$listKeys` です。カスタム要素の `key` は入力のことがある(`<wcs-storage>`)ので言いません。
212
+ - **`--strict` は読めなかった state を数えます。** `wcs/state-src-unread`(lint が読めない `<wcs-state src>`)と、state の先頭の `...spread` の `wcs/path-dynamic-unknown` —— どちらの後も、その state のパスは 1 つも検査されません —— は info のままですが、`--strict` では warning と同じく数えます(exit `1`)。lint が値を読めないキー(別のファイルから import した辞書、`team: init.team`)は、state の残りを検査したままにします: `--strict` が通す info のままです。そして、summary 行がその数を言い(`(strict; 2 unchecked counted as warnings)`)、その後に `strict:` の注記が続きます。4.29 までの `--strict` は、そうした state を検査しないまま exit `0` でした。
213
+
214
+ 新しい error は `--errors-only` にも出ます。新しい warning は `--strict` で失敗します。
215
+
178
216
  ## 生成 → 検証 → 修正ループでの利用
179
217
 
180
218
  安定した 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
@@ -40,7 +40,7 @@ wcs-validate [--attr=data-wcs] [--state-tag=wcs-state] [--lang=ja|en] [--root=<d
40
40
  | `--lang=ja\|en` | Diagnostic message language. Defaults to the environment locale (`LC_ALL` / `LC_MESSAGES` / `LANG`, then the OS locale); codes and ranges are language-independent |
41
41
  | `--root=<dir>` (also `--root <dir>`) | Since 4.10: the site's root directory, where a path from `/` is read — a `<wcs-state src="/app.js">` under `<base href="/ja/">` (the form of `docs/csp.md` and `examples/router-i18n`) and an import from `/…` in a state file are read as `<dir>/app.js`; a path that leaves the directory (`/../x.js`) is not. Without it a path from `/` is not read (`wcs/state-src-unread`, info). A finding in such a file is reported under the directory (`public/app.js:12:5 …`) |
42
42
  | `--errors-only` (alias `--quiet`) | Print only error-severity lines; warning/info counts and the exit code are unchanged |
43
- | `--strict` | Exit `1` on warning-severity diagnostics too. Severities are unchanged (the IDE shows the same thing); only the exit-code threshold moves from error to warning. The summary line ends with `(strict)`. Use it to fail CI on a path typo (`wcs/binding-path-missing` is a warning) — but resolve every `<wcs-state src>` first (an unresolvable external state leaves warnings that would now fail the build). Combines with `--errors-only`: output stays error-only, the exit code still reflects warnings |
43
+ | `--strict` | Exit `1` on warning-severity diagnostics too. Severities are unchanged (the IDE shows the same thing); only the exit-code threshold moves from error to warning. The summary line ends with `(strict)`. Use it to fail CI on a path typo (`wcs/binding-path-missing` is a warning) — but resolve every `<wcs-state src>` first (an unresolvable external state leaves warnings that would now fail the build). Combines with `--errors-only`: output stays error-only, the exit code still reflects warnings. Since 4.30 the infos that say a whole state was not read — `wcs/state-src-unread`, and `wcs/path-dynamic-unknown` for a `...spread` at the top of a state — count like warnings too, and are printed with `--errors-only` |
44
44
 
45
45
  ## Output & exit codes
46
46
 
@@ -125,6 +125,7 @@ Since 4.23, from the ekiden-entry seam app — an entry wizard for a relay race,
125
125
 
126
126
  - **A key whose value the lint cannot read is unknown, not missing.** `team: init.team` beside `const init = emptyEntry()`, `errs: emptyErrs()`, a conditional, `[1, 2].map(…)`, the rows of `[newRunner()]`: the paths under such a key are not checked, and one `wcs/path-dynamic-unknown` info at the key says so — with the number of paths bound under it (a row's `.name` under the key's `for:` is one) and what has them checked: a JSDoc `@type` on the key, or a `stateSchema`. Up to 4.22 each of those paths was a false `wcs/binding-path-missing`, the same code as a real typo. A member of a `const` bound to an object literal (`team: DEFAULTS.team`, in the module or imported) is read, and the paths under it are checked.
127
127
  - **`wcs/radio-name-shared`** (warning) — radios in a `for:` row with a literal `name` and a binding of the row's (`<input type="radio" name="sex" data-wcs="radio: .sex">`). Every row's radios get the same name, so the browser makes one group of all the rows: only one radio on the whole page stays checked, and the page disagrees with the rows' values from the first render. Bind a name that differs per row (`attr.name: .<a row field>`), or drop the name — `radio:` keeps the radios bound to one path in step without it. Not reported when the name is bound, when the bound path is not the row's (`value: .id; radio: selectedId` — one choice over the rows), or when each row holds its own `<form>`.
128
+ - **`wcs/radio-before-value`** (warning) — `radio:` / `checkbox:` written before the binding that gives the control its value (`<input type="radio" data-wcs="radio: theme; attr.value: .value">`). Bindings are applied in the order written, and `radio:` compares the element's `value` when it is applied — still the browser's `"on"`: no radio is checked at the first render, and nothing at run time says so (a later write of the state checks the right one, which hides it where the value arrives after the page is drawn). Write the value first: `attr.value: .value; radio: theme`. Silent when the value binding comes first and when the value is only in the markup (`value="red"`). Since 4.29.
128
129
  - **`wcs/number-written-as-string`** (warning) — a two-way `value:` with no conversion on the way in, bound to a path the state holds as a number: `<input type="number" data-wcs="value: count">` with `count: 0` (a JSDoc `@type {number}`, a `stateSchema` and a row field `value: .qty` count too). An element's `value` is a string, so after the user enters 5 the state has `"5"` and `count + 1` is `"51"`. Write `valueAsNumber: count`, or an input filter on the left side: `value|number: count` (`|int`, `|float`).
129
130
  - **`wcs/two-way-output-filter`** (warning) — an output filter on a two-way `value:` / `valueAsNumber:` (`value: code|upper`, `value: price|locale`). In a field the user types in, the filter formats what the state holds on every keystroke: the field is rewritten while the user types — the caret jumps to the end, an IME composition is cut — and the state receives the field's formatted text, since an output filter is not undone on the way back. Show the formatted text in another element, write back when the field is committed and format in a setter (`value#onchange:`), or make the binding one-way (`value#ro:`). A binding that writes back a committed value (`#onchange`, a `<select>`, a slider) is reported only when no input filter undoes the output: `value#onchange|number: price|toFixed(2)` is not. Nor are the filters that give back what the element wrote: `string`, `nullIfEmpty`, `coalesce(…)`, `defaults('')`.
130
131
  - **A boolean given to `attr.*`** (`wcs/binding-type-expectation`) is told what happens to it: the runtime writes `String(value)` — `"true"` / `"false"` — and only `null` / `undefined` remove an attribute. Where those words are the attribute's values — the ARIA states (`attr.aria-invalid: flag|truthy`), `contenteditable`, `draggable`, `spellcheck` — nothing is reported any more (it was a false warning: `"attr.aria-invalid" requires a string`). A boolean attribute of a native element (`attr.disabled: flag`) is told that `disabled="false"` still disables, with the property to bind instead (`disabled: flag`). Any other attribute (`attr.data-open: flag`) is told that it is written as the text and never removed, with `|defaults(null)` to remove it while false and `|string` where the text is meant.
@@ -175,6 +176,43 @@ Since 4.26, from the lending-desk seam app — an equipment-lending desk written
175
176
 
176
177
  `--errors-only` prints the errors now found in TypeScript (`wcs/tag-member-unknown` on an element defined in a `.ts` module, `wcs/getter-untracked-read` on a typed getter, …); `--strict` also fails on the two new warnings and on the wider `wcs/filter-input-type`.
177
178
 
179
+ ## What a page assembled from parts is told
180
+
181
+ Since 4.29, from the garden-plots seam app — a console assembled from a city's shared parts: designers' parts in HTML alone (Declarative Custom Components), developers' parts as classes mounted on the page's data. Up to 4.28 the lint knew nothing of a part: of the 45 mistakes its author made on purpose it caught 2.
182
+
183
+ **A Declarative Custom Component** (`<my-pager data-wc-definition><template shadowrootmode="open"> … <wcs-state> … </wcs-state></template></my-pager>`):
184
+
185
+ - **A definition is a scope of its own.** The markup in its template is checked against the definition's own `<wcs-state>`, and the page's markup against the page's. Up to 4.28 the two were one set of keys: a page's binding passed on a key only a part had, and a part's on a key only the page had. A part's file (`parts/my-pager.html`) is checked the same way when it is named on the command line.
186
+ - **`wcs/dcc-declaration`** (error) — a definition the runtime refuses when it defines the tag, by the same conditions: `$bindables` / `$commands` that is not a list; an entry that is empty, starts with `$`, is written twice or is not a member of the state; a method in `$bindables`; a value in `$commands`; a `<wcs-state bind-component>` in a definition; a second `<wcs-state>` of the definition's own. The refused definition defines nothing, so every instance on every page stays an unknown element. Only what is certain is said: a list that is not a literal, a state that is not an `export default { … }` literal and a state file the lint cannot read are left alone.
187
+ - **`wcs/tag-member-unknown`** (error) now covers a DCC: `<my-pager data-wcs="totl: n">` and `command.nxt:` are checked against the part's `$bindables` and `$commands`, with the near name. The definition is read where the page says it is — in the page, or in the file the import map names for the autoloader's `dcc` loader: an eager key whose file ends in `.html` or that says `|dcc`, a namespace that says `|dcc/`. A file the lint cannot read gives no contract, and the tag's bindings are not checked: a path from `/` is read only with `--root=<dir>`.
188
+ - **`wcs/dcc-attribute`** (warning) — an instance that carries one of the part's `$bindables` as an attribute (`<my-pager total="120">`). A DCC's inputs are properties: the attribute is not read, and the part shows its default. The runtime warns with the same code since 4.28. Once per tag and name.
189
+
190
+
191
+ **A class part** (`class XCard extends HTMLElement` with `<wcs-state bind-component="state">` in its template and `state = { … }` on the instance, mounted with `<x-card data-wcs="state: user">`):
192
+
193
+ - **The class is read where the page says it is** — the file the import map names for the autoloader (`"@components/x-card": "./parts/x-card.js"`, or a namespace: `"@components/x/": "./parts/"` and `<x-card>` → `./parts/card.js`), or a module the page loads that calls `customElements.define("x-card", XCard)`. A part's own template is read for the parts it mounts in turn. `.ts` files are read with their types erased.
194
+ - **The getters a part exports are paths of the page.** A getter of the part's state is readable at the path the part is mounted on — `user.display`, and `.display` in the rows a part is mounted on, a part inside a part included. Up to 4.28 a page that read one was told the path does not exist (`wcs/binding-path-missing`), and the way round it — declaring the getter by hand in the JSDoc type of the page's data — hid a later rename. A getter the part no longer has is reported as any missing path.
195
+ - **A part's methods are checked like a page's**: `this.tenant.name = v` (`wcs/nested-assign`) and `this.plots.push(p)` (`wcs/array-mutation`) are errors in a part too. The finding is in the part's file, at its line.
196
+ - **A path of a part's template whose first key nothing gives** is `wcs/binding-path-missing` (warning), in the part's file: the key is not one of the part's own state, the page does not hand it over (`state.view:`), and the object the part is mounted on does not have it — `nmae` in the template, `view.x` where the page wrote `state.veiw:`, a path of the page read inside the part (`pageTitle`: hand it over). Inside a part such a read falls through and fails nothing; the runtime reports it since 4.28, and this is the same test. The mounted object is judged only where its shape is known (a seed, a JSDoc type, a schema): rows of a list that starts empty say nothing. Deeper than the first key nothing is said.
197
+ - Only what is certain is read: `state = { … }` as an object literal (a field, or `this.state = { … }` in the constructor) with no spread and no computed key, and a template that is one string of the module. A file the lint cannot read (a path from `/` without `--root`), a state built by a call, a class it cannot find: nothing is said about the tag, as before.
198
+
199
+
200
+ ## What a page written from another framework's habits is told
201
+
202
+ Since 4.30, from the street-reports seam app — a React app ported to wcstack by a first-time author. The habits a React (JSX) author brings ran without a word, or the lint described them as something else: an expression was "a path that does not exist", and a template literal or a quoted string on the right of a binding was not reported at all. What the runtime refuses or silently drops is an error, the rest a warning, and only what is certain is said.
203
+
204
+ - **`wcs/binding-expression`** (error) — the right side of a binding is a path and filters, not an expression: `hidden: !loading`, `textContent: count + 1`, `class.active: status === 'new'`, `class.is-new: .status === 'new'`, `textContent: done ? '完了' : '未完了'`, `` attr.href: `/reports/${id}` ``, `textContent: '件数: ' + count`, `textContent: formatDate(reportedAt)`, `if: items.length > 0`, `{{ count + 1 }}`, `<!--@@: count + 1 -->`. An expression is a right side (before the first `|`) with whitespace in it or one of `` ! ? = < > + ( ) ' " ` & , ``, none of which a path can hold. The message names the filter where the form has one — `!x` → `x|not`, `x > 0` → `x|gt(0)`, `x === 'new'` → `x|eq(new)`, `x + 1` → `x|add(1)` — and a getter otherwise. On an event binding with arguments or an arrow function (`onclick: remove(.id)`, `onchange: () => toggleRow(.id)`) it says that a handler is a method name, called with `(event, ...loopIndexes)`. One finding per text: the missing-path report of the same text (`wcs/binding-path-missing`, `wcs/path-nonexistent`) is not added. Filters with arguments, modifiers, row paths, wildcard and index paths, spreads, `else:`, `state.key:`, `command.x:` and `eventToken.x:` are not expressions; `a || b` is already an error (`wcs/binding-syntax`, an empty filter). `{{ }}` in a file without a `<wcs-state>` is another template engine's (`{{#each}}`) and is not read.
205
+ - **`wcs/attribute-mustache`** (warning) — `{{ }}` in an attribute other than the bind attribute: `href="/reports/{{ id }}"`, `class="row {{ kind }}"`, `alt="{{ title }}"`, `<wcs-link to="/reports/{{ .id }}">`. `{{ }}` is read in text only, so the attribute keeps the braces; bind it (`attr.href: <path>`, with a getter that builds the string). A warning, since a server-side template that fills it before the page is served is fine. Only in a file (or a DCC definition) with a `<wcs-state>`, not where the state declares `$behavior: { enableMustache: false }`, not in a `data-wcs-ignore` subtree; once per attribute.
206
+ - **`wcs/structural-element`** (error) — `if:` / `elseif:` / `else:` / `for:` alone in the `data-wcs` of an element that is not a `<template>` (`<p data-wcs="if: open">`, `<li data-wcs="for: items">`): the runtime sets a property of that name and does nothing else — the element is always shown, the list is one element. Put the element inside `<template data-wcs="if: …">`. Beside another binding, `wcs/template-syntax` says it as before.
207
+ - **`wcs/collection-mutation`** (error) — in a state's methods, setters, `$watch` and `$on` handlers (where `wcs/array-mutation` looks): `this.selected.add(id)`, `.delete(…)`, `.clear()`, `this.byId.set(k, v)` on a key whose initial value in the state literal is `new Set(…)` / `new Map(…)`. The state does not see it. Assign a new one (`this.selected = new Set([...this.selected, id])`), or keep an array / an object. Not said when the method assigns the key again.
208
+ - **`wcs/row-id-shared`** (warning) — a literal `id="…"` on an element of a `for:` row that no binding gives (`attr.id:` / `id:`): every row gets the same id, and a `<label for>` or `aria-labelledby` reaches the first row only. Bind it (`attr.id: .domId`, with a row getter that builds it from the row's key). Once per loop and id. Not under an `if:` branch in the row (it may be drawn for one row at a time) nor in a shadow root.
209
+ - **`wcs/event-name-case`** (warning) — `onSubmit:`, `onClick:`, `onChange:` (JSX's spelling): the listener is added for an event named `Submit`, which nothing dispatches. Write `onsubmit:` for a DOM event; a callback "prop" of a part is an event the part dispatches, bound with `eventToken.<member>:`.
210
+ - **`wcs/inline-import`** (error) — a static `import … from "./x.js"` (`../`, `/`) in an inline `<wcs-state>` or `<wcs-guard-handler>` script: it is evaluated from a `blob:` URL, and the import does not resolve. Use a `src=` file, a full URL, or an import-map name. Not for a full URL, a bare specifier or a `src=` state.
211
+ - **`wcs/key-binding`** (warning) — `key:` on a native element (React's `key`): it sets a property named `key` and does nothing. No key is needed: rows are matched by the row object, and `$listKeys` keeps rows across refetched data. A custom element's `key` may be an input (`<wcs-storage>`) and is not reported.
212
+ - **`--strict` counts a state that was not read.** `wcs/state-src-unread` (a `<wcs-state src>` the lint cannot read) and the `wcs/path-dynamic-unknown` of a `...spread` at the top of a state — after either, none of that state's paths is checked — stay info, but under `--strict` they count like warnings (exit `1`). A key whose value the lint cannot read (a dictionary imported from another file, `team: init.team`) leaves the rest of the state checked: it stays an info that `--strict` passes. For those two, the summary line says how many (`(strict; 2 unchecked counted as warnings)`) and a `strict:` note follows it. Up to 4.29 `--strict` exited `0` with such a state unchecked.
213
+
214
+ The new errors are printed with `--errors-only` too; the new warnings fail `--strict`.
215
+
178
216
  ## Use in generate–validate–fix loops
179
217
 
180
218
  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.