@wcstack/lint 4.24.2 → 4.26.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 +32 -0
- package/README.md +32 -0
- package/dist/cli.cjs +9294 -7712
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -95,6 +95,7 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
|
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
- **発見**: HTML ファイルから上へ辿って最も近い `wcstack.manifest.json` が自動で使われます — コマンドラインに渡す必要はありません。`application` artifact を含む `*.manifest.json` を引数に渡した場合は、その実行全体で発見を置き換えます。VS Code 拡張も同じファイルを発見するので IDE と CLI の結果は一致します。
|
|
98
|
+
- **schema を当てるページ**(4.26 から): schema を作った state のファイルを記した manifest — `wcstack.application.stateSource`、manifest からの相対で、`wcs-schema emit` が書きます — は、そのファイルを root の `<wcs-state src>` で読むページだけの契約です(同じパスの `.js` と `.ts`、`.mjs` と `.mts` は同じファイル)。state がインラインのページや別のファイルのページは、発見した manifest でも引数に渡した manifest でも、manifest が無いものとして検査します。4.25 までは、アプリの schema をその下のすべてのページに当てていたので、アプリの隣で自前のインラインの state を持つページの正しいパスが `wcs/path-nonexistent` の error になっていました。`stateSource` の無い manifest(手書き・それより前の `wcs-schema` が作ったもの)は、これまでどおりすべてのページに当てます。
|
|
98
99
|
- **効果**: `stateSchema` を宣言すると、schema 上に確定的に存在しないバインドパスは `wcs/path-nonexistent`(**error**・exit `1`)、`for:` に非配列は `wcs/path-type-mismatch`(**error**)になります。schema が開いたままの箇所(素の `{}`)は沈黙し、インラインスクリプトのメソッド / getter / `$listKeys` は引き続き存在扱いです。`stateSchema` が無ければ従来どおりです。
|
|
99
100
|
- **契約が要るとき**: validator が全体を読めない state は、契約が無いとパスをまったく検査できません。よくあるのはトップレベルの spread です — `export default { ...defaults(), get total() { … } }` は静的には見えないキーを持ち込むので、その state のパスは検査しません。4.4 から、spread の上で 1 回だけそう言います(`wcs/path-dynamic-unknown`、info)。`stateSchema` があれば束縛を —— 4.4 から getter の中で読むパス(`wcs/read-path-missing`)も —— それで検査します。読めない `<wcs-state src>` — / から始まるパス・URL・無いファイル — の state も検査できません。4.7 から、それを属性の上で 1 回だけ言います(`wcs/state-src-unread`、info)。4.6 までは何も言いませんでした。`src` はページからの相対パスで読むので、ファイルはサーバーと同じ並びに置き、/ から始まるパスには 4.10 から `--root=<dir>` を渡してください。
|
|
100
101
|
- **schema の出どころ**: 手で書く(受け付けるのは JSON-Schema サブセット `type / properties / required / items / enum / const / anyOf / $defs / $ref` のみ)か、TypeScript の state ファイル(または JSDoc で型を付けた JavaScript のファイル)から `wcs-schema`(`@wcstack/typescript`)で生成します。manifest は派生物なので、CI では `wcs-schema check` で同期を保ってください。
|
|
@@ -143,6 +144,37 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
|
|
|
143
144
|
|
|
144
145
|
新しい 2 つの error は `--errors-only` にも出ます。新しい warning は `--strict` で失敗します。
|
|
145
146
|
|
|
147
|
+
## 画面とセンサーの要素のページに言うこと
|
|
148
|
+
|
|
149
|
+
4.25 から、継ぎ目アプリ stamp-rally — 画面とセンサーの要素のスタンプラリー: 全画面・画面の向き・傾きとセンサー・共有・連絡先・資格情報・スリープの抑止 — から。作者がわざとした 20 の間違いのどれにも、この lint はそれとして報告しませんでした。いま言うこと:
|
|
150
|
+
|
|
151
|
+
- **`wcs/path-readonly`**(error)は、カスタム要素が書くメンバーを setter の無い getter に束ねた形も報告します — `<wcs-wakelock data-wcs="held: keepAwake">` と `get keepAwake() { … }`。出力だけのメンバーは束ねた時点で書かれるので、state の初期化が失敗し、ページ全体が動きません(`[wcs/path-readonly] "keepAwake" is a getter without a setter`)。lint は 0 件でした。判定はランタイムの配線と同じです: `#ro` でも変わらず、`#init=none` なら要素が値を知らせるたびに失敗し、要素が何も書かないのは `#ro,init=none` だけです。入力でもあるメンバー(`<wcs-storage>` の `value`・`trigger`)は、要素が値を知らせるたび — 要素に渡すだけの getter は `value#ro:` で一方向に束ねます — と、`#init=element` の束ねた時点に書かれます。spread が束ねるメンバーも同じに読みます。組み込みの `wcs-*` タグと、ページがリテラルの `static wcBindable` で定義する要素が対象です。
|
|
152
|
+
- **`wcs/token-undeclared`** は、`$commandTokens` / `$eventTokens` そのものが無い state のトークンも報告します — トークンが 1 つも無い、いちばん確かな場合で、lint が黙っていた場合です(宣言を写し忘れた Quick Start): `command.select: $command.select`(error — state の初期化が失敗する)、スクリプトの `this.$command.select.emit(…)`(error)、`on*: $command.x` と `eventToken.<member>: name`(warning — イベントのたびに報告される)。`$eventTokens` に無い `$on` のエントリも error です: ランタイムは state の読み込みを拒みます。「無い」と言うのは、宣言を全部読める state だけです — トップレベルに spread の無い `export default { … }` か JSON で、キーが無いか空のリストのとき。未宣言の `on*: $command.x` はこの code になりました(以前は `wcs/binding-path-missing`)。
|
|
153
|
+
- **`wcs/command-event-argument`**(warning) — データを取るコマンドに直結した `on*: $command.x`: `<button data-wcs="onclick: $command.share">` と `<wcs-share data-wcs="command.share: $command.share">`。イベントから emit したトークンはイベントを第 1 引数として運び、コマンドはそれで呼ばれます: `<wcs-screen-orientation>` の `lock(event)` と `<wcs-share>` の `share(event)` はブラウザの TypeError が `error` に出るだけ、`<wcs-credential>` の `get(event)` は何も言わず `null` になります。state のメソッドから emit してください: `onclick: share` と `share() { this.$command.share.emit({ … }) }`。組み込みタグの、メソッドが引数を宣言するコマンドが対象です。引数の無いコマンド(`start`・`requestFullscreen` — ボタンへの直結が短い書き方)、受け取る種類でない第 1 引数を無視する 4 つ — `<wcs-fetch>` の `fetch`・`<wcs-ws>` の `close`・`<wcs-idle>` の `start`・`<wcs-notify>` の `close` — 、ネイティブ要素のコマンドには出しません。
|
|
154
|
+
- **`wcs/frequency-invalid`**(warning) — `<wcs-accelerometer>` / `<wcs-gyroscope>` / `<wcs-magnetometer>` / `<wcs-ambient-light-sensor>` の、正の数値でないリテラルの `frequency`: `frequency="60hz"`・`"0"`・`"-5"`。要素はそれを「指定なし」として読み、センサーはブラウザの既定の頻度で黙って動きます。文面は、値の先頭の数値(`frequency="60"`)を言います。束ねた `frequency:` は検査しません。
|
|
155
|
+
- **`wcs/target-selector`**(warning) — `<wcs-fullscreen>` / `<wcs-pip>` / `<wcs-pointer-lock>` / `<wcs-intersect>` / `<wcs-resize>` の、裸の語で書いたリテラルの `target` で、文書にその id の要素があり、そのタグ名の要素が無いもの: `target="viewer"` は `<viewer>` 要素を選ぶ CSS セレクタで、`#viewer` のつもりです。コマンドは失敗し、それを知らせるのは要素の `error` だけです。監視の 2 つは何も監視しません。
|
|
156
|
+
- **`wcs/output-path-written`**(warning) — 要素の出力に束ねたパスへ、スクリプトが `true` を代入する: `<wcs-fullscreen data-wcs="active: viewerFs">` と `this.viewerFs = true`。出力は要素が書くものなので、全画面にはなりません — そしてその値を表示するもの(`class.fullscreen: viewerFs`・ボタンのラベル)は、そうなったと言います。要素にはコマンドで頼んでください。わざと狭い規則です: `= true` だけ(使い終えた出力を `false` や `null` に戻すのは普通の書き方)で、カスタム要素の入力やネイティブ要素の双方向の束縛(`checked: flag`)にも束ねたパスには言いません。
|
|
157
|
+
- **要素の出力が書くスロットは「分からない」であって「無い」ではありません。** `picked: null` と `<wcs-contacts data-wcs="value: picked">`、`users: []` と `<wcs-fetch data-wcs="value: users">`、spread が書く `<パス>.value`: スロットの中身は要素が渡すものなので、その下に束ねたパス(`picked.0.name.0`・行の `.name`)は検査せず、キーの上の `wcs/path-dynamic-unknown`(info)1 件がそう言います。以前は 1 件ずつ `wcs/binding-path-missing` でした。キーに JSDoc の `@type` を付ければ検査します。
|
|
158
|
+
- **`wcs/input-nested-write`** は、代わりに束ねる形を言います: アクセサペア(`value#init=element: <getter>`)か、一方向の `value#ro: <getter>`。setter も `#ro` も無い getter は保存はしますが、要素が知らせる値の書き戻しを拒まれます。
|
|
159
|
+
|
|
160
|
+
広がった `wcs/path-readonly` と `wcs/token-undeclared` の error は `--errors-only` にも出ます。新しい 4 つの warning は `--strict` で失敗します。
|
|
161
|
+
|
|
162
|
+
## TypeScript で書くチームに言うこと
|
|
163
|
+
|
|
164
|
+
4.26 から、継ぎ目アプリ lending-desk — TypeScript で書くチームの備品の貸出窓口: `.ts` の state、生成した `stateSchema`、`.ts` のモジュールで定義する要素、1 つの共有ファイルに置いた API の型。そのページは、比較の綴り違いのステータス、ステッパーに無いメンバーへの束縛、読むものの半分しか追跡しない getter、manifest には残っている 3 つの改名したキーなどを抱えたまま、この lint を 0 error・0 warning で通っていました。そこへ行き着くために、ハンドラの戻りの型も外していました。いま言うこと:
|
|
165
|
+
|
|
166
|
+
- **`.ts` の state の戻りの型を読みます。** `get total(): number {`・`submit(e: Event): void {`・`$watch` の `count(cur: number): void {` — オブジェクト型・合併・`Promise<…>`・型引数・型述語も — でメンバーが隠れなくなりました。4.25 までは、そのメンバーを読まず: ページに束ねた getter やメソッドは `wcs/binding-path-missing`(`stateSchema` があれば `wcs/path-nonexistent` — メソッドは schema に無い)、ハンドラの引数の `cur:` は `$watch` のキー(`wcs/watch-path-missing "cur"`)になり、スクリプトの規則(`wcs/getter-untracked-read`・`wcs/nested-assign`・`wcs/array-mutation` …)は型付きの getter を飛ばしていました。TypeScript の構文のある本体(`x as T`・`y!`・型付きの局所変数)・state が import する `.ts` のモジュール・ページの `.ts` のモジュールは、Node の `module.stripTypeScriptTypes` で型を消して読みます(Node 22.13 以降。それより古い Node では従来どおり検査しません)。パッケージは足していません: `@wcstack/lint` は依存ゼロのままです。
|
|
167
|
+
- **`wcs/tag-member-unknown` は TypeScript で定義した要素も読みます。** `<script type="module" src="./main.ts">` とそれが import する `.ts`(`./x.js` の import は `.js` が無ければ `./x.ts`、拡張子の無い import は `./x.ts` → `./x.js`): `static wcBindable = { … } as const satisfies Decl` もリテラルです。4.25 までは `.js` / `.mjs` のモジュールだけを読んでいたので、`max` を宣言するステッパーへの `maximum:` が通り、ステッパーは上限を持ちませんでした。
|
|
168
|
+
- **`wcs/filter-arg-enum`**(warning) — 比べる値が決して取らないリテラルを引数にした比較のフィルタ(`eq` / `ne`): 型が `"pending" | "approved" | "denied"` のときの `class.st-approved: .status|eq('aproved')`(`stateSchema` の `enum` / `const` / `anyOf` の const、JSDoc のリテラルの合併 — `@typedef` や import した型を通しても)。`eq` は決して真にならず(`ne` はいつも真)、バッジの色は黙って出ません。取りうる値と綴りの近い値を挙げます。パスに最初にかけたフィルタだけを見ます。
|
|
169
|
+
- **`wcs/filter-input-type` は、持っている型を使います。** 行のパス(`for: rows` の中の `.label|toFixed(0)`)は、展開した行のフィールドの型 — リテラルの行・JSDoc の型・`stateSchema`(getter も: schema が string と言う `.depositLabel|toFixed(0)`)— で読みます。日付のフィルタ(`date`・`time`・`datetime`・`ymd`・`hms`)はランタイムと同じく `Date` だけを受けます(null 以外はランタイムが throw する): ISO の文字列への `.at|date` を報告します。4.25 までは、リテラルの種を持つ書き切ったパスだけを検査していました。
|
|
170
|
+
- **別モジュールの JSDoc の型を読みます。** `/** @type {import("./api.ts").Reservation[]} */`・getter の `@returns {import("./api.ts").Reservation[]}`・`@typedef {import("./api").Reservation} Reservation`: 型をそのファイル — `.ts` / `.d.ts` の `interface` と `type`、`.js` の `@typedef` — から読み、その下に束ねた行を検査します。読めない型(ファイルが無い・名前が無い)のキーの下は検査せず、1 回だけそう言います(`wcs/path-dynamic-unknown`、info)— 分からないのであって、無いのではありません。4.25 までは、そのリストの下に束ねたフィールドが 1 件ずつ偽の `wcs/binding-path-missing` でした。
|
|
171
|
+
- **`[]` に落ちる getter の行を「無い」と言いません。** `get pickups() { return this.counter ? this.counter.pickups : []; }`(`X ?? []`・`X || []`・早い `return []` も)で `X` の形が分からないとき、行は分からないものとし、getter の上で 1 回言います(`wcs/path-dynamic-unknown`)。4.25 までは `[]` が行のフィールドをすべて `wcs/binding-path-missing` にしていました。行の分かるリスト(`this.items ?? []`)はこれまでどおり検査します。
|
|
172
|
+
- **`wcs/watch-path-missing` は `stateSchema` を見ます。** 束縛と同じく、schema が持つキーは報告せず、確かに持たないキーだけを報告します。
|
|
173
|
+
- **`wcs/drift-state-key`**(warning) — このページに当てた `stateSchema` と root の state のスクリプトの、トップレベルのキーの食い違い: `.ts` で `get displayName()` に名前を変え、manifest にはまだ `headerName` がある。古い schema はスクリプトに勝ち — 古い名前に残った束縛が通り(0 error・0 warning)、その後に足したキーは `wcs/path-nonexistent` でした。`<wcs-state>` の開始タグの上で 1 回、両側のキーを挙げ、作り直しの `wcs-schema emit` を案内します — CI ではこの lint の前に `wcs-schema check` を走らせてください。両側が分かるときだけ: 読み切れる root の state のスクリプト(トップレベルの spread・計算したキー・`$stream` / `$scan` が無い)と schema のトップレベルの properties。ボリュームのマウントの根は数えません。
|
|
174
|
+
- **schema はその state のページに当てます** — 上の「schema を当てるページ」。
|
|
175
|
+
|
|
176
|
+
`--errors-only` には TypeScript で新たに見つかる error(`.ts` のモジュールで定義した要素の `wcs/tag-member-unknown`・型付きの getter の `wcs/getter-untracked-read` …)が出ます。`--strict` は新しい 2 つの warning と、広がった `wcs/filter-input-type` でも失敗します。
|
|
177
|
+
|
|
146
178
|
## 生成 → 検証 → 修正ループでの利用
|
|
147
179
|
|
|
148
180
|
安定した 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
|
@@ -95,6 +95,7 @@ Without a contract, a path the validator cannot resolve is only a **warning** (`
|
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
- **Discovery**: the nearest `wcstack.manifest.json` walking up from the HTML file is used automatically — nothing to pass on the command line. Passing `*.manifest.json` arguments that contain an `application` artifact replaces discovery for the whole run. The VS Code extension discovers the same file, so IDE and CLI agree.
|
|
98
|
+
- **Which pages a schema is for** (since 4.26): a manifest that names the state file its schema was generated from — `wcstack.application.stateSource`, relative to the manifest, which `wcs-schema emit` writes — is the contract only of a page whose root `<wcs-state src>` loads that file (`.js` and `.ts`, `.mjs` and `.mts` of one path being one file). A page whose state is inline, or another file, is checked as if there were no manifest, whether the manifest was discovered or passed on the command line. Up to 4.25 the app's schema was applied to every page under it, so a page with its own inline state beside the app got `wcs/path-nonexistent` errors for its correct paths. A manifest without `stateSource` (hand-written, or generated by an earlier `wcs-schema`) applies to every page as before.
|
|
98
99
|
- **Effect**: when a `stateSchema` is declared, a bound path that the schema definitely lacks is `wcs/path-nonexistent` (**error**, exit `1`); `for:` on a non-array is `wcs/path-type-mismatch` (**error**). Paths the schema leaves open (a bare `{}`) stay silent, and methods / getters / `$listKeys` from the inline script still count as existing. Without a `stateSchema`, behavior is unchanged.
|
|
99
100
|
- **When a contract is needed**: a state the validator cannot read in full needs one for its paths to be checked at all. A top-level spread is the common case — `export default { ...defaults(), get total() { … } }` brings in keys no static reader sees, so the validator checks no path of that state, and since 4.4 it says so once, at the spread (`wcs/path-dynamic-unknown`, info). With a `stateSchema` the bindings — and, since 4.4, the paths the getters read (`wcs/read-path-missing`) — are checked against it. A `<wcs-state src>` it cannot read — a path from `/`, a URL, a file that is not there — leaves that state unchecked as well; since 4.7 it says so once, at the attribute (`wcs/state-src-unread`, info), where up to 4.6 it said nothing. It reads a `src` relative to the page: keep the files laid out as on the server, and since 4.10 pass `--root=<dir>` for a path from `/`.
|
|
100
101
|
- **Where the schema comes from**: write it by hand (only the JSON-Schema subset `type / properties / required / items / enum / const / anyOf / $defs / $ref` is accepted), or generate it from a TypeScript state file — or a JavaScript one with JSDoc types — with `wcs-schema` (`@wcstack/typescript`). The manifest is a derived artifact — keep it in sync with `wcs-schema check` in CI.
|
|
@@ -143,6 +144,37 @@ Since 4.24, from the town-archive seam app — an archive of 12,000 photos: a lo
|
|
|
143
144
|
|
|
144
145
|
`--errors-only` prints the two new errors; `--strict` also fails on the new warning.
|
|
145
146
|
|
|
147
|
+
## What a page of screen and sensor elements is told
|
|
148
|
+
|
|
149
|
+
Since 4.25, from the stamp-rally seam app — a stamp rally on the screen and sensor elements: fullscreen, the screen's orientation, tilt and the sensors, share, contacts, credentials, the wake lock. Its author made 20 mistakes on purpose, and this lint reported none of them for what it was. What it says now:
|
|
150
|
+
|
|
151
|
+
- **`wcs/path-readonly`** (error) also reports a member a custom element writes, bound to a getter without a setter — `<wcs-wakelock data-wcs="held: keepAwake">` with `get keepAwake() { … }`. An output-only member is written when it is bound, so the state fails to initialize and the whole page is dead (`[wcs/path-readonly] "keepAwake" is a getter without a setter`); the lint said 0 errors. Read as the runtime wires it: `#ro` does not change that, `#init=none` moves the failure to each time the element reports a value, and only `#ro,init=none` makes the element write nothing. A member that is an input too (`value` on `<wcs-storage>`, `trigger`) is written each time the element reports a value — bind a getter that only feeds the element one way, `value#ro:` — and when it is bound with `#init=element`. A spread's members are read the same way. For the built-in `wcs-*` tags and an element the page defines with a literal `static wcBindable`.
|
|
152
|
+
- **`wcs/token-undeclared`** also reports a token used in a state that has no `$commandTokens` / `$eventTokens` at all — the one case where no token can exist, and the one the lint was silent on (a Quick Start copied with its declaration left out): `command.select: $command.select` (error — the state fails to initialize), `this.$command.select.emit(…)` in the script (error), `on*: $command.x` and `eventToken.<member>: name` (warning — reported each time the event fires). A `$on` entry whose name `$eventTokens` does not declare is an error too: the runtime refuses the state when it loads. "The state has none" is said only of a state read in full — an `export default { … }` literal with no top-level spread, or JSON, where the key is absent or an empty list. An undeclared `on*: $command.x` now carries this code; it used to be a `wcs/binding-path-missing`.
|
|
153
|
+
- **`wcs/command-event-argument`** (warning) — `on*: $command.x` wired straight to a command that takes data: `<button data-wcs="onclick: $command.share">` with `<wcs-share data-wcs="command.share: $command.share">`. A token emitted from an event carries the event as its first argument, and the command is called with it: `<wcs-screen-orientation>`'s `lock(event)` and `<wcs-share>`'s `share(event)` end as the browser's TypeError in `error`, `<wcs-credential>`'s `get(event)` resolves `null` without a word. Emit from a state method instead: `onclick: share` with `share() { this.$command.share.emit({ … }) }`. For a built-in tag's command whose method declares parameters. Not for a command with none (`start`, `requestFullscreen`: a button wired straight is the short form), nor for the four that ignore a first argument that is not theirs — `<wcs-fetch>`'s `fetch`, `<wcs-ws>`'s `close`, `<wcs-idle>`'s `start`, `<wcs-notify>`'s `close` — nor for a native element's command.
|
|
154
|
+
- **`wcs/frequency-invalid`** (warning) — a literal `frequency` on `<wcs-accelerometer>`, `<wcs-gyroscope>`, `<wcs-magnetometer>` or `<wcs-ambient-light-sensor>` that is not a positive number: `frequency="60hz"`, `"0"`, `"-5"`. The element reads it as "none", and the sensor runs at the browser's default rate without a word. The message gives the number the value starts with (`frequency="60"`). A bound `frequency:` is not checked.
|
|
155
|
+
- **`wcs/target-selector`** (warning) — a literal `target` written as a bare word on `<wcs-fullscreen>`, `<wcs-pip>`, `<wcs-pointer-lock>`, `<wcs-intersect>` or `<wcs-resize>`, where the document has an element with that id and none with that tag name: `target="viewer"` is a CSS selector for `<viewer>` elements, and `#viewer` was meant. The command then fails with only the element's `error` saying so; the two observers observe nothing.
|
|
156
|
+
- **`wcs/output-path-written`** (warning) — a script assigns `true` to a path bound to an element's output: `this.viewerFs = true` with `<wcs-fullscreen data-wcs="active: viewerFs">`. An output is the element's to write, so nothing becomes fullscreen — and what shows the flag (`class.fullscreen: viewerFs`, a button's label) now says it did. Ask the element with its command. Narrow on purpose: only `= true` (putting a consumed output back to `false` or `null` is normal), and not a path that an input of a custom element or a native two-way binding (`checked: flag`) also takes.
|
|
157
|
+
- **A slot an element's output writes is unknown, not missing.** `picked: null` with `<wcs-contacts data-wcs="value: picked">`, `users: []` with `<wcs-fetch data-wcs="value: users">`, the `value` a spread puts under its path: the slot holds whatever the element gives, so the paths bound under it (`picked.0.name.0`, a row's `.name`) are not checked, and one `wcs/path-dynamic-unknown` info at the key says so. Each used to be a `wcs/binding-path-missing`. A JSDoc `@type` on the key has them checked.
|
|
158
|
+
- **`wcs/input-nested-write`** names the forms to bind instead: an accessor pair, `value#init=element: <getter>`, or one way, `value#ro: <getter>`. A getter with neither a setter nor `#ro` saves, and then has what the element reports written back to it and refused.
|
|
159
|
+
|
|
160
|
+
`--errors-only` prints the wider `wcs/path-readonly` and `wcs/token-undeclared` errors; `--strict` also fails on the four new warnings.
|
|
161
|
+
|
|
162
|
+
## What a TypeScript team is told
|
|
163
|
+
|
|
164
|
+
Since 4.26, from the lending-desk seam app — an equipment-lending desk written by a team that writes TypeScript: a `.ts` state, a generated `stateSchema`, page-defined elements in `.ts` modules, API types in one shared file. Its pages passed this lint with 0 errors and 0 warnings while it had made, among others, a misspelt status in a comparison, a binding to a member a stepper does not have, a getter that tracks only half of what it reads, and three renamed keys the manifest still had; and to get there it had taken the return types off its handlers. What it says now:
|
|
165
|
+
|
|
166
|
+
- **A `.ts` state's return types are read.** `get total(): number {`, `submit(e: Event): void {`, `count(cur: number): void {` in `$watch` — and object types, unions, `Promise<…>`, type parameters, type predicates — no longer hide the member. Up to 4.25 such a member was not read: a getter or a method bound in the page was `wcs/binding-path-missing` (with a `stateSchema`, `wcs/path-nonexistent` — methods are not in the schema), a handler's parameter `cur:` was read as a `$watch` key (`wcs/watch-path-missing "cur"`), and the script rules (`wcs/getter-untracked-read`, `wcs/nested-assign`, `wcs/array-mutation`, …) skipped the typed getters. A body with TypeScript syntax (`x as T`, `y!`, a typed local), a `.ts` module the state imports, and a page's `.ts` modules are read with their types erased, through Node's `module.stripTypeScriptTypes` (Node 22.13 or later; on an older Node they stay unchecked, as before). No package is added: `@wcstack/lint` keeps zero dependencies.
|
|
167
|
+
- **`wcs/tag-member-unknown` reads elements defined in TypeScript.** `<script type="module" src="./main.ts">` and the `.ts` modules it imports (an import of `./x.js` reads `./x.ts` when there is no `.js`; one without an extension, `./x.ts` then `./x.js`): `static wcBindable = { … } as const satisfies Decl` is the literal. Up to 4.25 only `.js` / `.mjs` modules were read, and `maximum:` on a stepper that declares `max` passed — the stepper was never limited.
|
|
168
|
+
- **`wcs/filter-arg-enum`** (warning) — a comparison filter (`eq` / `ne`) whose literal argument the compared value never takes: `class.st-approved: .status|eq('aproved')` where the type is `"pending" | "approved" | "denied"` (a `stateSchema` `enum` / `const` / `anyOf` of consts, a JSDoc literal union — through a `@typedef` or an imported type too). `eq` is never true (`ne` always), and the badge's colour silently never shows. The message names the values and a near one. Only for a filter applied first to the path.
|
|
169
|
+
- **`wcs/filter-input-type` uses the types it has.** A row's path (`.label|toFixed(0)` under `for: rows`) is typed as the row field it expands to — a literal row's, a JSDoc type's, a `stateSchema`'s (a getter's too: `.depositLabel|toFixed(0)` where the schema says string). The date filters (`date`, `time`, `datetime`, `ymd`, `hms`) take a `Date` only, as the runtime does (it throws for anything else but null): `.at|date` on an ISO string is reported. Up to 4.25 only a path written in full with a literal seed was checked.
|
|
170
|
+
- **A JSDoc type from another module is read.** `/** @type {import("./api.ts").Reservation[]} */`, a getter's `@returns {import("./api.ts").Reservation[]}`, a `@typedef {import("./api").Reservation} Reservation`: the type is read from that file — an `interface` or a `type` of a `.ts` / `.d.ts`, a `@typedef` of a `.js` — and the rows bound under it are checked. A type it cannot read (no such file, no such name) leaves the paths under the key unchecked and says so once (`wcs/path-dynamic-unknown`, info) — unknown, not missing. Up to 4.25 each field bound under such a list was a false `wcs/binding-path-missing`.
|
|
171
|
+
- **A getter that falls back to `[]` does not make its rows "missing".** `get pickups() { return this.counter ? this.counter.pickups : []; }` (also `X ?? []`, `X || []`, an early `return []`) where `X`'s shape is not known: the rows are unknown, said once at the getter (`wcs/path-dynamic-unknown`). Up to 4.25 the `[]` made every row field a `wcs/binding-path-missing`. A list whose rows are known (`this.items ?? []`) is checked as before.
|
|
172
|
+
- **`wcs/watch-path-missing` consults the `stateSchema`**, as the bindings do: a key the schema has is not reported, only one it definitely lacks.
|
|
173
|
+
- **`wcs/drift-state-key`** (warning) — the `stateSchema` applied to the page and the page's root state script disagree on the top-level keys: `get displayName()` renamed in the `.ts` while the manifest still says `headerName`. A stale schema wins over the script — the binding left on the old name passed (0 errors, 0 warnings), and a key added since was `wcs/path-nonexistent`. Said once, at the `<wcs-state>` start tag, naming the keys on each side, with `wcs-schema emit` to regenerate it — run `wcs-schema check` before this lint in CI. Only where both sides are known: a root state script read in full (no top-level spread, no computed key, no `$stream` / `$scan`) and the schema's top-level properties; a volume's mount root is not counted.
|
|
174
|
+
- **A schema applies to the pages of its state** — see *Which pages a schema is for* above.
|
|
175
|
+
|
|
176
|
+
`--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
|
+
|
|
146
178
|
## Use in generate–validate–fix loops
|
|
147
179
|
|
|
148
180
|
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.
|