@markuplint/svelte-spec 4.5.23 → 5.0.0-alpha.1
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/ARCHITECTURE.ja.md +31 -7
- package/ARCHITECTURE.md +31 -7
- package/CHANGELOG.md +16 -0
- package/lib/index.d.ts +4 -6
- package/lib/index.js +90 -6
- package/package.json +6 -3
package/ARCHITECTURE.ja.md
CHANGED
|
@@ -2,18 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
## 概要
|
|
4
4
|
|
|
5
|
-
`@markuplint/svelte-spec` は markuplint 向けの Svelte 固有の拡張仕様を提供します。Svelte
|
|
5
|
+
`@markuplint/svelte-spec` は markuplint 向けの Svelte 固有の拡張仕様を提供します。Svelte のフォーム要素における双方向バインディング動作と IDL プロパティ属性に対応するため、要素レベルの属性オーバーライドを定義する `ExtendedSpec` オブジェクトをエクスポートします。`<select>` と `<textarea>` 要素の `value` 属性の型を `Any` に拡張するほか、`<input>`、`<select>`、`<textarea>` 要素で `defaultValue`、`defaultChecked`、`indeterminate` などの IDL プロパティ属性をサポートします。
|
|
6
6
|
|
|
7
7
|
## ExtendedSpec の内容
|
|
8
8
|
|
|
9
|
-
|
|
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` |
|
|
10
29
|
|
|
11
30
|
### 要素固有のオーバーライド
|
|
12
31
|
|
|
13
|
-
| 要素 | 属性
|
|
14
|
-
| ------------ |
|
|
15
|
-
| `<
|
|
16
|
-
| `<
|
|
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 プロパティ |
|
|
17
41
|
|
|
18
42
|
これらのオーバーライドにより、markuplint が Svelte 固有の属性使用を不正としてフラグ付けすることなく、標準 HTML 仕様を拡張します。
|
|
19
43
|
|
|
@@ -40,7 +64,7 @@ flowchart TD
|
|
|
40
64
|
end
|
|
41
65
|
|
|
42
66
|
subgraph pkg ["@markuplint/svelte-spec"]
|
|
43
|
-
spec["ExtendedSpec オブジェクト\n(select, textarea オーバーライド)"]
|
|
67
|
+
spec["ExtendedSpec オブジェクト\n(input, select, textarea オーバーライド)"]
|
|
44
68
|
end
|
|
45
69
|
|
|
46
70
|
subgraph downstream ["下流"]
|
package/ARCHITECTURE.md
CHANGED
|
@@ -2,18 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
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 on form elements.
|
|
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
6
|
|
|
7
7
|
## ExtendedSpec Content
|
|
8
8
|
|
|
9
|
-
|
|
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` |
|
|
10
29
|
|
|
11
30
|
### Element-Specific Overrides
|
|
12
31
|
|
|
13
|
-
| Element | Attribute
|
|
14
|
-
| ------------ |
|
|
15
|
-
| `<
|
|
16
|
-
| `<
|
|
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 |
|
|
17
41
|
|
|
18
42
|
These overrides extend the standard HTML spec so that markuplint does not flag Svelte-specific attribute usage as invalid.
|
|
19
43
|
|
|
@@ -40,7 +64,7 @@ flowchart TD
|
|
|
40
64
|
end
|
|
41
65
|
|
|
42
66
|
subgraph pkg ["@markuplint/svelte-spec"]
|
|
43
|
-
spec["ExtendedSpec object\n(select, textarea overrides)"]
|
|
67
|
+
spec["ExtendedSpec object\n(input, select, textarea overrides)"]
|
|
44
68
|
end
|
|
45
69
|
|
|
46
70
|
subgraph downstream ["Downstream"]
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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-alpha.1](https://github.com/markuplint/markuplint/compare/v5.0.0-alpha.0...v5.0.0-alpha.1) (2026-02-22)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **svelte-spec:** use acceptedAttrNames and add contenteditable override ([60a6279](https://github.com/markuplint/markuplint/commit/60a627907b93543b542b9578b53cbe06406a5196))
|
|
11
|
+
|
|
12
|
+
# [5.0.0-alpha.0](https://github.com/markuplint/markuplint/compare/v4.14.1...v5.0.0-alpha.0) (2026-02-20)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- **svelte-spec:** allow IDL property attributes on form elements ([418e88d](https://github.com/markuplint/markuplint/commit/418e88dac4158d25be883f1495592c495849ca75)), closes [#2590](https://github.com/markuplint/markuplint/issues/2590)
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
- **svelte-spec:** add directivePatterns and useIDLAttributeNames ([78568cf](https://github.com/markuplint/markuplint/commit/78568cff19bef02a8f255eed33bb7e50a8c89c6d))
|
|
21
|
+
|
|
6
22
|
## [4.5.23](https://github.com/markuplint/markuplint/compare/@markuplint/svelte-spec@4.5.22...@markuplint/svelte-spec@4.5.23) (2026-02-10)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @markuplint/svelte-spec
|
package/lib/index.d.ts
CHANGED
|
@@ -3,18 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides Svelte-specific extended specifications for markuplint.
|
|
5
5
|
* Defines element-level attribute overrides for Svelte's two-way
|
|
6
|
-
* binding behavior on form elements
|
|
7
|
-
*
|
|
8
|
-
* variables.
|
|
6
|
+
* binding behavior on form elements and IDL property attributes
|
|
7
|
+
* such as `defaultValue`, `defaultChecked`, and `indeterminate`.
|
|
9
8
|
*/
|
|
10
9
|
import type { ExtendedSpec } from '@markuplint/ml-spec';
|
|
11
10
|
/**
|
|
12
11
|
* The Svelte framework extended specification.
|
|
13
12
|
*
|
|
14
13
|
* Provides per-element attribute definitions that accommodate
|
|
15
|
-
* Svelte's two-way binding (`bind:value`)
|
|
16
|
-
*
|
|
17
|
-
* any type rather than only strings.
|
|
14
|
+
* Svelte's two-way binding (`bind:value`) and IDL property
|
|
15
|
+
* attributes on form elements.
|
|
18
16
|
*/
|
|
19
17
|
declare const spec: ExtendedSpec;
|
|
20
18
|
export default spec;
|
package/lib/index.js
CHANGED
|
@@ -3,26 +3,106 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides Svelte-specific extended specifications for markuplint.
|
|
5
5
|
* Defines element-level attribute overrides for Svelte's two-way
|
|
6
|
-
* binding behavior on form elements
|
|
7
|
-
*
|
|
8
|
-
* variables.
|
|
6
|
+
* binding behavior on form elements and IDL property attributes
|
|
7
|
+
* such as `defaultValue`, `defaultChecked`, and `indeterminate`.
|
|
9
8
|
*/
|
|
10
9
|
/**
|
|
11
10
|
* The Svelte framework extended specification.
|
|
12
11
|
*
|
|
13
12
|
* Provides per-element attribute definitions that accommodate
|
|
14
|
-
* Svelte's two-way binding (`bind:value`)
|
|
15
|
-
*
|
|
16
|
-
* any type rather than only strings.
|
|
13
|
+
* Svelte's two-way binding (`bind:value`) and IDL property
|
|
14
|
+
* attributes on form elements.
|
|
17
15
|
*/
|
|
18
16
|
const spec = {
|
|
17
|
+
acceptedAttrNames: 'both',
|
|
18
|
+
def: {
|
|
19
|
+
'#globalAttrs': {
|
|
20
|
+
'#extends': {
|
|
21
|
+
/**
|
|
22
|
+
* Svelte accepts "inherit" as a valid contentEditable value
|
|
23
|
+
* (IDL state value from the ContentEditable interface).
|
|
24
|
+
*/
|
|
25
|
+
contenteditable: {
|
|
26
|
+
type: {
|
|
27
|
+
enum: ['', 'true', 'false', 'plaintext-only', 'inherit'],
|
|
28
|
+
disallowToSurroundBySpaces: true,
|
|
29
|
+
invalidValueDefault: 'inherit',
|
|
30
|
+
missingValueDefault: 'inherit',
|
|
31
|
+
sameStates: { true: [''] },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
directivePatterns: [
|
|
38
|
+
// bind:group, bind:this → true directives
|
|
39
|
+
{
|
|
40
|
+
pattern: '^bind:(?:group|this)$',
|
|
41
|
+
isDirective: true,
|
|
42
|
+
isDynamicValue: true,
|
|
43
|
+
},
|
|
44
|
+
// bind:name → potentialName=name, isDynamicValue
|
|
45
|
+
{
|
|
46
|
+
pattern: '^bind:(.+)$',
|
|
47
|
+
potentialName: '$1',
|
|
48
|
+
isDynamicValue: true,
|
|
49
|
+
},
|
|
50
|
+
// on:event (Svelte 4 legacy)
|
|
51
|
+
{
|
|
52
|
+
pattern: '^on:.+$',
|
|
53
|
+
isDirective: true,
|
|
54
|
+
isDynamicValue: true,
|
|
55
|
+
},
|
|
56
|
+
// class:name → potentialName=class, isDuplicatable
|
|
57
|
+
{
|
|
58
|
+
pattern: '^class:',
|
|
59
|
+
potentialName: 'class',
|
|
60
|
+
isDuplicatable: true,
|
|
61
|
+
isDynamicValue: true,
|
|
62
|
+
},
|
|
63
|
+
// style:property → potentialName=style, isDuplicatable
|
|
64
|
+
{
|
|
65
|
+
pattern: '^style:',
|
|
66
|
+
potentialName: 'style',
|
|
67
|
+
isDuplicatable: true,
|
|
68
|
+
isDynamicValue: true,
|
|
69
|
+
},
|
|
70
|
+
// animate:, transition:, in:, out:, use:, let: → isDirective
|
|
71
|
+
{
|
|
72
|
+
pattern: '^(?:animate|transition|in|out|use|let):',
|
|
73
|
+
isDirective: true,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
19
76
|
specs: [
|
|
77
|
+
{
|
|
78
|
+
name: 'input',
|
|
79
|
+
attributes: {
|
|
80
|
+
defaultChecked: {
|
|
81
|
+
type: 'Boolean',
|
|
82
|
+
caseSensitive: true,
|
|
83
|
+
condition: ['[type=checkbox]', '[type=radio]'],
|
|
84
|
+
},
|
|
85
|
+
defaultValue: {
|
|
86
|
+
type: 'Any',
|
|
87
|
+
caseSensitive: true,
|
|
88
|
+
},
|
|
89
|
+
indeterminate: {
|
|
90
|
+
type: 'Boolean',
|
|
91
|
+
caseSensitive: true,
|
|
92
|
+
condition: '[type=checkbox]',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
20
96
|
{
|
|
21
97
|
name: 'select',
|
|
22
98
|
attributes: {
|
|
23
99
|
value: {
|
|
24
100
|
type: 'Any',
|
|
25
101
|
},
|
|
102
|
+
defaultValue: {
|
|
103
|
+
type: 'Any',
|
|
104
|
+
caseSensitive: true,
|
|
105
|
+
},
|
|
26
106
|
},
|
|
27
107
|
},
|
|
28
108
|
{
|
|
@@ -31,6 +111,10 @@ const spec = {
|
|
|
31
111
|
value: {
|
|
32
112
|
type: 'Any',
|
|
33
113
|
},
|
|
114
|
+
defaultValue: {
|
|
115
|
+
type: 'Any',
|
|
116
|
+
caseSensitive: true,
|
|
117
|
+
},
|
|
34
118
|
},
|
|
35
119
|
},
|
|
36
120
|
],
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/svelte-spec",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha.1",
|
|
4
4
|
"description": "Extended specification for tags and attributes in Svelte",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22"
|
|
10
|
+
},
|
|
8
11
|
"type": "module",
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
@@ -21,7 +24,7 @@
|
|
|
21
24
|
"clean": "tsc --build --clean tsconfig.build.json"
|
|
22
25
|
},
|
|
23
26
|
"dependencies": {
|
|
24
|
-
"@markuplint/ml-spec": "
|
|
27
|
+
"@markuplint/ml-spec": "5.0.0-alpha.1"
|
|
25
28
|
},
|
|
26
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "78a295e73a097a1ce09c777c06fa21ab68136387"
|
|
27
30
|
}
|