@wcstack/lint 4.29.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.
- package/README.ja.md +17 -1
- package/README.md +17 -1
- package/dist/cli.cjs +389 -8
- 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
|
|
|
@@ -197,6 +197,22 @@ nothing to check: index.html — no data-wcs binding, <wcs-*> tag or wcstack scr
|
|
|
197
197
|
- 確かなときだけ読みます: オブジェクトリテラルの `state = { … }`(フィールドか、コンストラクタの `this.state = { … }`)で、スプレッドも計算されたキーも無いもの。テンプレートは、モジュールの中の 1 つの文字列。lint が読めないファイル(`--root` なしの `/` から始まるパス)、呼び出しで作る state、見つからないクラスには、これまでどおり何も言いません。
|
|
198
198
|
|
|
199
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
|
+
|
|
200
216
|
## 生成 → 検証 → 修正ループでの利用
|
|
201
217
|
|
|
202
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
|
|
|
@@ -197,6 +197,22 @@ Since 4.29, from the garden-plots seam app — a console assembled from a city's
|
|
|
197
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
198
|
|
|
199
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
|
+
|
|
200
216
|
## Use in generate–validate–fix loops
|
|
201
217
|
|
|
202
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.
|
package/dist/cli.cjs
CHANGED
|
@@ -464,6 +464,28 @@ var WcsDiagnosticCode = {
|
|
|
464
464
|
// ランタイムは何も言わず、後から state に書くと正しいものが選ばれる(継ぎ目アプリ garden-plots の取り込み — 保存した
|
|
465
465
|
// 設定がページを描く前に届くようになって見えた)。値の束縛が前にあるとき・リテラルの `value` だけのときは黙る。warning。
|
|
466
466
|
RadioBeforeValue: "wcs/radio-before-value",
|
|
467
|
+
// --- another framework's habits (service/frameworkHabitsValidator.ts・collectionMutationValidator.ts — 継ぎ目アプリ
|
|
468
|
+
// street-reports: React から移した作者。ランタイムが拒むか黙って落とすものは error、ほかは warning) ---
|
|
469
|
+
// 束縛の右辺(最初の `|` より前)が式(`hidden: !loading`・`textContent: count + 1`・`{{ a ? b : c }}`・
|
|
470
|
+
// `onclick: remove(.id)`)。パスとして引かれ、何も出ない。同じ文字列のパスの検査(binding-path-missing 等)は重ねない。error。
|
|
471
|
+
BindingExpression: "wcs/binding-expression",
|
|
472
|
+
// 束縛属性以外の属性の値の `{{ }}`(`href="/r/{{ id }}"`)。`{{ }}` はテキストでしか読まれず、属性には書いたまま残る。
|
|
473
|
+
// サーバーのテンプレートが埋めるなら正しいので warning。`<wcs-state>` の無いファイルでは言わない。
|
|
474
|
+
AttributeMustache: "wcs/attribute-mustache",
|
|
475
|
+
// `<template>` でない要素の `data-wcs` にある `if:` / `elseif:` / `else:` / `for:`(単独)。ランタイムはその名前の
|
|
476
|
+
// プロパティを書くだけで、要素は常に出て、行は 1 つ。error。
|
|
477
|
+
StructuralElement: "wcs/structural-element",
|
|
478
|
+
// state の `new Set(…)` / `new Map(…)` のキーをその場で変える(`this.selected.add(id)`)。state は見ない。error。
|
|
479
|
+
CollectionMutation: "wcs/collection-mutation",
|
|
480
|
+
// `for:` の行の中の要素のリテラルの `id`(束ねていない)。すべての行が同じ id になる。warning。
|
|
481
|
+
RowIdShared: "wcs/row-id-shared",
|
|
482
|
+
// `onSubmit:` — `on` の直後が大文字のイベント束縛(JSX の綴り)。`Submit` という名前のイベントを聞く。warning。
|
|
483
|
+
EventNameCase: "wcs/event-name-case",
|
|
484
|
+
// インラインの `<wcs-state>` / `<wcs-guard-handler>` のスクリプトの相対・ルート相対の静的 import。blob: URL から
|
|
485
|
+
// 評価されるので解決しない。error。
|
|
486
|
+
InlineImport: "wcs/inline-import",
|
|
487
|
+
// `key:`(React の key)。`key` という名前のプロパティを書くだけ。warning。
|
|
488
|
+
KeyBinding: "wcs/key-binding",
|
|
467
489
|
// 書き戻すときに変換しない双方向の `value:` が、state が数値で持つパス(種・JSDoc の `@type`・stateSchema)を指す。
|
|
468
490
|
// 要素の `value` は文字列なので、5 と入力した後の state は `"5"` で、`count + 1` は `"51"` になる。ランタイムは何も
|
|
469
491
|
// 言わない(ekiden-entry — 弁当 1 個と 2 個が 12 個になった)。数値にする入力フィルタ(`value|number:`)・
|
|
@@ -652,6 +674,9 @@ function didYouMean(input, candidates) {
|
|
|
652
674
|
if (input.length === 0) {
|
|
653
675
|
return "";
|
|
654
676
|
}
|
|
677
|
+
if (/[\s!?=<>+('"`&]/.test(input)) {
|
|
678
|
+
return " An expression is not a path: use a filter (|not, |eq(x), |gt(n)) or a getter.";
|
|
679
|
+
}
|
|
655
680
|
const folded = input.toLowerCase();
|
|
656
681
|
let best = null;
|
|
657
682
|
let bestDistance = 3;
|
|
@@ -2662,7 +2687,7 @@ function getWcsManifest() {
|
|
|
2662
2687
|
}
|
|
2663
2688
|
|
|
2664
2689
|
// ../state/package.json
|
|
2665
|
-
var version = "4.
|
|
2690
|
+
var version = "4.30.0";
|
|
2666
2691
|
|
|
2667
2692
|
// src/service/wcsManifest.ts
|
|
2668
2693
|
var ENGINE_VERSION = version;
|
|
@@ -13343,6 +13368,12 @@ function shortSeed(raw) {
|
|
|
13343
13368
|
return flat.length <= 32 ? flat : `${flat.slice(0, 29)}\u2026`;
|
|
13344
13369
|
}
|
|
13345
13370
|
var MAX_LISTED_KEYS = 10;
|
|
13371
|
+
function collectionFix(key, method, kind) {
|
|
13372
|
+
const k = `this.${key}`;
|
|
13373
|
+
if (method === "clear") return `${k} = new ${kind}()`;
|
|
13374
|
+
if (kind === "Set") return method === "add" ? `${k} = new Set([...${k}, id])` : `${k} = new Set([...${k}].filter((x) => x !== id))`;
|
|
13375
|
+
return method === "set" ? `${k} = new Map([...${k}, [key, value]])` : `${k} = new Map([...${k}].filter(([k]) => k !== key))`;
|
|
13376
|
+
}
|
|
13346
13377
|
function listKeys(keys) {
|
|
13347
13378
|
return keys.length <= MAX_LISTED_KEYS ? keys.join(", ") : `${keys.slice(0, MAX_LISTED_KEYS).join(", ")} \u2026 (+${keys.length - MAX_LISTED_KEYS})`;
|
|
13348
13379
|
}
|
|
@@ -13435,6 +13466,15 @@ var ja = {
|
|
|
13435
13466
|
attrBooleanPresence: (a, p, rhs) => `"attr.${a}" \u306B boolean \u3092\u675F\u306D\u3066\u3044\u307E\u3059\u3002attr.* \u306F String(value) \u3092\u66F8\u304F\u306E\u3067\u3001false \u306E\u3068\u304D ${a}="false" \u306B\u306A\u308A\u307E\u3059\u3002\u8AD6\u7406\u5C5E\u6027\u306F\u5024\u306B\u95A2\u4FC2\u306A\u304F\u3001\u5728\u308B\u3060\u3051\u3067\u52B9\u304D\u307E\u3059: ${a}="false" \u3067\u3082 ${a} \u306E\u307E\u307E\u3067\u3059\uFF08\u5C5E\u6027\u3092\u5916\u3059\u306E\u306F null / undefined \u3060\u3051\uFF09\u3002\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044: ${p}: ${rhs}`,
|
|
13436
13467
|
attrBooleanText: (a, rhs) => `"attr.${a}" \u306B boolean \u3092\u675F\u306D\u3066\u3044\u307E\u3059\u3002attr.* \u306F String(value) \u3092\u66F8\u304F\u306E\u3067\u3001\u5C5E\u6027\u306F "true" \u304B "false" \u306B\u306A\u308A\u3001\u5916\u308C\u308B\u3053\u3068\u306F\u3042\u308A\u307E\u305B\u3093\uFF08\u5916\u3059\u306E\u306F null / undefined \u3060\u3051\uFF09\u3002\u5C5E\u6027\u306E\u6709\u7121\u3092\u898B\u308B\u5074\uFF08CSS \u306E [${a}]\u30FBhasAttribute()\uFF09\u306B\u306F\u3001\u3069\u3061\u3089\u3067\u3082\u5728\u308A\u307E\u3059\u3002false \u306E\u9593\u306F\u5916\u3059\u306A\u3089 attr.${a}: ${rhs}|defaults(null)\u3001\u6587\u5B57\u306E "true" / "false" \u304C\u610F\u56F3\u306A\u3089 attr.${a}: ${rhs}|string \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044`,
|
|
13437
13468
|
radioBeforeValue: (binding, value, checkbox, fix) => `\u300C${binding}:\u300D\u304C\u3001\u3053\u306E${checkbox ? "\u30C1\u30A7\u30C3\u30AF\u30DC\u30C3\u30AF\u30B9" : "\u30E9\u30B8\u30AA"}\u306B\u5024\u3092\u4E0E\u3048\u308B\u300C${value}:\u300D\u3088\u308A\u524D\u306B\u66F8\u304B\u308C\u3066\u3044\u307E\u3059\u3002\u675F\u7E1B\u306F\u66F8\u3044\u305F\u9806\u306B\u5F53\u305F\u308B\u306E\u3067\u3001\u5024\u304C\u307E\u3060\u30D6\u30E9\u30A6\u30B6\u306E\u65E2\u5B9A\u306E "on" \u306E\u3046\u3061\u306B\u6BD4\u3079\u3089\u308C\u3001\u6700\u521D\u306E\u63CF\u753B\u3067\u306F\u4F55\u3082\u30C1\u30A7\u30C3\u30AF\u3055\u308C\u307E\u305B\u3093\uFF08\u4F55\u3082\u77E5\u3089\u305B\u307E\u305B\u3093\u3002\u5F8C\u304B\u3089 state \u306B\u66F8\u304F\u3068\u6B63\u3057\u3044\u3082\u306E\u304C\u30C1\u30A7\u30C3\u30AF\u3055\u308C\u307E\u3059\uFF09\u3002\u5024\u3092\u5148\u306B\u66F8\u3044\u3066\u304F\u3060\u3055\u3044: ${fix}`,
|
|
13469
|
+
bindingExpression: (expression, fix) => `\u675F\u7E1B\u306E\u53F3\u8FBA\u306F\u30D1\u30B9\u3068\u30D5\u30A3\u30EB\u30BF\u3067\u3001\u5F0F\u3067\u306F\u3042\u308A\u307E\u305B\u3093: "${expression}" \u306F\u8A55\u4FA1\u3055\u308C\u305A\u3001\u305D\u306E\u540D\u524D\u306E\u30D1\u30B9\u3068\u3057\u3066\u5F15\u304B\u308C\u307E\u3059\u3002${fix !== null ? `${fix} \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044` : "\u305D\u306E\u5024\u3092\u8A08\u7B97\u3059\u308B getter \u3092 state \u306B\u66F8\u304D\u3001getter \u306E\u540D\u524D\u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044"}`,
|
|
13470
|
+
handlerExpression: (property, expression, method) => `\u30A4\u30D9\u30F3\u30C8\u306E\u675F\u7E1B\u306E\u53F3\u8FBA\u306F\u30E1\u30BD\u30C3\u30C9\u306E\u540D\u524D\u3067\u3001\u547C\u3073\u51FA\u3057\u3084\u95A2\u6570\u3067\u306F\u3042\u308A\u307E\u305B\u3093: "${expression}" \u306F\u8A55\u4FA1\u3055\u308C\u307E\u305B\u3093\u3002${method !== null ? `"${property}: ${method}" \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044` : "\u30E1\u30BD\u30C3\u30C9\u306E\u540D\u524D\u3092\u66F8\u3044\u3066\u304F\u3060\u3055\u3044"}\u3002\u30CF\u30F3\u30C9\u30E9\u306F (event, ...\u30EB\u30FC\u30D7\u306E\u6DFB\u5B57) \u3067\u547C\u3070\u308C\u308B\u306E\u3067\u3001\u884C\u306E\u5024\u306F\u30E1\u30BD\u30C3\u30C9\u306E\u4E2D\u3067\u6DFB\u5B57\u304B\u3089\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044`,
|
|
13471
|
+
attributeMustache: (name) => `{{ }} \u306F\u30C6\u30AD\u30B9\u30C8\u306E\u4E2D\u3067\u3057\u304B\u8AAD\u307E\u308C\u307E\u305B\u3093\u3002\u5C5E\u6027 "${name}" \u306E\u4E2D\u3067\u306F\u66F8\u3044\u305F\u307E\u307E\u6B8B\u308A\u307E\u3059\u3002\u5C5E\u6027\u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08attr.${name}: <\u30D1\u30B9>\u3002\u6587\u5B57\u5217\u3092\u7D44\u307F\u7ACB\u3066\u308B getter \u3092\u66F8\u3044\u3066\uFF09\u3002\u30DA\u30FC\u30B8\u3092\u8FD4\u3059\u524D\u306B\u30B5\u30FC\u30D0\u30FC\u306E\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u304C\u57CB\u3081\u308B\u306E\u306A\u3089\u3001\u3053\u306E\u307E\u307E\u3067\u6B63\u3057\u3044\u66F8\u304D\u65B9\u3067\u3059`,
|
|
13472
|
+
structuralElement: (directive, tagName) => `"${directive}:" \u306F <template> \u306E\u4E0A\u3067\u3060\u3051\u50CD\u304D\u307E\u3059\u3002<${tagName}> \u306E\u4E0A\u3067\u306F\u30E9\u30F3\u30BF\u30A4\u30E0\u306F "${directive}" \u3068\u3044\u3046\u540D\u524D\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u66F8\u304F\u3060\u3051\u3067\u3001${directive === "for" ? "\u8981\u7D20\u306F\u884C\u3054\u3068\u3067\u306F\u306A\u304F 1 \u3064\u3060\u3051\u63CF\u304B\u308C\u307E\u3059" : "\u8981\u7D20\u306F\u5E38\u306B\u8868\u793A\u3055\u308C\u307E\u3059"}\u3002\u8981\u7D20\u3092 <template data-wcs="${directive === "else" ? "else:" : `${directive}: \u2026`}"> \u306E\u4E2D\u306B\u5165\u308C\u3066\u304F\u3060\u3055\u3044`,
|
|
13473
|
+
collectionMutation: (key, method, kind) => `"this.${key}.${method}(\u2026)" \u306F state \u306E ${kind} \u3092\u305D\u306E\u5834\u3067\u5909\u3048\u307E\u3059\u3002state \u306F\u305D\u308C\u3092\u898B\u306A\u3044\u306E\u3067\u3001"${key}" \u306B\u675F\u306D\u305F\u3082\u306E\u3082\u3001\u305D\u308C\u3092\u8AAD\u3080 getter \u3082\u66F4\u65B0\u3055\u308C\u307E\u305B\u3093\uFF08\u4F55\u3082\u77E5\u3089\u305B\u307E\u305B\u3093\uFF09\u3002\u65B0\u3057\u3044 ${kind} \u3092\u4EE3\u5165\u3059\u308B\uFF08${collectionFix(key, method, kind)}\uFF09\u304B\u3001\u914D\u5217 / \u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u6301\u3063\u3066\u304F\u3060\u3055\u3044`,
|
|
13474
|
+
rowIdShared: (id) => `for: \u306E\u3059\u3079\u3066\u306E\u884C\u304C id="${id}" \u306B\u306A\u308A\u307E\u3059\u3002id \u306F 1 \u3064\u306E\u8981\u7D20\u306E\u3082\u306E\u3067\u3001\u305D\u308C\u3092\u540D\u6307\u3059 <label for> \u3084 aria-labelledby \u306F\u6700\u521D\u306E\u884C\u306B\u3057\u304B\u5C4A\u304D\u307E\u305B\u3093\u3002id \u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08attr.id: .domId \u2014 \u884C\u306E\u30AD\u30FC\u304B\u3089\u7D44\u307F\u7ACB\u3066\u308B\u884C\u306E getter \u3092\u66F8\u3044\u3066\uFF09`,
|
|
13475
|
+
eventNameCase: (property, lower2) => `"${property}:" \u306F "${property.slice(2)}" \u3068\u3044\u3046\u540D\u524D\u306E\u30A4\u30D9\u30F3\u30C8\u3092\u805E\u304D\u307E\u3059\u304C\u3001\u305D\u308C\u3092\u9001\u308B\u3082\u306E\u306F\u3042\u308A\u307E\u305B\u3093 \u2014 DOM \u306E\u30A4\u30D9\u30F3\u30C8\u540D\u306F\u5C0F\u6587\u5B57\u3067\u3059\u3002DOM \u306E\u30A4\u30D9\u30F3\u30C8\u306A\u3089 "${lower2}:" \u3068\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\u3002\u90E8\u54C1\u306E\u30B3\u30FC\u30EB\u30D0\u30C3\u30AF\uFF08"prop"\uFF09\u306F\u90E8\u54C1\u304C\u9001\u308B\u30A4\u30D9\u30F3\u30C8\u3067\u3001eventToken.<\u30E1\u30F3\u30D0\u30FC>: \u3067\u675F\u306D\u307E\u3059`,
|
|
13476
|
+
inlineImport: (specifier, guard) => `\u30A4\u30F3\u30E9\u30A4\u30F3\u306E ${guard ? "<wcs-guard-handler>" : "<wcs-state>"} \u306E\u30B9\u30AF\u30EA\u30D7\u30C8\u306F blob: URL \u304B\u3089\u8A55\u4FA1\u3055\u308C\u308B\u306E\u3067\u3001"${specifier}" \u306F\u89E3\u6C7A\u3057\u307E\u305B\u3093\uFF08${guard ? "\u30AC\u30FC\u30C9\u306F" : "state \u306F"}\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3059\uFF09\u3002${guard ? "\u5B8C\u5168\u306A URL \u304B\u3001\u30DA\u30FC\u30B8\u306E import map \u304C\u4E0E\u3048\u308B\u540D\u524D\u3092 import \u3057\u3066\u304F\u3060\u3055\u3044" : '\u5B8C\u5168\u306A URL \u304B\u3001\u30DA\u30FC\u30B8\u306E import map \u304C\u4E0E\u3048\u308B\u540D\u524D\u3092 import \u3059\u308B\u304B\u3001state \u3092\u30D5\u30A1\u30A4\u30EB\u306B\u79FB\u3057\u3066\u304F\u3060\u3055\u3044\uFF08src="./state.js"\uFF09'}`,
|
|
13477
|
+
keyBinding: () => `"key:" \u306F "key" \u3068\u3044\u3046\u540D\u524D\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u66F8\u304F\u3060\u3051\u3067\u3001\u307B\u304B\u306B\u4F55\u3082\u3057\u307E\u305B\u3093\u3002key \u306F\u8981\u308A\u307E\u305B\u3093 \u2014 \u884C\u306F\u884C\u306E\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u7A81\u304D\u5408\u308F\u3055\u308C\u3001\u53D6\u308A\u76F4\u3057\u305F\u30C7\u30FC\u30BF\u3067\u884C\u3092\u4FDD\u3064\u306E\u306F $listKeys \u3067\u3059`,
|
|
13438
13478
|
radioNameShared: (name, binding) => `\u884C\u3054\u3068\u306E\u30E9\u30B8\u30AA\u304C\u3059\u3079\u3066 name="${name}" \u306B\u306A\u308B\u306E\u3067\u3001\u30D6\u30E9\u30A6\u30B6\u306F\u5168\u90E8\u306E\u884C\u306E\u30E9\u30B8\u30AA\u3092 1 \u3064\u306E\u30B0\u30EB\u30FC\u30D7\u306B\u3057\u307E\u3059\u3002\u30DA\u30FC\u30B8\u5168\u4F53\u3067 1 \u3064\u3057\u304B\u9078\u3070\u308C\u305F\u72B6\u614B\u306B\u306A\u3089\u305A\u3001\u8868\u793A\u306F\u6700\u521D\u306E\u63CF\u753B\u304B\u3089\u884C\u3054\u3068\u306E\u5024\u3068\u98DF\u3044\u9055\u3044\u307E\u3059\uFF08\u4F55\u3082\u77E5\u3089\u305B\u307E\u305B\u3093\uFF09\u3002${binding === "radio" ? "\u884C\u3054\u3068\u306B\u9055\u3046 name \u3092\u675F\u306D\u308B\uFF08attr.name: .<\u884C\u3054\u3068\u306B\u9055\u3046\u30D5\u30A3\u30FC\u30EB\u30C9>\uFF09\u304B\u3001name \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\uFF08radio: \u306F name \u304C\u7121\u304F\u3066\u3082\u3001\u540C\u3058\u30D1\u30B9\u306B\u675F\u306D\u305F\u30E9\u30B8\u30AA\u3092\u9078\u629E\u306B\u5408\u308F\u305B\u307E\u3059\uFF09" : "\u884C\u3054\u3068\u306B\u9055\u3046 name \u3092\u675F\u306D\u3066\u304F\u3060\u3055\u3044\uFF08attr.name: .<\u884C\u3054\u3068\u306B\u9055\u3046\u30D5\u30A3\u30FC\u30EB\u30C9>\uFF09\u3002\u884C\u3092\u307E\u305F\u3044\u3067 1 \u3064\u3092\u9078\u3070\u305B\u308B\u306A\u3089\u3001\u5168\u90E8\u3092 1 \u3064\u306E\u30D1\u30B9\u306B\u675F\u306D\u307E\u3059\uFF08value: .<\u884C\u306E id>; radio: <\u30D1\u30B9>\uFF09"}`,
|
|
13439
13479
|
numberWrittenAsString: (path, left, asNumber) => `"${path}" \u306F state \u3067\u306F\u6570\u5024\u3067\u3059\u304C\u3001value: \u304C\u66F8\u304D\u623B\u3059\u306E\u306F\u8981\u7D20\u306E\u6301\u3064\u6587\u5B57\u5217\u3067\u3059\u30025 \u3068\u5165\u529B\u3057\u305F\u5F8C\u306E state \u306F "5" \u3067\u3001"5" + 1 \u306F "51" \u306B\u306A\u308A\u307E\u3059\uFF08\u4F55\u3082\u77E5\u3089\u305B\u307E\u305B\u3093\uFF09\u3002\u66F8\u304D\u623B\u3059\u3068\u304D\u306B\u6570\u5024\u306B\u3057\u3066\u304F\u3060\u3055\u3044: ${asNumber ? `valueAsNumber: ${path}\u3001\u307E\u305F\u306F` : ""}\u5DE6\u8FBA\u306E\u5165\u529B\u30D5\u30A3\u30EB\u30BF ${left}|number: ${path}\uFF08|int\u30FB|float \u3082\uFF09`,
|
|
13440
13480
|
twoWayOutputFilter: (prop, filters, left, rhs, keystroke) => keystroke ? `${prop}: \u306F\u53CC\u65B9\u5411\u3067 1 \u6253\u9375\u3054\u3068\u306B\u66F8\u304D\u623B\u3057\u3001\u51FA\u529B\u30D5\u30A3\u30EB\u30BF "${filters}" \u306F\u305D\u306E\u305F\u3073\u306B state \u306E\u5024\u3092\u6574\u5F62\u3057\u3066\u6B04\u3078\u66F8\u304D\u76F4\u3057\u307E\u3059\u3002\u5165\u529B\u4E2D\u306E\u6B04\u304C\u66F8\u304D\u63DB\u308F\u308A\uFF08\u30AD\u30E3\u30EC\u30C3\u30C8\u306F\u672B\u5C3E\u3078\u98DB\u3073\u3001IME \u306E\u5909\u63DB\u306F\u9014\u5207\u308C\u307E\u3059\uFF09\u3001state \u304C\u53D7\u3051\u53D6\u308B\u306E\u3082\u6B04\u306E\u6574\u5F62\u6E08\u307F\u306E\u6587\u5B57\u3067\u3059\uFF08\u51FA\u529B\u30D5\u30A3\u30EB\u30BF\u306F\u66F8\u304D\u623B\u3057\u3067\u5143\u306B\u623B\u308A\u307E\u305B\u3093\uFF09\u3002\u6574\u5F62\u3057\u305F\u6587\u5B57\u306F\u5225\u306E\u8981\u7D20\u306B\u8868\u793A\u3059\u308B\u3001\u6B04\u306E\u78BA\u5B9A\u3067\u66F8\u304D\u623B\u3057\u3066 setter \u3067\u6574\u5F62\u3059\u308B\uFF08${prop}#onchange:\uFF09\u3001\u307E\u305F\u306F\u4E00\u65B9\u5411\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${prop}#ro: ${rhs}\uFF09` : `${prop}: \u306F\u53CC\u65B9\u5411\u3067\u3059\u304C\u3001\u51FA\u529B\u30D5\u30A3\u30EB\u30BF "${filters}" \u306F\u66F8\u304D\u623B\u3057\u3067\u5143\u306B\u623B\u308A\u307E\u305B\u3093\u3002\u8981\u7D20\u304C\u66F8\u304D\u623B\u3059\u306E\u306F\u8868\u793A\u3057\u3066\u3044\u308B\u6574\u5F62\u6E08\u307F\u306E\u5024\u3067\u3001\u6B21\u306F\u305D\u306E\u5024\u306B\u30D5\u30A3\u30EB\u30BF\u304C\u639B\u304B\u308A\u307E\u3059\u3002\u5DE6\u8FBA\u306E\u5165\u529B\u30D5\u30A3\u30EB\u30BF\u3067\u5143\u306B\u623B\u3059\uFF08${left}|<\u30D5\u30A3\u30EB\u30BF>: \u2026\uFF09\u3001\u6574\u5F62\u3057\u305F\u5024\u306F\u5225\u306E\u8981\u7D20\u306B\u8868\u793A\u3059\u308B\u3001\u307E\u305F\u306F\u4E00\u65B9\u5411\u306B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${prop}#ro: ${rhs}\uFF09`,
|
|
@@ -13726,6 +13766,15 @@ var en = {
|
|
|
13726
13766
|
attrBooleanPresence: (a, p, rhs) => `"attr.${a}" is given a boolean. attr.* writes String(value), so false is written as ${a}="false" \u2014 and a boolean attribute is on whenever it is present, whatever its value: ${a}="false" still means ${a} (only null / undefined remove an attribute). Bind the property instead: ${p}: ${rhs}`,
|
|
13727
13767
|
attrBooleanText: (a, rhs) => `"attr.${a}" is given a boolean. attr.* writes String(value), so the attribute is "true" or "false" and is never removed (only null / undefined remove it): whatever tests its presence \u2014 [${a}] in CSS, hasAttribute() \u2014 finds it either way. To remove it while false, write attr.${a}: ${rhs}|defaults(null); if the text "true" / "false" is what is meant, say so: attr.${a}: ${rhs}|string`,
|
|
13728
13768
|
radioBeforeValue: (binding, value, checkbox, fix) => `"${binding}:" is written before "${value}:", which gives this ${checkbox ? "checkbox" : "radio"} its value. Bindings are applied in the order written, so it is compared while its value is still the browser's default "on": nothing is checked at the first render \u2014 nothing says so, and a later write of the state checks the right one. Write the value first: ${fix}`,
|
|
13769
|
+
bindingExpression: (expression, fix) => `A binding takes a path and filters, not an expression: "${expression}" is not evaluated, it is looked up as a path of that name. ${fix !== null ? `Write ${fix}` : "Write a getter in the state that computes the value, and bind the getter's name"}`,
|
|
13770
|
+
handlerExpression: (property, expression, method) => `An event binding names a method, not a call or a function: "${expression}" is not evaluated. ${method !== null ? `Write "${property}: ${method}"` : "Write the method's name"}; the handler is called with (event, ...loopIndexes), so read the row's values in the method through the loop index`,
|
|
13771
|
+
attributeMustache: (name) => `{{ }} is read in text only: in the attribute "${name}" it stays as written. Bind the attribute (attr.${name}: <path>, with a getter that builds the string) \u2014 a server-side template that fills it before the page is served is fine`,
|
|
13772
|
+
structuralElement: (directive, tagName) => `"${directive}:" works on a <template> only: on <${tagName}> the runtime sets a property named "${directive}" and does nothing else \u2014 ${directive === "for" ? "the element is drawn once, not once per row" : "the element is always shown"}. Put the element inside <template data-wcs="${directive === "else" ? "else:" : `${directive}: \u2026`}">`,
|
|
13773
|
+
collectionMutation: (key, method, kind) => `"this.${key}.${method}(\u2026)" changes the state's ${kind} in place: the state does not see it, so nothing bound to "${key}" and no getter that reads it is updated \u2014 nothing says so. Assign a new ${kind} (${collectionFix(key, method, kind)}), or keep an array / an object`,
|
|
13774
|
+
rowIdShared: (id) => `Every row of the for: gets id="${id}": an id belongs to one element, so a <label for> or aria-labelledby that names it reaches the first row only. Bind it (attr.id: .domId, with a row getter that builds it from the row's key)`,
|
|
13775
|
+
eventNameCase: (property, lower2) => `"${property}:" listens for an event named "${property.slice(2)}", which nothing dispatches \u2014 DOM event names are lower case. Write "${lower2}:" for the DOM event; a callback "prop" of a part is an event the part dispatches, bound with eventToken.<member>:`,
|
|
13776
|
+
inlineImport: (specifier, guard) => `An inline ${guard ? "<wcs-guard-handler>" : "<wcs-state>"} script is evaluated from a blob: URL, against which "${specifier}" does not resolve: the ${guard ? "guard" : "state"} fails to load. Import a full URL or a name the page's import map gives${guard ? "" : ', or move the state into a file (src="./state.js")'}`,
|
|
13777
|
+
keyBinding: () => `"key:" sets a property named "key" and does nothing else. No key is needed: rows are matched by the row object, and $listKeys keeps rows across refetched data`,
|
|
13729
13778
|
radioNameShared: (name, binding) => `Every row's radios get name="${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 \u2014 nothing says so. ${binding === "radio" ? "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" : "Bind a name that differs per row (attr.name: .<a row field>) \u2014 or, for one choice over all the rows, bind them all to one path: value: .<the row's id>; radio: <path>"}`,
|
|
13730
13779
|
numberWrittenAsString: (path, left, asNumber) => `"${path}" is a number in the state, but value: writes back what the element holds, a string: after the user enters 5 the state has "5", and "5" + 1 is "51" \u2014 nothing says so. Convert it on the way in: ${asNumber ? `valueAsNumber: ${path}, or ` : ""}an input filter on the left side, ${left}|number: ${path} (also |int, |float)`,
|
|
13731
13780
|
twoWayOutputFilter: (prop, filters, left, rhs, keystroke) => keystroke ? `${prop}: is two-way and writes back on every keystroke, and the output filter "${filters}" formats what the state holds each time: the field is rewritten while the user types \u2014 the caret jumps to the end, an IME composition is cut \u2014 and what the state receives is the field's formatted text (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 (${prop}#onchange:), or make the binding one-way: ${prop}#ro: ${rhs}` : `${prop}: is two-way, and nothing undoes the output filter "${filters}" on the way back: the element writes back the formatted value it shows, and the filter is then applied to that. Undo it with an input filter on the left side (${left}|<filter>: \u2026), show the formatted value in another element, or make the binding one-way: ${prop}#ro: ${rhs}`,
|
|
@@ -21525,7 +21574,8 @@ function validateScriptReads(html, stateTagName = "wcs-state", locale2, fileRead
|
|
|
21525
21574
|
start: block.contentStart + spread.start,
|
|
21526
21575
|
end: block.contentStart + spread.end,
|
|
21527
21576
|
message: msgs.pathDynamicUnknownSpread(block.content.slice(spread.start, spread.end)),
|
|
21528
|
-
severity: "info"
|
|
21577
|
+
severity: "info",
|
|
21578
|
+
wholeState: true
|
|
21529
21579
|
});
|
|
21530
21580
|
}
|
|
21531
21581
|
const prefix = block.mountPath === null || block.mountPath === "" ? "" : `${block.mountPath}.`;
|
|
@@ -21887,8 +21937,320 @@ function describe(callable) {
|
|
|
21887
21937
|
return callable.listed?.key ?? callable.name;
|
|
21888
21938
|
}
|
|
21889
21939
|
|
|
21890
|
-
// src/service/
|
|
21940
|
+
// src/service/frameworkHabitsValidator.ts
|
|
21941
|
+
var EXPRESSION_CHARACTER = /[\s!?=<>+()'"`&,]/;
|
|
21942
|
+
var PATH = /^(?:\.|\.?[^\s!?=<>+()'"`&,|.@][^\s!?=<>+()'"`&,|@]*)$/;
|
|
21943
|
+
var NUMBER2 = /^-?\d+(?:\.\d+)?$/;
|
|
21944
|
+
function isBindingExpression(path) {
|
|
21945
|
+
if (path === "" || path.includes("@")) return false;
|
|
21946
|
+
return EXPRESSION_CHARACTER.test(path);
|
|
21947
|
+
}
|
|
21948
|
+
function filterHint(expression) {
|
|
21949
|
+
const text3 = expression.trim();
|
|
21950
|
+
const not3 = /^!\s*(\S+)$/.exec(text3);
|
|
21951
|
+
if (not3 !== null && PATH.test(not3[1])) return `${not3[1]}|not`;
|
|
21952
|
+
const binary = /^(\S+)\s*(===|!==|==|!=|>=|<=|>|<|\+|-|\*|\/|%)\s*(\S+)$/.exec(text3);
|
|
21953
|
+
if (binary === null || !PATH.test(binary[1])) return null;
|
|
21954
|
+
const [, path, op, raw] = binary;
|
|
21955
|
+
const quoted = /^(['"])(.*)\1$/.exec(raw);
|
|
21956
|
+
const value = quoted !== null ? quoted[2] : raw;
|
|
21957
|
+
const isNumber = quoted === null && NUMBER2.test(raw);
|
|
21958
|
+
if (quoted === null && !isNumber && !["true", "false", "null"].includes(raw)) return null;
|
|
21959
|
+
if (/[,()|]/.test(value)) return null;
|
|
21960
|
+
const name = {
|
|
21961
|
+
"===": "eq",
|
|
21962
|
+
"==": "eq",
|
|
21963
|
+
"!==": "ne",
|
|
21964
|
+
"!=": "ne",
|
|
21965
|
+
">": "gt",
|
|
21966
|
+
">=": "ge",
|
|
21967
|
+
"<": "lt",
|
|
21968
|
+
"<=": "le",
|
|
21969
|
+
"+": "add",
|
|
21970
|
+
"-": "sub",
|
|
21971
|
+
"*": "mul",
|
|
21972
|
+
"/": "div",
|
|
21973
|
+
"%": "mod"
|
|
21974
|
+
}[op];
|
|
21975
|
+
if (name !== "eq" && name !== "ne" && !isNumber) return null;
|
|
21976
|
+
return `${path}|${name}(${value})`;
|
|
21977
|
+
}
|
|
21978
|
+
function calledMethod(expression) {
|
|
21979
|
+
const arrow = expression.indexOf("=>");
|
|
21980
|
+
const body = arrow === -1 ? expression : expression.slice(arrow + 2);
|
|
21981
|
+
const call = /^\s*\{?\s*(?:this\s*\.\s*)?([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\(/.exec(body);
|
|
21982
|
+
return call === null ? null : call[1];
|
|
21983
|
+
}
|
|
21984
|
+
function propertyOf(left) {
|
|
21985
|
+
return (splitOutsideQuotes2(left, "|")[0] ?? "").replace(/#.*$/, "").trim();
|
|
21986
|
+
}
|
|
21987
|
+
function validateBindingExpressions(html, bindAttribute = "data-wcs", stateTagName = "wcs-state", locale2) {
|
|
21988
|
+
const msgs = getMessages(locale2);
|
|
21989
|
+
const out = [];
|
|
21990
|
+
if (html.includes(bindAttribute)) {
|
|
21991
|
+
for (const attr of findAllBindAttributes(html, bindAttribute)) {
|
|
21992
|
+
let pos = 0;
|
|
21993
|
+
for (const binding of splitBindingExpressions(attr.value)) {
|
|
21994
|
+
const bindingStart = attr.valueStart + pos;
|
|
21995
|
+
pos += binding.length + 1;
|
|
21996
|
+
const colon = indexOfOutsideQuotes2(binding, ":");
|
|
21997
|
+
if (colon === -1) continue;
|
|
21998
|
+
const property = propertyOf(binding.slice(0, colon));
|
|
21999
|
+
if (property === "else") continue;
|
|
22000
|
+
const site = expressionIn(binding, colon + 1);
|
|
22001
|
+
if (site === null) continue;
|
|
22002
|
+
const handler = property.startsWith("on");
|
|
22003
|
+
out.push({
|
|
22004
|
+
code: WcsDiagnosticCode.BindingExpression,
|
|
22005
|
+
start: bindingStart + site.start,
|
|
22006
|
+
end: bindingStart + site.end,
|
|
22007
|
+
message: handler ? msgs.handlerExpression(property, site.text, calledMethod(site.text)) : msgs.bindingExpression(site.text, filterHint(site.text)),
|
|
22008
|
+
severity: "error"
|
|
22009
|
+
});
|
|
22010
|
+
}
|
|
22011
|
+
}
|
|
22012
|
+
}
|
|
22013
|
+
if ((html.includes("{{") || html.includes("@@")) && parseWcsStateElements(html, stateTagName).length > 0) {
|
|
22014
|
+
const texts = [...findAllMustacheSyntax(html).filter((m) => !m.inDocumentHead), ...findAllCommentBindings(html).filter((m) => !m.inDocumentHead)];
|
|
22015
|
+
for (const m of texts) {
|
|
22016
|
+
const site = expressionIn(m.expression, 0);
|
|
22017
|
+
if (site === null) continue;
|
|
22018
|
+
out.push({
|
|
22019
|
+
code: WcsDiagnosticCode.BindingExpression,
|
|
22020
|
+
start: m.exprStart + site.start,
|
|
22021
|
+
end: m.exprStart + site.end,
|
|
22022
|
+
message: msgs.bindingExpression(site.text, filterHint(site.text)),
|
|
22023
|
+
severity: "error"
|
|
22024
|
+
});
|
|
22025
|
+
}
|
|
22026
|
+
}
|
|
22027
|
+
return out;
|
|
22028
|
+
}
|
|
22029
|
+
function expressionIn(text3, from) {
|
|
22030
|
+
const rhs = text3.slice(from);
|
|
22031
|
+
const segments = splitOutsideQuotes2(rhs, "|");
|
|
22032
|
+
if (segments.slice(1).some((s) => s.trim() === "")) return null;
|
|
22033
|
+
const raw = segments[0] ?? "";
|
|
22034
|
+
const path = raw.trim();
|
|
22035
|
+
if (!isBindingExpression(path)) return null;
|
|
22036
|
+
const start = from + raw.indexOf(path);
|
|
22037
|
+
return { start, end: start + path.length, text: path };
|
|
22038
|
+
}
|
|
22039
|
+
function writtenAttributes2(html, from, to) {
|
|
22040
|
+
const out = [];
|
|
22041
|
+
const attribute = /([^\s"'<>/=]+)(?:(\s*=\s*)(?:"([^"]*)"|'([^']*)'|([^\s"'<>`=]+)))?/g;
|
|
22042
|
+
const text3 = html.slice(from, to);
|
|
22043
|
+
let match;
|
|
22044
|
+
while ((match = attribute.exec(text3)) !== null) {
|
|
22045
|
+
const value = match[3] ?? match[4] ?? match[5] ?? null;
|
|
22046
|
+
const quoted = match[3] !== void 0 || match[4] !== void 0 ? 1 : 0;
|
|
22047
|
+
out.push({
|
|
22048
|
+
name: match[1].toLowerCase(),
|
|
22049
|
+
value,
|
|
22050
|
+
start: from + match.index,
|
|
22051
|
+
end: from + match.index + match[0].length,
|
|
22052
|
+
valueStart: from + match.index + match[1].length + (match[2]?.length ?? 0) + quoted
|
|
22053
|
+
});
|
|
22054
|
+
}
|
|
22055
|
+
return out;
|
|
22056
|
+
}
|
|
22057
|
+
function validateAttributeMustaches(html, bindAttribute = "data-wcs", stateTagName = "wcs-state", locale2, fileReader) {
|
|
22058
|
+
if (!html.includes("{{")) return [];
|
|
22059
|
+
if (parseWcsStateElements(html, stateTagName).length === 0) return [];
|
|
22060
|
+
if (isMustacheDisabled(html, stateTagName, fileReader)) return [];
|
|
22061
|
+
const msgs = getMessages(locale2);
|
|
22062
|
+
const bind = bindAttribute.toLowerCase();
|
|
22063
|
+
const out = [];
|
|
22064
|
+
for (const tag of findStartTagRegions(html)) {
|
|
22065
|
+
if (!html.slice(tag.start, tag.end).includes("{{")) continue;
|
|
22066
|
+
for (const a of writtenAttributes2(html, tag.start, tag.end)) {
|
|
22067
|
+
if (a.value === null || a.name === bind) continue;
|
|
22068
|
+
const open = a.value.indexOf("{{");
|
|
22069
|
+
if (open === -1) continue;
|
|
22070
|
+
const close = a.value.indexOf("}}", open + 2);
|
|
22071
|
+
if (close === -1) continue;
|
|
22072
|
+
out.push({
|
|
22073
|
+
code: WcsDiagnosticCode.AttributeMustache,
|
|
22074
|
+
start: a.valueStart + open,
|
|
22075
|
+
end: a.valueStart + close + 2,
|
|
22076
|
+
message: msgs.attributeMustache(a.name),
|
|
22077
|
+
severity: "warning"
|
|
22078
|
+
});
|
|
22079
|
+
}
|
|
22080
|
+
}
|
|
22081
|
+
return out;
|
|
22082
|
+
}
|
|
22083
|
+
function validateMarkupHabits(html, bindAttribute = "data-wcs", locale2) {
|
|
22084
|
+
const msgs = getMessages(locale2);
|
|
22085
|
+
const out = [];
|
|
22086
|
+
const boundId = /* @__PURE__ */ new Set();
|
|
22087
|
+
if (html.includes(bindAttribute)) {
|
|
22088
|
+
for (const attr of findAllBindAttributes(html, bindAttribute)) {
|
|
22089
|
+
const bindings = splitBindingExpressions(attr.value);
|
|
22090
|
+
const nonEmpty = bindings.filter((b) => b.trim() !== "").length;
|
|
22091
|
+
let pos = 0;
|
|
22092
|
+
for (const binding of bindings) {
|
|
22093
|
+
const bindingStart = attr.valueStart + pos;
|
|
22094
|
+
pos += binding.length + 1;
|
|
22095
|
+
if (binding.trim() === "") continue;
|
|
22096
|
+
const colon = indexOfOutsideQuotes2(binding, ":");
|
|
22097
|
+
const rawLeft = colon === -1 ? binding : binding.slice(0, colon);
|
|
22098
|
+
const exact = rawLeft.trim();
|
|
22099
|
+
const leftStart = bindingStart + (rawLeft.length - rawLeft.trimStart().length);
|
|
22100
|
+
const property = propertyOf(rawLeft);
|
|
22101
|
+
if (property === "id" || property === "attr.id" || property === ".id" || property === "...") {
|
|
22102
|
+
if (attr.attrsStart !== void 0) boundId.add(attr.attrsStart);
|
|
22103
|
+
}
|
|
22104
|
+
if (STRUCTURAL_BINDING_TYPE_SET2.has(exact) && nonEmpty === 1 && attr.tagName !== "template") {
|
|
22105
|
+
out.push({
|
|
22106
|
+
code: WcsDiagnosticCode.StructuralElement,
|
|
22107
|
+
start: leftStart,
|
|
22108
|
+
end: leftStart + exact.length,
|
|
22109
|
+
message: msgs.structuralElement(exact, attr.tagName ?? ""),
|
|
22110
|
+
severity: "error"
|
|
22111
|
+
});
|
|
22112
|
+
continue;
|
|
22113
|
+
}
|
|
22114
|
+
if (/^on[A-Z]/.test(property)) {
|
|
22115
|
+
out.push({
|
|
22116
|
+
code: WcsDiagnosticCode.EventNameCase,
|
|
22117
|
+
start: leftStart,
|
|
22118
|
+
end: leftStart + property.length,
|
|
22119
|
+
message: msgs.eventNameCase(property, `on${property.slice(2).toLowerCase()}`),
|
|
22120
|
+
severity: "warning"
|
|
22121
|
+
});
|
|
22122
|
+
} else if (property === "key" && attr.tagName !== void 0 && !attr.tagName.includes("-")) {
|
|
22123
|
+
out.push({
|
|
22124
|
+
code: WcsDiagnosticCode.KeyBinding,
|
|
22125
|
+
start: leftStart,
|
|
22126
|
+
end: leftStart + property.length,
|
|
22127
|
+
message: msgs.keyBinding(),
|
|
22128
|
+
severity: "warning"
|
|
22129
|
+
});
|
|
22130
|
+
}
|
|
22131
|
+
}
|
|
22132
|
+
}
|
|
22133
|
+
}
|
|
22134
|
+
out.push(...sharedRowIds(html, bindAttribute, boundId, msgs));
|
|
22135
|
+
return out;
|
|
22136
|
+
}
|
|
22137
|
+
function sharedRowIds(html, bindAttribute, boundId, msgs) {
|
|
22138
|
+
if (!/<template[^>]*for\s*:/i.test(html)) return [];
|
|
22139
|
+
const out = [];
|
|
22140
|
+
const said = /* @__PURE__ */ new Set();
|
|
22141
|
+
const chainAt = createTemplateChain(html);
|
|
22142
|
+
for (const tag of findStartTagRegions(html)) {
|
|
22143
|
+
if (boundId.has(tag.start)) continue;
|
|
22144
|
+
const id = writtenAttributes2(html, tag.start, tag.end).find((a) => a.name === "id");
|
|
22145
|
+
if (id === void 0 || id.value === null || id.value.trim() === "") continue;
|
|
22146
|
+
const fors = getEnclosingFors(html, tag.start, bindAttribute);
|
|
22147
|
+
if (fors.length === 0) continue;
|
|
22148
|
+
const loop = fors[fors.length - 1];
|
|
22149
|
+
const chain = chainAt(tag.start);
|
|
22150
|
+
if (chain[chain.length - 1] !== loop.anchor) continue;
|
|
22151
|
+
const key = `${loop.anchor}\0${id.value}`;
|
|
22152
|
+
if (said.has(key)) continue;
|
|
22153
|
+
said.add(key);
|
|
22154
|
+
out.push({
|
|
22155
|
+
code: WcsDiagnosticCode.RowIdShared,
|
|
22156
|
+
start: id.start,
|
|
22157
|
+
end: id.end,
|
|
22158
|
+
message: msgs.rowIdShared(id.value),
|
|
22159
|
+
severity: "warning"
|
|
22160
|
+
});
|
|
22161
|
+
}
|
|
22162
|
+
return out;
|
|
22163
|
+
}
|
|
21891
22164
|
var GUARD_TAG = "wcs-guard-handler";
|
|
22165
|
+
var RELATIVE_SPECIFIER = /^(?:\.{1,2}\/|\/(?!\/))/;
|
|
22166
|
+
function validateInlineImports(html, stateTagName = "wcs-state", locale2) {
|
|
22167
|
+
if (!/\bimport\b|\bexport\b/.test(html)) return [];
|
|
22168
|
+
const msgs = getMessages(locale2);
|
|
22169
|
+
const out = [];
|
|
22170
|
+
const check = (blocks, guard) => {
|
|
22171
|
+
for (const block of blocks) {
|
|
22172
|
+
if (block.modulePath !== void 0) continue;
|
|
22173
|
+
for (const s of relativeImports(block.content)) {
|
|
22174
|
+
out.push({
|
|
22175
|
+
code: WcsDiagnosticCode.InlineImport,
|
|
22176
|
+
start: block.contentStart + s.start,
|
|
22177
|
+
end: block.contentStart + s.end,
|
|
22178
|
+
message: msgs.inlineImport(s.specifier, guard),
|
|
22179
|
+
severity: "error"
|
|
22180
|
+
});
|
|
22181
|
+
}
|
|
22182
|
+
}
|
|
22183
|
+
};
|
|
22184
|
+
if (html.includes(GUARD_TAG)) check(parseWcsScriptBlocks(html, GUARD_TAG), true);
|
|
22185
|
+
check(parseLoadedScriptBlocks(html, stateTagName), false);
|
|
22186
|
+
return out;
|
|
22187
|
+
}
|
|
22188
|
+
function relativeImports(source) {
|
|
22189
|
+
if (!/\b(?:import|export)\b/.test(source)) return [];
|
|
22190
|
+
let program;
|
|
22191
|
+
try {
|
|
22192
|
+
program = parseErasingTypes(source, { ecmaVersion: "latest", sourceType: "module", allowHashBang: true });
|
|
22193
|
+
} catch {
|
|
22194
|
+
return [];
|
|
22195
|
+
}
|
|
22196
|
+
const out = [];
|
|
22197
|
+
for (const node of program.body) {
|
|
22198
|
+
if (node.type !== "ImportDeclaration" && node.type !== "ExportAllDeclaration" && node.type !== "ExportNamedDeclaration") continue;
|
|
22199
|
+
const src = node.source;
|
|
22200
|
+
if (src === void 0 || src === null || src.type !== "Literal" || typeof src.value !== "string") continue;
|
|
22201
|
+
if (!RELATIVE_SPECIFIER.test(src.value)) continue;
|
|
22202
|
+
out.push({ specifier: src.value, start: src.start, end: src.end });
|
|
22203
|
+
}
|
|
22204
|
+
return out;
|
|
22205
|
+
}
|
|
22206
|
+
|
|
22207
|
+
// src/service/collectionMutationValidator.ts
|
|
22208
|
+
var METHODS = {
|
|
22209
|
+
Set: /* @__PURE__ */ new Set(["add", "delete", "clear"]),
|
|
22210
|
+
Map: /* @__PURE__ */ new Set(["set", "delete", "clear"])
|
|
22211
|
+
};
|
|
22212
|
+
var CALL = String.raw`\bthis\s*\??\.\s*(${ID})\s*\??\.\s*(add|set|delete|clear)(?=\s*\()`;
|
|
22213
|
+
function validateCollectionMutations(html, stateTagName = "wcs-state", locale2) {
|
|
22214
|
+
const msgs = getMessages(locale2);
|
|
22215
|
+
const out = [];
|
|
22216
|
+
for (const block of parseLoadedScriptBlocks(html, stateTagName)) {
|
|
22217
|
+
const script = block.content;
|
|
22218
|
+
if (!/new\s+(?:Set|Map)\b/.test(script)) continue;
|
|
22219
|
+
const kinds = /* @__PURE__ */ new Map();
|
|
22220
|
+
const kindOf = (key) => {
|
|
22221
|
+
if (!kinds.has(key)) {
|
|
22222
|
+
const declaration = findTopLevelDeclaration(script, key);
|
|
22223
|
+
const seed = declaration?.kind === "data" ? /^new\s+(Set|Map)\s*\(/.exec(declaration.value ?? "") : null;
|
|
22224
|
+
kinds.set(key, seed === null ? null : seed[1]);
|
|
22225
|
+
}
|
|
22226
|
+
return kinds.get(key);
|
|
22227
|
+
};
|
|
22228
|
+
let bodies = null;
|
|
22229
|
+
for (const match of execAllMasked(CALL, script)) {
|
|
22230
|
+
const [key, method] = match.groups;
|
|
22231
|
+
if (key === void 0 || method === void 0 || isApiRoot(key)) continue;
|
|
22232
|
+
const kind = kindOf(key);
|
|
22233
|
+
if (kind === null || !METHODS[kind].has(method)) continue;
|
|
22234
|
+
bodies ??= analyzeCallableBodies(script);
|
|
22235
|
+
const body = bodies.find((b) => match.index >= b.bodyStart && match.index < b.bodyStart + b.body.length);
|
|
22236
|
+
const scope = body === void 0 ? script : body.body;
|
|
22237
|
+
if (new RegExp(String.raw`\bthis\s*\??\.\s*${key}\s*=(?!=)`).test(maskCommentsAndStrings(scope))) continue;
|
|
22238
|
+
const start = block.contentStart + match.index;
|
|
22239
|
+
out.push({
|
|
22240
|
+
code: WcsDiagnosticCode.CollectionMutation,
|
|
22241
|
+
start,
|
|
22242
|
+
end: start + match.length,
|
|
22243
|
+
message: msgs.collectionMutation(key, method, kind),
|
|
22244
|
+
severity: "error",
|
|
22245
|
+
statePath: key
|
|
22246
|
+
});
|
|
22247
|
+
}
|
|
22248
|
+
}
|
|
22249
|
+
return out;
|
|
22250
|
+
}
|
|
22251
|
+
|
|
22252
|
+
// src/service/moduleTopReadValidator.ts
|
|
22253
|
+
var GUARD_TAG2 = "wcs-guard-handler";
|
|
21892
22254
|
var STORAGES = /* @__PURE__ */ new Set(["localStorage", "sessionStorage"]);
|
|
21893
22255
|
var GLOBALS = /* @__PURE__ */ new Set(["window", "globalThis", "self"]);
|
|
21894
22256
|
var STORAGE_WRITES = /* @__PURE__ */ new Set(["setItem", "removeItem", "clear"]);
|
|
@@ -21908,7 +22270,7 @@ function validateModuleTopReads(html, stateTagName = "wcs-state", locale2) {
|
|
|
21908
22270
|
}
|
|
21909
22271
|
}
|
|
21910
22272
|
};
|
|
21911
|
-
if (html.includes(
|
|
22273
|
+
if (html.includes(GUARD_TAG2)) check(parseWcsScriptBlocks(html, GUARD_TAG2), true);
|
|
21912
22274
|
check(parseLoadedScriptBlocks(html, stateTagName), false);
|
|
21913
22275
|
return out;
|
|
21914
22276
|
}
|
|
@@ -22008,7 +22370,8 @@ function validateStateSources(html, stateTagName = "wcs-state", locale2, fileRea
|
|
|
22008
22370
|
start: span.start,
|
|
22009
22371
|
end: span.end,
|
|
22010
22372
|
message: getMessages(locale2).stateSrcUnread(src),
|
|
22011
|
-
severity: "info"
|
|
22373
|
+
severity: "info",
|
|
22374
|
+
wholeState: true
|
|
22012
22375
|
});
|
|
22013
22376
|
}
|
|
22014
22377
|
return out;
|
|
@@ -22945,6 +23308,7 @@ function validateText(text3, options, applicationSchema, env) {
|
|
|
22945
23308
|
out.push(...validateOutputPathWrites(text3, bindAttribute, stateTagName, locale2, fileReader));
|
|
22946
23309
|
out.push(...validateAccessorLists(text3, stateTagName, locale2));
|
|
22947
23310
|
out.push(...validateArrayMutations(text3, stateTagName, locale2));
|
|
23311
|
+
out.push(...validateCollectionMutations(text3, stateTagName, locale2));
|
|
22948
23312
|
out.push(...validateModuleTopReads(text3, stateTagName, locale2));
|
|
22949
23313
|
out.push(...validateWatchDeclarations(text3, stateTagName, locale2, fileReader, bindAttribute, applicationSchema));
|
|
22950
23314
|
out.push(...validateScanDeclarations(text3, stateTagName, locale2));
|
|
@@ -22959,6 +23323,16 @@ function validateText(text3, options, applicationSchema, env) {
|
|
|
22959
23323
|
for (const d of validateNestedAssigns(text3, stateTagName, locale2)) {
|
|
22960
23324
|
out.push({ code: WcsDiagnosticCode.NestedAssign, start: d.start, end: d.end, message: d.message, severity: d.severity });
|
|
22961
23325
|
}
|
|
23326
|
+
out.push(...validateAttributeMustaches(text3, bindAttribute, stateTagName, locale2, fileReader));
|
|
23327
|
+
out.push(...validateMarkupHabits(text3, bindAttribute, locale2));
|
|
23328
|
+
out.push(...validateInlineImports(text3, stateTagName, locale2));
|
|
23329
|
+
const expressions = validateBindingExpressions(text3, bindAttribute, stateTagName, locale2);
|
|
23330
|
+
if (expressions.length > 0) {
|
|
23331
|
+
const inExpression = (d) => d.code !== WcsDiagnosticCode.BindingExpression && expressions.some((e) => d.start >= e.start && d.end <= e.end);
|
|
23332
|
+
const kept2 = out.filter((d) => !inExpression(d));
|
|
23333
|
+
out.length = 0;
|
|
23334
|
+
out.push(...kept2, ...expressions);
|
|
23335
|
+
}
|
|
22962
23336
|
const ignored = [
|
|
22963
23337
|
...findIgnoredRanges(text3, bindAttribute),
|
|
22964
23338
|
...text3.includes("{{") && isMustacheDisabled(text3, stateTagName, fileReader) ? findAllMustacheSyntax(text3).map((m) => [m.matchStart, m.matchEnd]) : []
|
|
@@ -23181,6 +23555,7 @@ function runValidation(inputs, options = {}) {
|
|
|
23181
23555
|
let errorCount = 0;
|
|
23182
23556
|
let warningCount = 0;
|
|
23183
23557
|
let infoCount = 0;
|
|
23558
|
+
let uncheckedCount = 0;
|
|
23184
23559
|
for (const source of [...diagnosticsBySource.keys()].sort()) {
|
|
23185
23560
|
const diags = diagnosticsBySource.get(source);
|
|
23186
23561
|
const mapper = createPositionMapper(textBySource.get(source) ?? "");
|
|
@@ -23188,7 +23563,9 @@ function runValidation(inputs, options = {}) {
|
|
|
23188
23563
|
if (d.severity === "error") errorCount++;
|
|
23189
23564
|
else if (d.severity === "warning") warningCount++;
|
|
23190
23565
|
else infoCount++;
|
|
23191
|
-
|
|
23566
|
+
const unchecked = d.severity === "info" && d.wholeState === true;
|
|
23567
|
+
if (unchecked) uncheckedCount++;
|
|
23568
|
+
if (options.errorsOnly && d.severity !== "error" && !(options.strict === true && unchecked)) continue;
|
|
23192
23569
|
const pos = mapper(d.start);
|
|
23193
23570
|
lines.push(`${source}:${pos.line}:${pos.column} ${severityLabel[d.severity]} ${d.code} ${d.message}`);
|
|
23194
23571
|
}
|
|
@@ -23198,6 +23575,9 @@ function runValidation(inputs, options = {}) {
|
|
|
23198
23575
|
if (notRead.length > 0) {
|
|
23199
23576
|
notes.push(`not read: ${notRead.join(", ")} \u2014 wcs-validate reads HTML pages (data-wcs, <wcs-*> tags), not a framework's components or script files`);
|
|
23200
23577
|
}
|
|
23578
|
+
if (options.strict === true && uncheckedCount > 0) {
|
|
23579
|
+
notes.push(`strict: ${uncheckedCount} info about a state that was not read at all (an unread src, a spread at the top of the state) counted like warnings \u2014 give --root, or a stateSchema, to have it checked`);
|
|
23580
|
+
}
|
|
23201
23581
|
if (nothingToCheck.length > 0) {
|
|
23202
23582
|
notes.push(`nothing to check: ${nothingToCheck.join(", ")} \u2014 no data-wcs binding, <wcs-*> tag or wcstack script in them`);
|
|
23203
23583
|
}
|
|
@@ -23206,7 +23586,8 @@ function runValidation(inputs, options = {}) {
|
|
|
23206
23586
|
errorCount,
|
|
23207
23587
|
warningCount,
|
|
23208
23588
|
infoCount,
|
|
23209
|
-
|
|
23589
|
+
uncheckedCount,
|
|
23590
|
+
exitCode: errorCount > 0 || options.strict === true && (warningCount > 0 || uncheckedCount > 0) ? 1 : 0,
|
|
23210
23591
|
diagnosticsBySource,
|
|
23211
23592
|
notRead,
|
|
23212
23593
|
nothingToCheck,
|
|
@@ -23315,7 +23696,7 @@ function main(argv) {
|
|
|
23315
23696
|
}
|
|
23316
23697
|
process.stdout.write(
|
|
23317
23698
|
`
|
|
23318
|
-
${result.errorCount} error(s), ${result.warningCount} warning(s), ${result.infoCount} info${options.strict ?
|
|
23699
|
+
${result.errorCount} error(s), ${result.warningCount} warning(s), ${result.infoCount} info${options.strict ? ` (strict${result.uncheckedCount > 0 ? `; ${result.uncheckedCount} unchecked counted as warnings` : ""})` : ""}
|
|
23319
23700
|
`
|
|
23320
23701
|
);
|
|
23321
23702
|
for (const note of result.notes) process.stdout.write(note + "\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/lint",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.30.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": {
|