@markuplint/vue-parser 3.0.0-dev.54 → 3.0.0-dev.96
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/lib/attr.js +85 -13
- package/package.json +5 -5
package/lib/attr.js
CHANGED
|
@@ -10,24 +10,96 @@ function attr(attr) {
|
|
|
10
10
|
}
|
|
11
11
|
return attr;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
13
|
+
{
|
|
14
|
+
/**
|
|
15
|
+
* `v-on`
|
|
16
|
+
*/
|
|
17
|
+
const [, directive, potentialName, modifier] = attr.name.raw.match(/^(v-on:|@)([^.]+)(?:\.([^.]))?$/i) || [];
|
|
18
|
+
if (directive && potentialName) {
|
|
19
|
+
return {
|
|
20
|
+
...attr,
|
|
21
|
+
potentialName: `on${potentialName.toLowerCase()}`,
|
|
22
|
+
isDynamicValue: true,
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
_modifier: modifier,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
{
|
|
29
|
+
/**
|
|
30
|
+
* `v-bind`
|
|
31
|
+
*/
|
|
32
|
+
const [, directive, potentialName, modifier] = attr.name.raw.match(/^(v-bind:|:)([^.]+)(?:\.([^.]))?$/i) || [];
|
|
33
|
+
if (directive && potentialName) {
|
|
34
|
+
if (duplicatableAttrs.includes(potentialName.toLowerCase())) {
|
|
35
|
+
attr.isDuplicatable = true;
|
|
36
|
+
}
|
|
37
|
+
if (!modifier) {
|
|
38
|
+
return {
|
|
39
|
+
...attr,
|
|
40
|
+
potentialName,
|
|
41
|
+
isDynamicValue: true,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
switch (modifier) {
|
|
45
|
+
case '.attr': {
|
|
46
|
+
return {
|
|
47
|
+
...attr,
|
|
48
|
+
potentialName,
|
|
49
|
+
isDynamicValue: true,
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
_modifier: modifier,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// TODO: Supporting for `prop` and `camel` https://github.com/markuplint/markuplint/pull/681
|
|
55
|
+
case '.prop':
|
|
56
|
+
case '.camel':
|
|
57
|
+
default: {
|
|
58
|
+
const name = `v-bind:${potentialName}${modifier !== null && modifier !== void 0 ? modifier : ''}`;
|
|
59
|
+
return {
|
|
60
|
+
...attr,
|
|
61
|
+
potentialName: attr.name.raw !== name ? name : undefined,
|
|
62
|
+
isDirective: true,
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
_modifier: modifier,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
{
|
|
71
|
+
/**
|
|
72
|
+
* `v-model`
|
|
73
|
+
*/
|
|
74
|
+
const [, directive, modifier] = attr.name.raw.match(/^(v-model)(?:\.([^.]))?$/i) || [];
|
|
75
|
+
if (directive) {
|
|
76
|
+
// TODO: Supporting for `v-model` https://github.com/markuplint/markuplint/pull/681
|
|
77
|
+
return {
|
|
78
|
+
...attr,
|
|
79
|
+
isDirective: true,
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
_modifier: modifier,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
{
|
|
86
|
+
/**
|
|
87
|
+
* `v-slot`
|
|
88
|
+
*/
|
|
89
|
+
const [, , slotName] = attr.name.raw.match(/^(v-slot:|#)(.+)$/i) || [];
|
|
90
|
+
const name = `v-slot:${slotName}`;
|
|
91
|
+
if (slotName) {
|
|
92
|
+
return {
|
|
93
|
+
...attr,
|
|
94
|
+
potentialName: attr.name.raw !== name ? name : undefined,
|
|
95
|
+
isDirective: true,
|
|
96
|
+
};
|
|
20
97
|
}
|
|
21
|
-
return {
|
|
22
|
-
...attr,
|
|
23
|
-
potentialName,
|
|
24
|
-
isDynamicValue: true,
|
|
25
|
-
};
|
|
26
98
|
}
|
|
27
99
|
/**
|
|
28
100
|
* If directives
|
|
29
101
|
*/
|
|
30
|
-
if (/^
|
|
102
|
+
if (/^v-/.test(attr.name.raw)) {
|
|
31
103
|
return {
|
|
32
104
|
...attr,
|
|
33
105
|
isDirective: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/vue-parser",
|
|
3
|
-
"version": "3.0.0-dev.
|
|
3
|
+
"version": "3.0.0-dev.96+3b9f1720",
|
|
4
4
|
"description": "Vue parser for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"clean": "tsc --build --clean"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@markuplint/html-parser": "3.0.0-dev.
|
|
20
|
-
"@markuplint/ml-ast": "3.0.0-dev.
|
|
21
|
-
"@markuplint/parser-utils": "3.0.0-dev.
|
|
19
|
+
"@markuplint/html-parser": "3.0.0-dev.96+3b9f1720",
|
|
20
|
+
"@markuplint/ml-ast": "3.0.0-dev.96+3b9f1720",
|
|
21
|
+
"@markuplint/parser-utils": "3.0.0-dev.96+3b9f1720",
|
|
22
22
|
"tslib": "^2.4.1",
|
|
23
23
|
"vue-eslint-parser": "^9.1.0"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "3b9f17205d7754b29edf790bdbbf5e4931ba27a2"
|
|
26
26
|
}
|