@markuplint/vue-parser 3.4.0 → 3.6.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/lib/attr.js +8 -5
- package/lib/parse.js +12 -4
- package/package.json +5 -5
package/lib/attr.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.attr = void 0;
|
|
4
4
|
const duplicatableAttrs = ['class', 'style'];
|
|
5
|
-
function attr(
|
|
5
|
+
function attr(
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
|
+
attr) {
|
|
8
|
+
var _a, _b, _c, _d;
|
|
6
9
|
if (attr.type !== 'html-attr') {
|
|
7
10
|
const name = attr.potentialName;
|
|
8
11
|
if (duplicatableAttrs.includes(name)) {
|
|
@@ -14,7 +17,7 @@ function attr(attr) {
|
|
|
14
17
|
/**
|
|
15
18
|
* `v-on`
|
|
16
19
|
*/
|
|
17
|
-
const [, directive, potentialName, modifier] = attr.name.raw.match(/^(v-on:|@)([^.]+)(?:\.([^.]))?$/i)
|
|
20
|
+
const [, directive, potentialName, modifier] = (_a = attr.name.raw.match(/^(v-on:|@)([^.]+)(?:\.([^.]+))?$/i)) !== null && _a !== void 0 ? _a : [];
|
|
18
21
|
if (directive && potentialName) {
|
|
19
22
|
return {
|
|
20
23
|
...attr,
|
|
@@ -29,7 +32,7 @@ function attr(attr) {
|
|
|
29
32
|
/**
|
|
30
33
|
* `v-bind`
|
|
31
34
|
*/
|
|
32
|
-
const [, directive, potentialName, modifier] = attr.name.raw.match(/^(v-bind:|:)([^.]+)(?:\.([^.]))?$/i)
|
|
35
|
+
const [, directive, potentialName, modifier] = (_b = attr.name.raw.match(/^(v-bind:|:)([^.]+)(?:\.([^.]+))?$/i)) !== null && _b !== void 0 ? _b : [];
|
|
33
36
|
if (directive && potentialName) {
|
|
34
37
|
if (duplicatableAttrs.includes(potentialName.toLowerCase())) {
|
|
35
38
|
attr.isDuplicatable = true;
|
|
@@ -71,7 +74,7 @@ function attr(attr) {
|
|
|
71
74
|
/**
|
|
72
75
|
* `v-model`
|
|
73
76
|
*/
|
|
74
|
-
const [, directive, modifier] = attr.name.raw.match(/^(v-model)(?:\.([^.]))?$/i)
|
|
77
|
+
const [, directive, modifier] = (_c = attr.name.raw.match(/^(v-model)(?:\.([^.]+))?$/i)) !== null && _c !== void 0 ? _c : [];
|
|
75
78
|
if (directive) {
|
|
76
79
|
// TODO: Supporting for `v-model` https://github.com/markuplint/markuplint/pull/681
|
|
77
80
|
return {
|
|
@@ -86,7 +89,7 @@ function attr(attr) {
|
|
|
86
89
|
/**
|
|
87
90
|
* `v-slot`
|
|
88
91
|
*/
|
|
89
|
-
const [, , slotName] = attr.name.raw.match(/^(v-slot:|#)(.+)$/i)
|
|
92
|
+
const [, , slotName] = (_d = attr.name.raw.match(/^(v-slot:|#)(.+)$/i)) !== null && _d !== void 0 ? _d : [];
|
|
90
93
|
const name = `v-slot:${slotName}`;
|
|
91
94
|
if (slotName) {
|
|
92
95
|
return {
|
package/lib/parse.js
CHANGED
|
@@ -30,7 +30,7 @@ const parse = (rawCode, options) => {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
const nodeList = ast.templateBody
|
|
33
|
-
? (0,
|
|
33
|
+
? (0, parser_utils_1.flattenNodes)(traverse(ast.templateBody, null, rawCode, options), rawCode)
|
|
34
34
|
: [];
|
|
35
35
|
// Remove `</template>`
|
|
36
36
|
const templateEndTagIndex = nodeList.findIndex(node => /\s*<\/\s*template\s*>\s*/i.test(node.raw));
|
|
@@ -49,7 +49,9 @@ const parse = (rawCode, options) => {
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
exports.parse = parse;
|
|
52
|
-
function traverse(
|
|
52
|
+
function traverse(
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
54
|
+
rootNode, parentNode = null, rawHtml, options) {
|
|
53
55
|
const nodeList = [];
|
|
54
56
|
if (rootNode.type !== 'VElement') {
|
|
55
57
|
return [];
|
|
@@ -71,7 +73,13 @@ function traverse(rootNode, parentNode = null, rawHtml, options) {
|
|
|
71
73
|
}
|
|
72
74
|
return nodeList;
|
|
73
75
|
}
|
|
74
|
-
function nodeize(
|
|
76
|
+
function nodeize(
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
78
|
+
originNode,
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
80
|
+
prevNode,
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
82
|
+
parentNode, rawHtml, options) {
|
|
75
83
|
const nextNode = null;
|
|
76
84
|
const startOffset = originNode.range[0];
|
|
77
85
|
const endOffset = originNode.range[1];
|
|
@@ -79,7 +87,7 @@ function nodeize(originNode, prevNode, parentNode, rawHtml, options) {
|
|
|
79
87
|
const endLine = originNode.loc.end.line;
|
|
80
88
|
const startCol = originNode.loc.start.column + 1;
|
|
81
89
|
const endCol = originNode.loc.end.column + 1;
|
|
82
|
-
const raw = rawHtml.slice(startOffset, endOffset
|
|
90
|
+
const raw = rawHtml.slice(startOffset, endOffset !== null && endOffset !== void 0 ? endOffset : startOffset);
|
|
83
91
|
switch (originNode.type) {
|
|
84
92
|
case 'VText': {
|
|
85
93
|
const node = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/vue-parser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
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.
|
|
20
|
-
"@markuplint/ml-ast": "3.
|
|
21
|
-
"@markuplint/parser-utils": "3.
|
|
19
|
+
"@markuplint/html-parser": "3.6.0",
|
|
20
|
+
"@markuplint/ml-ast": "3.1.0",
|
|
21
|
+
"@markuplint/parser-utils": "3.6.0",
|
|
22
22
|
"tslib": "^2.4.1",
|
|
23
23
|
"vue-eslint-parser": "^9.1.0"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "715dd53d3b1064a9bcf616c1533921cad9e3b187"
|
|
26
26
|
}
|