@wcstack/lint 4.24.2 → 4.25.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 +15 -0
- package/README.md +15 -0
- package/dist/cli.cjs +8236 -7390
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -143,6 +143,21 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
|
|
|
143
143
|
|
|
144
144
|
新しい 2 つの error は `--errors-only` にも出ます。新しい warning は `--strict` で失敗します。
|
|
145
145
|
|
|
146
|
+
## 画面とセンサーの要素のページに言うこと
|
|
147
|
+
|
|
148
|
+
4.25 から、継ぎ目アプリ stamp-rally — 画面とセンサーの要素のスタンプラリー: 全画面・画面の向き・傾きとセンサー・共有・連絡先・資格情報・スリープの抑止 — から。作者がわざとした 20 の間違いのどれにも、この lint はそれとして報告しませんでした。いま言うこと:
|
|
149
|
+
|
|
150
|
+
- **`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` で定義する要素が対象です。
|
|
151
|
+
- **`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`)。
|
|
152
|
+
- **`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` — 、ネイティブ要素のコマンドには出しません。
|
|
153
|
+
- **`wcs/frequency-invalid`**(warning) — `<wcs-accelerometer>` / `<wcs-gyroscope>` / `<wcs-magnetometer>` / `<wcs-ambient-light-sensor>` の、正の数値でないリテラルの `frequency`: `frequency="60hz"`・`"0"`・`"-5"`。要素はそれを「指定なし」として読み、センサーはブラウザの既定の頻度で黙って動きます。文面は、値の先頭の数値(`frequency="60"`)を言います。束ねた `frequency:` は検査しません。
|
|
154
|
+
- **`wcs/target-selector`**(warning) — `<wcs-fullscreen>` / `<wcs-pip>` / `<wcs-pointer-lock>` / `<wcs-intersect>` / `<wcs-resize>` の、裸の語で書いたリテラルの `target` で、文書にその id の要素があり、そのタグ名の要素が無いもの: `target="viewer"` は `<viewer>` 要素を選ぶ CSS セレクタで、`#viewer` のつもりです。コマンドは失敗し、それを知らせるのは要素の `error` だけです。監視の 2 つは何も監視しません。
|
|
155
|
+
- **`wcs/output-path-written`**(warning) — 要素の出力に束ねたパスへ、スクリプトが `true` を代入する: `<wcs-fullscreen data-wcs="active: viewerFs">` と `this.viewerFs = true`。出力は要素が書くものなので、全画面にはなりません — そしてその値を表示するもの(`class.fullscreen: viewerFs`・ボタンのラベル)は、そうなったと言います。要素にはコマンドで頼んでください。わざと狭い規則です: `= true` だけ(使い終えた出力を `false` や `null` に戻すのは普通の書き方)で、カスタム要素の入力やネイティブ要素の双方向の束縛(`checked: flag`)にも束ねたパスには言いません。
|
|
156
|
+
- **要素の出力が書くスロットは「分からない」であって「無い」ではありません。** `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` を付ければ検査します。
|
|
157
|
+
- **`wcs/input-nested-write`** は、代わりに束ねる形を言います: アクセサペア(`value#init=element: <getter>`)か、一方向の `value#ro: <getter>`。setter も `#ro` も無い getter は保存はしますが、要素が知らせる値の書き戻しを拒まれます。
|
|
158
|
+
|
|
159
|
+
広がった `wcs/path-readonly` と `wcs/token-undeclared` の error は `--errors-only` にも出ます。新しい 4 つの warning は `--strict` で失敗します。
|
|
160
|
+
|
|
146
161
|
## 生成 → 検証 → 修正ループでの利用
|
|
147
162
|
|
|
148
163
|
安定した 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
|
@@ -143,6 +143,21 @@ Since 4.24, from the town-archive seam app — an archive of 12,000 photos: a lo
|
|
|
143
143
|
|
|
144
144
|
`--errors-only` prints the two new errors; `--strict` also fails on the new warning.
|
|
145
145
|
|
|
146
|
+
## What a page of screen and sensor elements is told
|
|
147
|
+
|
|
148
|
+
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:
|
|
149
|
+
|
|
150
|
+
- **`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`.
|
|
151
|
+
- **`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`.
|
|
152
|
+
- **`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.
|
|
153
|
+
- **`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.
|
|
154
|
+
- **`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.
|
|
155
|
+
- **`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.
|
|
156
|
+
- **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.
|
|
157
|
+
- **`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.
|
|
158
|
+
|
|
159
|
+
`--errors-only` prints the wider `wcs/path-readonly` and `wcs/token-undeclared` errors; `--strict` also fails on the four new warnings.
|
|
160
|
+
|
|
146
161
|
## Use in generate–validate–fix loops
|
|
147
162
|
|
|
148
163
|
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.
|