@markuplint/svelte-spec 5.0.0-rc.2 → 5.0.0-rc.5

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/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.0.0-rc.5](https://github.com/markuplint/markuplint/compare/v5.0.0-rc.4...v5.0.0-rc.5) (2026-08-28)
7
+
8
+ **Note:** Version bump only for package @markuplint/svelte-spec
9
+
10
+ # [5.0.0-rc.4](https://github.com/markuplint/markuplint/compare/v5.0.0-rc.3...v5.0.0-rc.4) (2026-04-19)
11
+
12
+ **Note:** Version bump only for package @markuplint/svelte-spec
13
+
14
+ # [5.0.0-rc.3](https://github.com/markuplint/markuplint/compare/v5.0.0-rc.2...v5.0.0-rc.3) (2026-04-19)
15
+
16
+ **Note:** Version bump only for package @markuplint/svelte-spec
17
+
6
18
  # [5.0.0-rc.2](https://github.com/markuplint/markuplint/compare/v5.0.0-rc.1...v5.0.0-rc.2) (2026-04-15)
7
19
 
8
20
  **Note:** Version bump only for package @markuplint/svelte-spec
package/lib/index.d.ts CHANGED
@@ -5,6 +5,11 @@
5
5
  * Defines element-level attribute overrides for Svelte's two-way
6
6
  * binding behavior on form elements and IDL property attributes
7
7
  * such as `defaultValue`, `defaultChecked`, and `indeterminate`.
8
+ *
9
+ * This package intentionally has no test files: it exports only a
10
+ * static data object whose shape is verified by the TypeScript build
11
+ * against the `ExtendedSpec` type, and its behavior is covered by the
12
+ * `@markuplint/svelte-parser` integration tests.
8
13
  */
9
14
  import type { ExtendedSpec } from '@markuplint/ml-spec';
10
15
  /**
package/lib/index.js CHANGED
@@ -5,6 +5,11 @@
5
5
  * Defines element-level attribute overrides for Svelte's two-way
6
6
  * binding behavior on form elements and IDL property attributes
7
7
  * such as `defaultValue`, `defaultChecked`, and `indeterminate`.
8
+ *
9
+ * This package intentionally has no test files: it exports only a
10
+ * static data object whose shape is verified by the TypeScript build
11
+ * against the `ExtendedSpec` type, and its behavior is covered by the
12
+ * `@markuplint/svelte-parser` integration tests.
8
13
  */
9
14
  /**
10
15
  * The Svelte framework extended specification.
@@ -14,6 +19,13 @@
14
19
  * attributes on form elements.
15
20
  */
16
21
  const spec = {
22
+ /**
23
+ * `'both'` rather than `'idl'` (React) because Svelte templates use
24
+ * standard HTML content attribute names, so IDL spellings must not be
25
+ * suggested as renames; IDL names such as `defaultValue` are still
26
+ * resolved to their content attribute equivalents by `MLAttr` in
27
+ * `@markuplint/ml-core`, not by the parser.
28
+ */
17
29
  acceptedAttrNames: 'both',
18
30
  def: {
19
31
  '#globalAttrs': {
@@ -34,6 +46,12 @@ const spec = {
34
46
  },
35
47
  },
36
48
  },
49
+ /**
50
+ * The core engine evaluates these in order and the first match wins,
51
+ * so `^bind:(?:group|this)$` must precede the generic `^bind:(.+)$`;
52
+ * otherwise `bind:group` / `bind:this` would resolve to nonexistent
53
+ * `group` / `this` attributes instead of staying directives.
54
+ */
37
55
  directivePatterns: [
38
56
  // bind:group, bind:this → true directives
39
57
  {
@@ -96,6 +114,11 @@ const spec = {
96
114
  {
97
115
  name: 'select',
98
116
  attributes: {
117
+ /**
118
+ * Standard HTML has no `value` content attribute on `select`;
119
+ * Svelte accepts it, and `bind:value` allows any type, not
120
+ * just strings.
121
+ */
99
122
  value: {
100
123
  type: 'Any',
101
124
  },
@@ -108,6 +131,11 @@ const spec = {
108
131
  {
109
132
  name: 'textarea',
110
133
  attributes: {
134
+ /**
135
+ * Standard HTML has no `value` content attribute on `textarea`;
136
+ * Svelte accepts it, and `bind:value` allows any type, not
137
+ * just strings.
138
+ */
111
139
  value: {
112
140
  type: 'Any',
113
141
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/svelte-spec",
3
- "version": "5.0.0-rc.2",
3
+ "version": "5.0.0-rc.5",
4
4
  "description": "Extended specification for tags and attributes in Svelte",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,7 +10,7 @@
10
10
  "author": "Yusuke Hirao <yusukehirao@me.com>",
11
11
  "license": "MIT",
12
12
  "engines": {
13
- "node": ">=22"
13
+ "node": ">=24"
14
14
  },
15
15
  "type": "module",
16
16
  "exports": {
@@ -28,7 +28,7 @@
28
28
  "clean": "tsc --build --clean tsconfig.build.json"
29
29
  },
30
30
  "dependencies": {
31
- "@markuplint/ml-spec": "5.0.0-rc.2"
31
+ "@markuplint/ml-spec": "5.0.0-rc.5"
32
32
  },
33
- "gitHead": "e43763858d9234c417053becc73dbd088c1e7ea6"
33
+ "gitHead": "8d87463af2ff3f1b83fb28da20f1819362cf3555"
34
34
  }
@@ -1,98 +0,0 @@
1
- # @markuplint/svelte-spec
2
-
3
- ## 概要
4
-
5
- `@markuplint/svelte-spec` は markuplint 向けの Svelte 固有の拡張仕様を提供します。Svelte のフォーム要素における双方向バインディング動作と IDL プロパティ属性に対応するため、要素レベルの属性オーバーライドを定義する `ExtendedSpec` オブジェクトをエクスポートします。`<select>` と `<textarea>` 要素の `value` 属性の型を `Any` に拡張するほか、`<input>`、`<select>`、`<textarea>` 要素で `defaultValue`、`defaultChecked`、`indeterminate` などの IDL プロパティ属性をサポートします。
6
-
7
- ## ExtendedSpec の内容
8
-
9
- ### `acceptedAttrNames`
10
-
11
- この spec は `acceptedAttrNames: 'both'` を設定しており、`@markuplint/ml-core` の `MLAttr` コンストラクタに IDL 属性名を HTML コンテンツ属性名に解決するよう指示します(例: `defaultValue` → 対応するコンテンツ属性)。`'both'` モードではコンテンツ属性名と IDL 名の両方が受け入れられ、リネーム候補は提示されません。この解決はパーサーではなくコアレベルで行われます。
12
-
13
- ### `contenteditable` オーバーライド
14
-
15
- Svelte は `contentEditable` 属性の値として `"inherit"` を受け付けます(ContentEditable インターフェースの IDL 状態値)。この仕様はグローバル属性 `contenteditable` の型を拡張し、`"inherit"` を有効な列挙値として追加します。
16
-
17
- ### `directivePatterns`
18
-
19
- この spec は Svelte ディレクティブ属性を解決するための `directivePatterns` 配列を宣言します。パターンは順番に評価されます(最初のマッチが優先):
20
-
21
- | パターン | 結果 |
22
- | ---------------------------------------------- | ------------------------------------------------------------------------------- |
23
- | `^bind:(?:group\|this)$` | `bind:group` / `bind:this` → `isDirective`、`isDynamicValue` |
24
- | `^bind:(.+)$` | `bind:name` → `potentialName=$1`、`isDynamicValue` |
25
- | `^on:.+$` | `on:event`(Svelte 4 レガシー)→ `isDirective`、`isDynamicValue` |
26
- | `^class:` | `class:name` → `potentialName=class`、`isDuplicatable`、`isDynamicValue` |
27
- | `^style:` | `style:property` → `potentialName=style`、`isDuplicatable`、`isDynamicValue` |
28
- | `^(?:animate\|transition\|in\|out\|use\|let):` | アニメーション/トランジション/アクション/スロットディレクティブ → `isDirective` |
29
-
30
- ### 要素固有のオーバーライド
31
-
32
- | 要素 | 属性 | 型オーバーライド | 理由 |
33
- | ------------ | ---------------- | ---------------- | ------------------------------------------------------------ |
34
- | `<input>` | `defaultChecked` | `Boolean` | チェックボックス/ラジオの非制御初期状態を表す IDL プロパティ |
35
- | `<input>` | `defaultValue` | `Any` | 入力要素の非制御初期値を表す IDL プロパティ |
36
- | `<input>` | `indeterminate` | `Boolean` | チェックボックスの不定状態を表す IDL プロパティ |
37
- | `<select>` | `value` | `Any` | Svelte の `bind:value` は文字列だけでなく任意の型を許容 |
38
- | `<select>` | `defaultValue` | `Any` | セレクト要素の非制御初期値を表す IDL プロパティ |
39
- | `<textarea>` | `value` | `Any` | Svelte の `bind:value` は文字列だけでなく任意の型を許容 |
40
- | `<textarea>` | `defaultValue` | `Any` | テキストエリアの非制御初期値を表す IDL プロパティ |
41
-
42
- これらのオーバーライドにより、markuplint が Svelte 固有の属性使用を不正としてフラグ付けすることなく、標準 HTML 仕様を拡張します。
43
-
44
- ## ディレクトリ構成
45
-
46
- ```
47
- src/
48
- └── index.ts — Svelte 固有のオーバーライドを含む ExtendedSpec オブジェクトをエクスポート
49
- ```
50
-
51
- ## 主要ソースファイル
52
-
53
- | ファイル | 用途 |
54
- | -------------- | ----------------------------------------------------------- |
55
- | `src/index.ts` | Svelte 用の `ExtendedSpec` オブジェクトを定義・エクスポート |
56
-
57
- ## 統合ポイント
58
-
59
- ```mermaid
60
- flowchart TD
61
- subgraph upstream ["上流"]
62
- htmlSpec["@markuplint/html-spec\n(ベース HTML 仕様)"]
63
- mlSpec["@markuplint/ml-spec\n(ExtendedSpec 型)"]
64
- end
65
-
66
- subgraph pkg ["@markuplint/svelte-spec"]
67
- spec["ExtendedSpec オブジェクト\n(input, select, textarea オーバーライド)"]
68
- end
69
-
70
- subgraph downstream ["下流"]
71
- mlCore["@markuplint/ml-core\n(schemaToSpec で仕様をマージ)"]
72
- end
73
-
74
- subgraph paired ["対となるパーサー"]
75
- svelteParser["@markuplint/svelte-parser\n(Svelte コンポーネントのパース)"]
76
- end
77
-
78
- mlSpec -->|"ExtendedSpec 型"| spec
79
- htmlSpec -->|"ベース要素定義"| mlCore
80
- spec -->|"Svelte オーバーライド"| mlCore
81
- svelteParser -->|"MLASTDocument を生成"| mlCore
82
- ```
83
-
84
- ### 上流
85
-
86
- - **`@markuplint/ml-spec`** -- このパッケージが実装する `ExtendedSpec` 型定義を提供
87
-
88
- ### 下流
89
-
90
- - **`@markuplint/ml-core`** -- `schemaToSpec()` を通じてこの仕様を利用し、Svelte のオーバーライドをベース HTML 仕様にマージ
91
-
92
- ### 対となるパーサー
93
-
94
- - **`@markuplint/svelte-parser`** -- Svelte コンポーネント構文を処理するパーサー。パーサーが Svelte テンプレートを markuplint AST に変換する一方、この spec パッケージはリンティングに必要な属性型情報を提供します。
95
-
96
- ## ドキュメントマップ
97
-
98
- - [メンテナンスガイド](docs/maintenance.ja.md) -- コマンド、レシピ、型リファレンス
package/ARCHITECTURE.md DELETED
@@ -1,98 +0,0 @@
1
- # @markuplint/svelte-spec
2
-
3
- ## Overview
4
-
5
- `@markuplint/svelte-spec` provides Svelte-specific extended specifications for markuplint. It exports an `ExtendedSpec` object that defines element-level attribute overrides to accommodate Svelte's two-way binding behavior and IDL property attributes on form elements. The `<select>` and `<textarea>` elements have their `value` attribute type broadened to `Any`, and the `<input>`, `<select>`, and `<textarea>` elements support IDL property attributes such as `defaultValue`, `defaultChecked`, and `indeterminate`.
6
-
7
- ## ExtendedSpec Content
8
-
9
- ### `acceptedAttrNames`
10
-
11
- The spec sets `acceptedAttrNames: 'both'`, which instructs `@markuplint/ml-core`'s `MLAttr` constructor to resolve IDL attribute names to their HTML content attribute equivalents (e.g., `defaultValue` -> the corresponding content attribute). In `'both'` mode, both content attribute names and IDL names are accepted without suggesting a rename. This resolution is performed at the core level, not in the parser.
12
-
13
- ### `contenteditable` Override
14
-
15
- Svelte accepts `"inherit"` as a valid `contentEditable` value (IDL state value from the ContentEditable interface). This spec extends the global `contenteditable` attribute type to include `"inherit"` as a valid enum value.
16
-
17
- ### `directivePatterns`
18
-
19
- The spec declares a `directivePatterns` array that the core engine uses to resolve Svelte directive attributes. Patterns are evaluated in order (first match wins):
20
-
21
- | Pattern | Result |
22
- | ---------------------------------------------- | ----------------------------------------------------------------------------- |
23
- | `^bind:(?:group\|this)$` | `bind:group` / `bind:this` -> `isDirective`, `isDynamicValue` |
24
- | `^bind:(.+)$` | `bind:name` -> `potentialName=$1`, `isDynamicValue` |
25
- | `^on:.+$` | `on:event` (Svelte 4 legacy) -> `isDirective`, `isDynamicValue` |
26
- | `^class:` | `class:name` -> `potentialName=class`, `isDuplicatable`, `isDynamicValue` |
27
- | `^style:` | `style:property` -> `potentialName=style`, `isDuplicatable`, `isDynamicValue` |
28
- | `^(?:animate\|transition\|in\|out\|use\|let):` | Animation/transition/action/slot directives -> `isDirective` |
29
-
30
- ### Element-Specific Overrides
31
-
32
- | Element | Attribute | Type Override | Reason |
33
- | ------------ | ---------------- | ------------- | ---------------------------------------------------------- |
34
- | `<input>` | `defaultChecked` | `Boolean` | IDL property for uncontrolled checkbox/radio initial state |
35
- | `<input>` | `defaultValue` | `Any` | IDL property for uncontrolled input initial value |
36
- | `<input>` | `indeterminate` | `Boolean` | IDL property for checkbox indeterminate state |
37
- | `<select>` | `value` | `Any` | Svelte's `bind:value` allows any type, not just strings |
38
- | `<select>` | `defaultValue` | `Any` | IDL property for uncontrolled select initial value |
39
- | `<textarea>` | `value` | `Any` | Svelte's `bind:value` allows any type, not just strings |
40
- | `<textarea>` | `defaultValue` | `Any` | IDL property for uncontrolled textarea initial value |
41
-
42
- These overrides extend the standard HTML spec so that markuplint does not flag Svelte-specific attribute usage as invalid.
43
-
44
- ## Directory Structure
45
-
46
- ```
47
- src/
48
- └── index.ts — Exports the ExtendedSpec object with Svelte-specific overrides
49
- ```
50
-
51
- ## Key Source Files
52
-
53
- | File | Purpose |
54
- | -------------- | -------------------------------------------------------- |
55
- | `src/index.ts` | Defines and exports the `ExtendedSpec` object for Svelte |
56
-
57
- ## Integration Points
58
-
59
- ```mermaid
60
- flowchart TD
61
- subgraph upstream ["Upstream"]
62
- htmlSpec["@markuplint/html-spec\n(Base HTML spec)"]
63
- mlSpec["@markuplint/ml-spec\n(ExtendedSpec type)"]
64
- end
65
-
66
- subgraph pkg ["@markuplint/svelte-spec"]
67
- spec["ExtendedSpec object\n(input, select, textarea overrides)"]
68
- end
69
-
70
- subgraph downstream ["Downstream"]
71
- mlCore["@markuplint/ml-core\n(Merges specs via schemaToSpec)"]
72
- end
73
-
74
- subgraph paired ["Paired Parser"]
75
- svelteParser["@markuplint/svelte-parser\n(Svelte component parsing)"]
76
- end
77
-
78
- mlSpec -->|"ExtendedSpec type"| spec
79
- htmlSpec -->|"Base element definitions"| mlCore
80
- spec -->|"Svelte overrides"| mlCore
81
- svelteParser -->|"Produces MLASTDocument"| mlCore
82
- ```
83
-
84
- ### Upstream
85
-
86
- - **`@markuplint/ml-spec`** -- Provides the `ExtendedSpec` type definition that this package implements
87
-
88
- ### Downstream
89
-
90
- - **`@markuplint/ml-core`** -- Consumes this spec via `schemaToSpec()`, merging Svelte overrides with the base HTML spec
91
-
92
- ### Paired Parser
93
-
94
- - **`@markuplint/svelte-parser`** -- The parser counterpart that handles Svelte component syntax. While the parser converts Svelte templates into the markuplint AST, this spec package provides the attribute type information needed for linting.
95
-
96
- ## Documentation Map
97
-
98
- - [Maintenance Guide](docs/maintenance.md) -- Commands, recipes, and type reference
package/SKILL.md DELETED
@@ -1,99 +0,0 @@
1
- ---
2
- description: Maintenance tasks for @markuplint/svelte-spec
3
- globs:
4
- - packages/@markuplint/svelte-spec/src/**/*.ts
5
- alwaysApply: false
6
- ---
7
-
8
- # svelte-spec-maintenance
9
-
10
- Perform maintenance tasks for `@markuplint/svelte-spec`: add global attributes,
11
- add element-specific attribute overrides for Svelte components.
12
-
13
- ## Input
14
-
15
- `$ARGUMENTS` specifies the task. Supported tasks:
16
-
17
- | Task | Description |
18
- | ---------------------- | ------------------------------------------ |
19
- | `add-global-attribute` | Add a new global attribute for Svelte |
20
- | `add-element-override` | Add an element-specific attribute override |
21
-
22
- If omitted, defaults to `add-element-override`.
23
-
24
- ## Reference
25
-
26
- Before executing any task, read `docs/maintenance.md` (or `docs/maintenance.ja.md`)
27
- for the full guide. The recipes there are the source of truth for procedures.
28
-
29
- Also read:
30
-
31
- - `ARCHITECTURE.md` -- Package overview, ExtendedSpec content, and integration points
32
- - `src/index.ts` -- The single source file (source of truth for the spec object)
33
-
34
- ## Task: add-global-attribute
35
-
36
- Add a new global attribute that applies to all Svelte elements. Follow recipe #1 in `docs/maintenance.md`.
37
-
38
- ### Step 1: Read the current spec
39
-
40
- 1. Read `src/index.ts` to understand the current `ExtendedSpec` structure
41
- 2. Check if a `def` property with `#globalAttrs` already exists
42
-
43
- ### Step 2: Add the global attribute
44
-
45
- 1. If `def` does not exist, add it to the spec object:
46
- ```ts
47
- def: {
48
- '#globalAttrs': {
49
- '#extends': {
50
- 'attribute-name': {
51
- type: 'Any',
52
- },
53
- },
54
- },
55
- },
56
- ```
57
- 2. If `def['#globalAttrs']['#extends']` already exists, add the new attribute to it
58
-
59
- ### Step 3: Verify
60
-
61
- 1. Build: `yarn build --scope @markuplint/svelte-spec`
62
- 2. Test: `yarn test --scope @markuplint/svelte-spec`
63
-
64
- ## Task: add-element-override
65
-
66
- Add an element-specific attribute override. Follow recipe #2 in `docs/maintenance.md`.
67
-
68
- ### Step 1: Read the current spec
69
-
70
- 1. Read `src/index.ts` to understand the current `specs` array
71
- 2. Check if the target element already has an entry
72
-
73
- ### Step 2: Add the override
74
-
75
- 1. If the element already exists in `specs`, add the new attribute to its `attributes` object
76
- 2. If the element does not exist, add a new entry to the `specs` array:
77
- ```ts
78
- {
79
- name: 'element-name',
80
- attributes: {
81
- 'attribute-name': {
82
- type: 'Any',
83
- },
84
- },
85
- },
86
- ```
87
-
88
- ### Step 3: Verify
89
-
90
- 1. Build: `yarn build --scope @markuplint/svelte-spec`
91
- 2. Test: `yarn test --scope @markuplint/svelte-spec`
92
-
93
- ## Rules
94
-
95
- 1. **Only export an `ExtendedSpec` object** -- this package must not contain any parsing logic.
96
- 2. **Global attributes go under `def['#globalAttrs']['#extends']`** -- not in the `specs` array.
97
- 3. **Element overrides go under the `specs[]` array** -- each entry needs a `name` and `attributes` object.
98
- 4. **Each attribute needs at minimum a `type` field** -- common values are `Any`, `String`, `Boolean`, or an enum object.
99
- 5. **Add JSDoc comments** to any new attribute definitions explaining why the override is needed.
@@ -1,127 +0,0 @@
1
- # メンテナンスガイド
2
-
3
- ## コマンド
4
-
5
- | コマンド | 説明 |
6
- | -------------------------------------------- | ---------------------- |
7
- | `yarn build --scope @markuplint/svelte-spec` | このパッケージをビルド |
8
- | `yarn dev --scope @markuplint/svelte-spec` | ウォッチモードでビルド |
9
- | `yarn clean --scope @markuplint/svelte-spec` | ビルド成果物を削除 |
10
- | `yarn test --scope @markuplint/svelte-spec` | テストを実行 |
11
-
12
- ## テスト
13
-
14
- このパッケージは静的なデータオブジェクトのみをエクスポートするため、デフォルトではテストファイルがありません。検証はビルドステップで行われます(TypeScript の型チェックにより、エクスポートされたオブジェクトが `ExtendedSpec` 型に準拠していることが保証されます)。
15
-
16
- 下流パッケージとの統合を検証するには:
17
-
18
- ```shell
19
- yarn test --scope @markuplint/svelte-parser
20
- ```
21
-
22
- ## レシピ
23
-
24
- ### 1. グローバル属性の追加
25
-
26
- 1. `src/index.ts` を読む
27
- 2. spec オブジェクトに `def` プロパティが存在しない場合、追加する:
28
- ```ts
29
- const spec: ExtendedSpec = {
30
- def: {
31
- '#globalAttrs': {
32
- '#extends': {
33
- 'new-attribute': {
34
- type: 'Any',
35
- },
36
- },
37
- },
38
- },
39
- specs: [
40
- // 既存のエントリ...
41
- ],
42
- };
43
- ```
44
- 3. `def['#globalAttrs']['#extends']` が既に存在する場合、既存のオブジェクトに新しい属性を追加
45
- 4. ビルド: `yarn build --scope @markuplint/svelte-spec`
46
- 5. 下流パーサーが正常に動作することを確認: `yarn test --scope @markuplint/svelte-parser`
47
-
48
- ### 2. 要素固有のオーバーライドの追加
49
-
50
- 1. `src/index.ts` を読む
51
- 2. 対象の要素が `specs` 配列に既にエントリを持っているか確認
52
- 3. 要素が存在する場合、その `attributes` オブジェクトに新しい属性を追加:
53
- ```ts
54
- {
55
- name: 'existing-element',
56
- attributes: {
57
- existingAttr: { type: 'Any' },
58
- newAttr: { type: 'Any' }, // ここに追加
59
- },
60
- },
61
- ```
62
- 4. 要素が存在しない場合、`specs` 配列に新しいエントリを追加:
63
- ```ts
64
- {
65
- name: 'new-element',
66
- attributes: {
67
- 'attribute-name': {
68
- type: 'Any',
69
- },
70
- },
71
- },
72
- ```
73
- 5. ビルド: `yarn build --scope @markuplint/svelte-spec`
74
- 6. 下流パーサーが正常に動作することを確認: `yarn test --scope @markuplint/svelte-parser`
75
-
76
- ## ExtendedSpec 型リファレンス
77
-
78
- `ExtendedSpec` 型(`@markuplint/ml-spec` から提供)は以下の構造を持ちます:
79
-
80
- ```ts
81
- type ExtendedSpec = {
82
- readonly cites?: Cites; // 参照 URL
83
- readonly def?: Partial<SpecDefs>; // グローバル定義
84
- readonly specs?: readonly ExtendedElementSpec[]; // 要素ごとのオーバーライド
85
- };
86
- ```
87
-
88
- ### `def` -- グローバル定義
89
-
90
- すべての要素に適用される属性に使用:
91
-
92
- ```ts
93
- def: {
94
- '#globalAttrs': {
95
- '#extends': {
96
- 'attribute-name': {
97
- type: 'Any',
98
- },
99
- },
100
- },
101
- }
102
- ```
103
-
104
- ### `specs` -- 要素ごとのオーバーライド
105
-
106
- `specs` 配列の各エントリは特定の HTML 要素を対象とします:
107
-
108
- ```ts
109
- specs: [
110
- {
111
- name: 'element-name', // HTML タグ名
112
- attributes: {
113
- 'attribute-name': {
114
- type: 'Any', // 型オーバーライド
115
- },
116
- },
117
- },
118
- ];
119
- ```
120
-
121
- よく使われる属性型の値:
122
-
123
- | 型の値 | 意味 |
124
- | ----------- | ---------------------------------- |
125
- | `'Any'` | 任意の型を許容(バインド値に使用) |
126
- | `'String'` | 文字列値のみ許容 |
127
- | `'Boolean'` | ブール属性(存在/不在) |
@@ -1,127 +0,0 @@
1
- # Maintenance Guide
2
-
3
- ## Commands
4
-
5
- | Command | Description |
6
- | -------------------------------------------- | ---------------------- |
7
- | `yarn build --scope @markuplint/svelte-spec` | Build this package |
8
- | `yarn dev --scope @markuplint/svelte-spec` | Watch mode build |
9
- | `yarn clean --scope @markuplint/svelte-spec` | Remove build artifacts |
10
- | `yarn test --scope @markuplint/svelte-spec` | Run tests |
11
-
12
- ## Testing
13
-
14
- This package has no test files by default because it exports only a static data object. Verification is done through the build step (TypeScript type checking ensures the exported object conforms to the `ExtendedSpec` type).
15
-
16
- To verify integration with downstream packages:
17
-
18
- ```shell
19
- yarn test --scope @markuplint/svelte-parser
20
- ```
21
-
22
- ## Recipes
23
-
24
- ### 1. Adding a Global Attribute
25
-
26
- 1. Read `src/index.ts`
27
- 2. If the `def` property does not exist on the spec object, add it:
28
- ```ts
29
- const spec: ExtendedSpec = {
30
- def: {
31
- '#globalAttrs': {
32
- '#extends': {
33
- 'new-attribute': {
34
- type: 'Any',
35
- },
36
- },
37
- },
38
- },
39
- specs: [
40
- // existing entries...
41
- ],
42
- };
43
- ```
44
- 3. If `def['#globalAttrs']['#extends']` already exists, add the new attribute to the existing object
45
- 4. Build: `yarn build --scope @markuplint/svelte-spec`
46
- 5. Verify the downstream parser still works: `yarn test --scope @markuplint/svelte-parser`
47
-
48
- ### 2. Adding an Element-Specific Override
49
-
50
- 1. Read `src/index.ts`
51
- 2. Check if the target element already has an entry in the `specs` array
52
- 3. If the element exists, add the new attribute to its `attributes` object:
53
- ```ts
54
- {
55
- name: 'existing-element',
56
- attributes: {
57
- existingAttr: { type: 'Any' },
58
- newAttr: { type: 'Any' }, // add here
59
- },
60
- },
61
- ```
62
- 4. If the element does not exist, add a new entry to the `specs` array:
63
- ```ts
64
- {
65
- name: 'new-element',
66
- attributes: {
67
- 'attribute-name': {
68
- type: 'Any',
69
- },
70
- },
71
- },
72
- ```
73
- 5. Build: `yarn build --scope @markuplint/svelte-spec`
74
- 6. Verify the downstream parser still works: `yarn test --scope @markuplint/svelte-parser`
75
-
76
- ## ExtendedSpec Type Reference
77
-
78
- The `ExtendedSpec` type (from `@markuplint/ml-spec`) has the following structure:
79
-
80
- ```ts
81
- type ExtendedSpec = {
82
- readonly cites?: Cites; // Reference URLs
83
- readonly def?: Partial<SpecDefs>; // Global definitions
84
- readonly specs?: readonly ExtendedElementSpec[]; // Per-element overrides
85
- };
86
- ```
87
-
88
- ### `def` -- Global Definitions
89
-
90
- Used for attributes that apply to all elements:
91
-
92
- ```ts
93
- def: {
94
- '#globalAttrs': {
95
- '#extends': {
96
- 'attribute-name': {
97
- type: 'Any',
98
- },
99
- },
100
- },
101
- }
102
- ```
103
-
104
- ### `specs` -- Per-Element Overrides
105
-
106
- Each entry in the `specs` array targets a specific HTML element:
107
-
108
- ```ts
109
- specs: [
110
- {
111
- name: 'element-name', // HTML tag name
112
- attributes: {
113
- 'attribute-name': {
114
- type: 'Any', // Type override
115
- },
116
- },
117
- },
118
- ];
119
- ```
120
-
121
- Common attribute type values:
122
-
123
- | Type Value | Meaning |
124
- | ----------- | ---------------------------------------- |
125
- | `'Any'` | Accepts any type (used for bound values) |
126
- | `'String'` | Accepts only string values |
127
- | `'Boolean'` | Boolean attribute (presence/absence) |