svg-eslint-parser 0.0.0 → 0.0.2
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.md +7 -1
- package/dist/index.cjs +265 -46
- package/dist/index.d.cts +78 -9
- package/dist/index.d.ts +78 -9
- package/dist/index.js +250 -46
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
8
|
var name = "svg-eslint-parser";
|
|
9
|
-
var version = "0.0.
|
|
9
|
+
var version = "0.0.2";
|
|
10
10
|
|
|
11
11
|
// src/meta.ts
|
|
12
12
|
var meta = {
|
|
@@ -28,22 +28,178 @@ var ParseError = class extends SyntaxError {
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
// src/constants/char.ts
|
|
32
|
-
var SPECIAL_CHAR = {
|
|
33
|
-
newline: "\n",
|
|
34
|
-
return: "\r",
|
|
35
|
-
space: " ",
|
|
36
|
-
tab: " "
|
|
37
|
-
};
|
|
38
|
-
|
|
39
31
|
// src/constants/parse.ts
|
|
40
32
|
var COMMENT_START = "<!--";
|
|
41
33
|
var COMMENT_END = "-->";
|
|
42
34
|
var RE_OPEN_TAG_START = /^<\w/;
|
|
43
35
|
var RE_OPEN_TAG_NAME = /^<(\S+)/;
|
|
44
36
|
var RE_CLOSE_TAG_NAME = /^<\/((?:.|\n)*)>$/;
|
|
37
|
+
var RE_INCOMPLETE_CLOSING_TAG = /<\/[^>]+$/;
|
|
38
|
+
|
|
39
|
+
// src/constants/nodeTypes.ts
|
|
40
|
+
var NodeTypes = /* @__PURE__ */ ((NodeTypes2) => {
|
|
41
|
+
NodeTypes2["Program"] = "Program";
|
|
42
|
+
NodeTypes2["Document"] = "Document";
|
|
43
|
+
NodeTypes2["Text"] = "Text";
|
|
44
|
+
NodeTypes2["XMLDeclaration"] = "XMLDeclaration";
|
|
45
|
+
NodeTypes2["Doctype"] = "Doctype";
|
|
46
|
+
NodeTypes2["DoctypeOpen"] = "DoctypeOpen";
|
|
47
|
+
NodeTypes2["DoctypeClose"] = "DoctypeClose";
|
|
48
|
+
NodeTypes2["DoctypeAttribute"] = "DoctypeAttribute";
|
|
49
|
+
NodeTypes2["DoctypeAttributeValue"] = "DoctypeAttributeValue";
|
|
50
|
+
NodeTypes2["DoctypeAttributeWrapperEnd"] = "DoctypeAttributeWrapperEnd";
|
|
51
|
+
NodeTypes2["DoctypeAttributeWrapperStart"] = "DoctypeAttributeWrapperStart";
|
|
52
|
+
NodeTypes2["Tag"] = "Tag";
|
|
53
|
+
NodeTypes2["OpenTagStart"] = "OpenTagStart";
|
|
54
|
+
NodeTypes2["OpenTagEnd"] = "OpenTagEnd";
|
|
55
|
+
NodeTypes2["CloseTag"] = "CloseTag";
|
|
56
|
+
NodeTypes2["Comment"] = "Comment";
|
|
57
|
+
NodeTypes2["CommentOpen"] = "CommentOpen";
|
|
58
|
+
NodeTypes2["CommentClose"] = "CommentClose";
|
|
59
|
+
NodeTypes2["CommentContent"] = "CommentContent";
|
|
60
|
+
NodeTypes2["Attribute"] = "Attribute";
|
|
61
|
+
NodeTypes2["AttributeKey"] = "AttributeKey";
|
|
62
|
+
NodeTypes2["AttributeValue"] = "AttributeValue";
|
|
63
|
+
NodeTypes2["AttributeValueWrapperStart"] = "AttributeValueWrapperStart";
|
|
64
|
+
NodeTypes2["AttributeValueWrapperEnd"] = "AttributeValueWrapperEnd";
|
|
65
|
+
return NodeTypes2;
|
|
66
|
+
})(NodeTypes || {});
|
|
67
|
+
|
|
68
|
+
// src/constants/tokenTypes.ts
|
|
69
|
+
var TokenTypes = /* @__PURE__ */ ((TokenTypes2) => {
|
|
70
|
+
TokenTypes2["Program"] = "Program";
|
|
71
|
+
TokenTypes2["Document"] = "Document";
|
|
72
|
+
TokenTypes2["Text"] = "Text";
|
|
73
|
+
TokenTypes2["Doctype"] = "Doctype";
|
|
74
|
+
TokenTypes2["DoctypeOpen"] = "DoctypeOpen";
|
|
75
|
+
TokenTypes2["DoctypeClose"] = "DoctypeClose";
|
|
76
|
+
TokenTypes2["DoctypeAttributeValue"] = "DoctypeAttributeValue";
|
|
77
|
+
TokenTypes2["DoctypeAttributeWrapperStart"] = "DoctypeAttributeWrapperStart";
|
|
78
|
+
TokenTypes2["DoctypeAttributeWrapperEnd"] = "DoctypeAttributeWrapperEnd";
|
|
79
|
+
TokenTypes2["Tag"] = "Tag";
|
|
80
|
+
TokenTypes2["OpenTagStart"] = "OpenTagStart";
|
|
81
|
+
TokenTypes2["OpenTagEnd"] = "OpenTagEnd";
|
|
82
|
+
TokenTypes2["CloseTag"] = "CloseTag";
|
|
83
|
+
TokenTypes2["Comment"] = "Comment";
|
|
84
|
+
TokenTypes2["CommentOpen"] = "CommentOpen";
|
|
85
|
+
TokenTypes2["CommentClose"] = "CommentClose";
|
|
86
|
+
TokenTypes2["CommentContent"] = "CommentContent";
|
|
87
|
+
TokenTypes2["Attribute"] = "Attribute";
|
|
88
|
+
TokenTypes2["AttributeKey"] = "AttributeKey";
|
|
89
|
+
TokenTypes2["AttributeValue"] = "AttributeValue";
|
|
90
|
+
TokenTypes2["AttributeAssignment"] = "AttributeAssignment";
|
|
91
|
+
TokenTypes2["AttributeValueWrapperStart"] = "AttributeValueWrapperStart";
|
|
92
|
+
TokenTypes2["AttributeValueWrapperEnd"] = "AttributeValueWrapperEnd";
|
|
93
|
+
return TokenTypes2;
|
|
94
|
+
})(TokenTypes || {});
|
|
95
|
+
|
|
96
|
+
// src/constants/specialChar.ts
|
|
97
|
+
var SPECIAL_CHAR = {
|
|
98
|
+
closingCorner: `>`,
|
|
99
|
+
colon: `:`,
|
|
100
|
+
comma: `,`,
|
|
101
|
+
doubleQuote: `"`,
|
|
102
|
+
equal: `=`,
|
|
103
|
+
exclamation: `!`,
|
|
104
|
+
hyphen: `-`,
|
|
105
|
+
newline: `
|
|
106
|
+
`,
|
|
107
|
+
openingCorner: `<`,
|
|
108
|
+
question: `?`,
|
|
109
|
+
return: `\r`,
|
|
110
|
+
singleQuote: `'`,
|
|
111
|
+
slash: `/`,
|
|
112
|
+
space: ` `,
|
|
113
|
+
tab: ` `
|
|
114
|
+
};
|
|
45
115
|
|
|
46
116
|
// src/constants/svgElements.ts
|
|
117
|
+
var SVG_ELEMENTS = /* @__PURE__ */ new Set([
|
|
118
|
+
"a",
|
|
119
|
+
"animate",
|
|
120
|
+
"animateMotion",
|
|
121
|
+
"animateTransform",
|
|
122
|
+
"circle",
|
|
123
|
+
"clipPath",
|
|
124
|
+
// not listed in mdn docs
|
|
125
|
+
"color-profile",
|
|
126
|
+
"defs",
|
|
127
|
+
"desc",
|
|
128
|
+
"ellipse",
|
|
129
|
+
"feBlend",
|
|
130
|
+
"feColorMatrix",
|
|
131
|
+
"feComponentTransfer",
|
|
132
|
+
"feComposite",
|
|
133
|
+
"feConvolveMatrix",
|
|
134
|
+
"feDiffuseLighting",
|
|
135
|
+
"feDisplacementMap",
|
|
136
|
+
"feDistantLight",
|
|
137
|
+
"feDropShadow",
|
|
138
|
+
"feFlood",
|
|
139
|
+
"feFuncA",
|
|
140
|
+
"feFuncB",
|
|
141
|
+
"feFuncG",
|
|
142
|
+
"feFuncR",
|
|
143
|
+
"feGaussianBlur",
|
|
144
|
+
"feImage",
|
|
145
|
+
"feMerge",
|
|
146
|
+
"feMergeNode",
|
|
147
|
+
"feMorphology",
|
|
148
|
+
"feOffset",
|
|
149
|
+
"fePointLight",
|
|
150
|
+
"feSpecularLighting",
|
|
151
|
+
"feSpotLight",
|
|
152
|
+
"feTile",
|
|
153
|
+
"feTurbulence",
|
|
154
|
+
"filter",
|
|
155
|
+
"foreignObject",
|
|
156
|
+
"g",
|
|
157
|
+
"image",
|
|
158
|
+
"line",
|
|
159
|
+
"linearGradient",
|
|
160
|
+
"marker",
|
|
161
|
+
"mask",
|
|
162
|
+
"metadata",
|
|
163
|
+
"mpath",
|
|
164
|
+
"path",
|
|
165
|
+
"pattern",
|
|
166
|
+
"polygon",
|
|
167
|
+
"polyline",
|
|
168
|
+
"radialGradient",
|
|
169
|
+
"rect",
|
|
170
|
+
"script",
|
|
171
|
+
"set",
|
|
172
|
+
"stop",
|
|
173
|
+
"style",
|
|
174
|
+
"svg",
|
|
175
|
+
"switch",
|
|
176
|
+
"symbol",
|
|
177
|
+
"text",
|
|
178
|
+
"textPath",
|
|
179
|
+
"title",
|
|
180
|
+
"tspan",
|
|
181
|
+
"use",
|
|
182
|
+
"view"
|
|
183
|
+
]);
|
|
184
|
+
var DEPRECATED_SVG_ELEMENTS = /* @__PURE__ */ new Set([
|
|
185
|
+
"altGlyph",
|
|
186
|
+
"altGlyphDef",
|
|
187
|
+
"altGlyphItem",
|
|
188
|
+
"animateColor",
|
|
189
|
+
"cursor",
|
|
190
|
+
"font",
|
|
191
|
+
"font-face",
|
|
192
|
+
"font-face-format",
|
|
193
|
+
"font-face-name",
|
|
194
|
+
"font-face-src",
|
|
195
|
+
"font-face-uri",
|
|
196
|
+
"glyph",
|
|
197
|
+
"glyphRef",
|
|
198
|
+
"hkern",
|
|
199
|
+
"missing-glyph",
|
|
200
|
+
"tref",
|
|
201
|
+
"vkern"
|
|
202
|
+
]);
|
|
47
203
|
var SELF_CLOSING_ELEMENTS = /* @__PURE__ */ new Set([
|
|
48
204
|
"animate",
|
|
49
205
|
"animateMotion",
|
|
@@ -79,6 +235,43 @@ var SELF_CLOSING_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
79
235
|
"view"
|
|
80
236
|
]);
|
|
81
237
|
|
|
238
|
+
// src/constants/tokenizerContextTypes.ts
|
|
239
|
+
var TokenizerContextTypes = /* @__PURE__ */ ((TokenizerContextTypes2) => {
|
|
240
|
+
TokenizerContextTypes2["Data"] = "Data";
|
|
241
|
+
TokenizerContextTypes2["OpenTagStart"] = "OpenTagStart";
|
|
242
|
+
TokenizerContextTypes2["OpenTagEnd"] = "OpenTagEnd";
|
|
243
|
+
TokenizerContextTypes2["CloseTag"] = "CloseTag";
|
|
244
|
+
TokenizerContextTypes2["Attributes"] = "Attributes";
|
|
245
|
+
TokenizerContextTypes2["AttributeKey"] = "AttributeKey";
|
|
246
|
+
TokenizerContextTypes2["AttributeValue"] = "AttributeValue";
|
|
247
|
+
TokenizerContextTypes2["AttributeValueBare"] = "AttributeValueBare";
|
|
248
|
+
TokenizerContextTypes2["AttributeValueWrapped"] = "AttributeValueWrapped";
|
|
249
|
+
TokenizerContextTypes2["CommentContent"] = "CommentContent";
|
|
250
|
+
TokenizerContextTypes2["CommentOpen"] = "CommentOpen";
|
|
251
|
+
TokenizerContextTypes2["CommentClose"] = "CommentClose";
|
|
252
|
+
TokenizerContextTypes2["DoctypeOpen"] = "DoctypeOpen";
|
|
253
|
+
TokenizerContextTypes2["DoctypeClose"] = "DoctypeClose";
|
|
254
|
+
TokenizerContextTypes2["DoctypeAttributes"] = "DoctypeAttributes";
|
|
255
|
+
TokenizerContextTypes2["DoctypeAttributeBare"] = "DoctypeAttributeBare";
|
|
256
|
+
TokenizerContextTypes2["DoctypeAttributeWrapped"] = "DoctypeAttributeWrapped";
|
|
257
|
+
return TokenizerContextTypes2;
|
|
258
|
+
})(TokenizerContextTypes || {});
|
|
259
|
+
|
|
260
|
+
// src/constants/constructTreeContextTypes.ts
|
|
261
|
+
var ConstructTreeContextTypes = /* @__PURE__ */ ((ConstructTreeContextTypes2) => {
|
|
262
|
+
ConstructTreeContextTypes2["Tag"] = "Tag";
|
|
263
|
+
ConstructTreeContextTypes2["TagName"] = "TagName";
|
|
264
|
+
ConstructTreeContextTypes2["TagContent"] = "TagContent";
|
|
265
|
+
ConstructTreeContextTypes2["Attribute"] = "Attribute";
|
|
266
|
+
ConstructTreeContextTypes2["Attributes"] = "Attributes";
|
|
267
|
+
ConstructTreeContextTypes2["AttributeValue"] = "AttributeValue";
|
|
268
|
+
ConstructTreeContextTypes2["Doctype"] = "Doctype";
|
|
269
|
+
ConstructTreeContextTypes2["DoctypeAttribute"] = "DoctypeAttribute";
|
|
270
|
+
ConstructTreeContextTypes2["DoctypeAttributes"] = "DoctypeAttributes";
|
|
271
|
+
ConstructTreeContextTypes2["Comment"] = "Comment";
|
|
272
|
+
return ConstructTreeContextTypes2;
|
|
273
|
+
})(ConstructTreeContextTypes || {});
|
|
274
|
+
|
|
82
275
|
// src/utils/firstLast.ts
|
|
83
276
|
function first(items) {
|
|
84
277
|
return items[0];
|
|
@@ -181,6 +374,12 @@ function createNodeFrom(token) {
|
|
|
181
374
|
return result;
|
|
182
375
|
}
|
|
183
376
|
|
|
377
|
+
// src/utils/getLastAttribute.ts
|
|
378
|
+
function getLastAttribute(state) {
|
|
379
|
+
const attributes = state.currentNode.attributes;
|
|
380
|
+
return last(attributes);
|
|
381
|
+
}
|
|
382
|
+
|
|
184
383
|
// src/utils/parseOpenTagName.ts
|
|
185
384
|
function parseOpenTagName(openTagStartTokenContent) {
|
|
186
385
|
const match = openTagStartTokenContent.match(RE_OPEN_TAG_NAME);
|
|
@@ -217,12 +416,12 @@ function calculateTokenLocation(source, range) {
|
|
|
217
416
|
function calculateTokenCharactersRange(state, options) {
|
|
218
417
|
const startPosition = state.sourceCode.index() - (state.accumulatedContent.length() - 1) - state.decisionBuffer.length();
|
|
219
418
|
let endPosition;
|
|
220
|
-
if (options.keepBuffer) {
|
|
419
|
+
if (!options.keepBuffer) {
|
|
221
420
|
endPosition = state.sourceCode.index() - state.decisionBuffer.length();
|
|
222
421
|
} else {
|
|
223
422
|
endPosition = state.sourceCode.index();
|
|
224
423
|
}
|
|
225
|
-
return [startPosition, endPosition];
|
|
424
|
+
return [startPosition, endPosition + 1];
|
|
226
425
|
}
|
|
227
426
|
|
|
228
427
|
// src/utils/calculateTokenPosition.ts
|
|
@@ -416,10 +615,6 @@ function construct5(token, state) {
|
|
|
416
615
|
state.caretPosition++;
|
|
417
616
|
return state;
|
|
418
617
|
}
|
|
419
|
-
function getLastAttribute(state) {
|
|
420
|
-
const attributes = state.currentNode.attributes;
|
|
421
|
-
return last(attributes);
|
|
422
|
-
}
|
|
423
618
|
function handleOpenTagEnd2(state) {
|
|
424
619
|
state.currentContext = state.currentContext.parentRef;
|
|
425
620
|
return state;
|
|
@@ -601,23 +796,19 @@ function construct8(token, state) {
|
|
|
601
796
|
state.caretPosition++;
|
|
602
797
|
return state;
|
|
603
798
|
}
|
|
604
|
-
function getLastAttribute2(state) {
|
|
605
|
-
const attributes = state.currentNode.attributes;
|
|
606
|
-
return last(attributes);
|
|
607
|
-
}
|
|
608
799
|
function handleValueEnd(state) {
|
|
609
800
|
state.currentContext = state.currentContext.parentRef;
|
|
610
801
|
return state;
|
|
611
802
|
}
|
|
612
803
|
function handleAttributeValue(state, token) {
|
|
613
|
-
const attribute =
|
|
804
|
+
const attribute = getLastAttribute(state);
|
|
614
805
|
attribute.value = createNodeFrom(token);
|
|
615
806
|
updateNodeEnd(attribute, token);
|
|
616
807
|
state.caretPosition++;
|
|
617
808
|
return state;
|
|
618
809
|
}
|
|
619
810
|
function handleAttributeValueWrapperStart(state, token) {
|
|
620
|
-
const attribute =
|
|
811
|
+
const attribute = getLastAttribute(state);
|
|
621
812
|
attribute.startWrapper = createNodeFrom(token);
|
|
622
813
|
if (!attribute.key) {
|
|
623
814
|
attribute.range = cloneRange(token.range);
|
|
@@ -627,7 +818,7 @@ function handleAttributeValueWrapperStart(state, token) {
|
|
|
627
818
|
return state;
|
|
628
819
|
}
|
|
629
820
|
function handleAttributeValueWrapperEnd(state, token) {
|
|
630
|
-
const attribute =
|
|
821
|
+
const attribute = getLastAttribute(state);
|
|
631
822
|
attribute.endWrapper = createNodeFrom(token);
|
|
632
823
|
updateNodeEnd(attribute, token);
|
|
633
824
|
state.caretPosition++;
|
|
@@ -655,16 +846,12 @@ function construct9(token, state) {
|
|
|
655
846
|
state.caretPosition++;
|
|
656
847
|
return state;
|
|
657
848
|
}
|
|
658
|
-
function getLastAttribute3(state) {
|
|
659
|
-
const attributes = state.currentNode.attributes;
|
|
660
|
-
return last(attributes);
|
|
661
|
-
}
|
|
662
849
|
function handleDoctypeClose2(state) {
|
|
663
850
|
state.currentContext = state.currentContext.parentRef;
|
|
664
851
|
return state;
|
|
665
852
|
}
|
|
666
853
|
function handleDoctypeAttributeWrapperStart(state, token) {
|
|
667
|
-
const attribute =
|
|
854
|
+
const attribute = getLastAttribute(state);
|
|
668
855
|
if (attribute.value !== void 0) {
|
|
669
856
|
state.currentContext = state.currentContext.parentRef;
|
|
670
857
|
return state;
|
|
@@ -675,7 +862,7 @@ function handleDoctypeAttributeWrapperStart(state, token) {
|
|
|
675
862
|
return state;
|
|
676
863
|
}
|
|
677
864
|
function handleDoctypeAttributeWrapperEnd(state, token) {
|
|
678
|
-
const attribute =
|
|
865
|
+
const attribute = getLastAttribute(state);
|
|
679
866
|
attribute.endWrapper = createNodeFrom(token);
|
|
680
867
|
updateNodeEnd(attribute, token);
|
|
681
868
|
state.currentContext = state.currentContext.parentRef;
|
|
@@ -683,7 +870,7 @@ function handleDoctypeAttributeWrapperEnd(state, token) {
|
|
|
683
870
|
return state;
|
|
684
871
|
}
|
|
685
872
|
function handleDoctypeAttributeValue(state, token) {
|
|
686
|
-
const attribute =
|
|
873
|
+
const attribute = getLastAttribute(state);
|
|
687
874
|
if (attribute.value !== void 0) {
|
|
688
875
|
state.currentContext = state.currentContext.parentRef;
|
|
689
876
|
return state;
|
|
@@ -855,7 +1042,7 @@ function parse(chars, state) {
|
|
|
855
1042
|
if (value === "</") {
|
|
856
1043
|
return parseOpeningCornerBraceWithSlash(state);
|
|
857
1044
|
}
|
|
858
|
-
if (value ===
|
|
1045
|
+
if (value === SPECIAL_CHAR.openingCorner || value === "<!" || value === "<!-") {
|
|
859
1046
|
return state.sourceCode.next();
|
|
860
1047
|
}
|
|
861
1048
|
if (value === COMMENT_START) {
|
|
@@ -952,7 +1139,7 @@ __export(closeTag_exports, {
|
|
|
952
1139
|
});
|
|
953
1140
|
function parse2(chars, state) {
|
|
954
1141
|
const value = chars.value();
|
|
955
|
-
if (value ===
|
|
1142
|
+
if (value === SPECIAL_CHAR.closingCorner) {
|
|
956
1143
|
return parseClosingCornerBrace(state);
|
|
957
1144
|
}
|
|
958
1145
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -980,10 +1167,10 @@ __export(attributes_exports2, {
|
|
|
980
1167
|
});
|
|
981
1168
|
function parse3(chars, state) {
|
|
982
1169
|
const value = chars.value();
|
|
983
|
-
if (value ===
|
|
1170
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) {
|
|
984
1171
|
return parseTagEnd(state);
|
|
985
1172
|
}
|
|
986
|
-
if (value ===
|
|
1173
|
+
if (value === SPECIAL_CHAR.equal) {
|
|
987
1174
|
return parseEqual(state);
|
|
988
1175
|
}
|
|
989
1176
|
if (!isWhitespace(value)) {
|
|
@@ -1026,7 +1213,7 @@ __export(openTagEnd_exports, {
|
|
|
1026
1213
|
parse: () => parse4
|
|
1027
1214
|
});
|
|
1028
1215
|
function parse4(chars, state) {
|
|
1029
|
-
if (chars.value() ===
|
|
1216
|
+
if (chars.value() === SPECIAL_CHAR.closingCorner) {
|
|
1030
1217
|
return parseClosingCornerBrace2(state);
|
|
1031
1218
|
}
|
|
1032
1219
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1058,7 +1245,7 @@ function parse5(chars, state) {
|
|
|
1058
1245
|
if (isWhitespace(value)) {
|
|
1059
1246
|
return parseWhitespace(state);
|
|
1060
1247
|
}
|
|
1061
|
-
if (value ===
|
|
1248
|
+
if (value === SPECIAL_CHAR.closingCorner) {
|
|
1062
1249
|
return parseClosingCornerBrace3(state);
|
|
1063
1250
|
}
|
|
1064
1251
|
state.decisionBuffer.clear();
|
|
@@ -1121,7 +1308,7 @@ function parse7(chars, state) {
|
|
|
1121
1308
|
}
|
|
1122
1309
|
function isKeyBreak(chars) {
|
|
1123
1310
|
const value = chars.value();
|
|
1124
|
-
return value ===
|
|
1311
|
+
return value === SPECIAL_CHAR.equal || value === SPECIAL_CHAR.slash || value === SPECIAL_CHAR.closingCorner || isWhitespace(value);
|
|
1125
1312
|
}
|
|
1126
1313
|
function parseKeyEnd(state) {
|
|
1127
1314
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
@@ -1142,10 +1329,11 @@ __export(openTagStart_exports, {
|
|
|
1142
1329
|
parse: () => parse8
|
|
1143
1330
|
});
|
|
1144
1331
|
function parse8(chars, state) {
|
|
1145
|
-
|
|
1332
|
+
const value = chars.value();
|
|
1333
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) {
|
|
1146
1334
|
return parseTagEnd2(state);
|
|
1147
1335
|
}
|
|
1148
|
-
if (isWhitespace(
|
|
1336
|
+
if (isWhitespace(value)) {
|
|
1149
1337
|
return parseWhitespace2(state);
|
|
1150
1338
|
}
|
|
1151
1339
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1189,10 +1377,10 @@ __export(attributeValue_exports2, {
|
|
|
1189
1377
|
});
|
|
1190
1378
|
function parse9(chars, state) {
|
|
1191
1379
|
const value = chars.value();
|
|
1192
|
-
if (value ===
|
|
1380
|
+
if (value === SPECIAL_CHAR.doubleQuote || value === SPECIAL_CHAR.singleQuote) {
|
|
1193
1381
|
return parseWrapper(state);
|
|
1194
1382
|
}
|
|
1195
|
-
if (value ===
|
|
1383
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) {
|
|
1196
1384
|
return parseTagEnd3(state);
|
|
1197
1385
|
}
|
|
1198
1386
|
if (!isWhitespace(value)) {
|
|
@@ -1237,7 +1425,7 @@ __export(commentContent_exports, {
|
|
|
1237
1425
|
});
|
|
1238
1426
|
function parse10(chars, state) {
|
|
1239
1427
|
const value = chars.value();
|
|
1240
|
-
if (value ===
|
|
1428
|
+
if (value === SPECIAL_CHAR.hyphen || value === "--") {
|
|
1241
1429
|
return state.sourceCode.next();
|
|
1242
1430
|
}
|
|
1243
1431
|
if (value === COMMENT_END) {
|
|
@@ -1275,10 +1463,10 @@ __export(doctypeAttributes_exports2, {
|
|
|
1275
1463
|
});
|
|
1276
1464
|
function parse11(chars, state) {
|
|
1277
1465
|
const value = chars.value();
|
|
1278
|
-
if (value ===
|
|
1466
|
+
if (value === SPECIAL_CHAR.doubleQuote || value === SPECIAL_CHAR.singleQuote) {
|
|
1279
1467
|
return parseWrapper2(state);
|
|
1280
1468
|
}
|
|
1281
|
-
if (value ===
|
|
1469
|
+
if (value === SPECIAL_CHAR.closingCorner) {
|
|
1282
1470
|
return parseClosingCornerBrace4(state);
|
|
1283
1471
|
}
|
|
1284
1472
|
if (!isWhitespace(value)) {
|
|
@@ -1323,7 +1511,7 @@ __export(attributeValueBare_exports, {
|
|
|
1323
1511
|
});
|
|
1324
1512
|
function parse12(chars, state) {
|
|
1325
1513
|
const value = chars.value();
|
|
1326
|
-
if (isWhitespace(value) || value ===
|
|
1514
|
+
if (isWhitespace(value) || value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) {
|
|
1327
1515
|
return parseValueEnd(state);
|
|
1328
1516
|
}
|
|
1329
1517
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1350,7 +1538,7 @@ __export(doctypeAttributeBare_exports, {
|
|
|
1350
1538
|
});
|
|
1351
1539
|
function parse13(chars, state) {
|
|
1352
1540
|
const value = chars.value();
|
|
1353
|
-
if (isWhitespace(value) || value ===
|
|
1541
|
+
if (isWhitespace(value) || value === SPECIAL_CHAR.closingCorner) {
|
|
1354
1542
|
return parseAttributeEnd(state);
|
|
1355
1543
|
}
|
|
1356
1544
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1578,11 +1766,11 @@ import { unionWith } from "eslint-visitor-keys";
|
|
|
1578
1766
|
var keys = {
|
|
1579
1767
|
Program: ["body"],
|
|
1580
1768
|
Document: ["children"],
|
|
1769
|
+
XMLDeclaration: [],
|
|
1581
1770
|
Doctype: ["open", "close", "attributes"],
|
|
1582
1771
|
DoctypeOpen: [],
|
|
1583
1772
|
DoctypeClose: [],
|
|
1584
1773
|
DoctypeAttribute: ["key"],
|
|
1585
|
-
DoctypeAttributeKey: [],
|
|
1586
1774
|
DoctypeAttributeValue: [],
|
|
1587
1775
|
DoctypeAttributeWrapperEnd: [],
|
|
1588
1776
|
DoctypeAttributeWrapperStart: [],
|
|
@@ -1671,11 +1859,27 @@ function parseSVG(code, options = {}) {
|
|
|
1671
1859
|
}
|
|
1672
1860
|
var name2 = meta.name;
|
|
1673
1861
|
var VisitorKeys = visitorKeys;
|
|
1862
|
+
var parse17 = parseSVG;
|
|
1674
1863
|
export {
|
|
1864
|
+
COMMENT_END,
|
|
1865
|
+
COMMENT_START,
|
|
1866
|
+
ConstructTreeContextTypes,
|
|
1867
|
+
DEPRECATED_SVG_ELEMENTS,
|
|
1868
|
+
NodeTypes,
|
|
1675
1869
|
ParseError,
|
|
1870
|
+
RE_CLOSE_TAG_NAME,
|
|
1871
|
+
RE_INCOMPLETE_CLOSING_TAG,
|
|
1872
|
+
RE_OPEN_TAG_NAME,
|
|
1873
|
+
RE_OPEN_TAG_START,
|
|
1874
|
+
SELF_CLOSING_ELEMENTS,
|
|
1875
|
+
SPECIAL_CHAR,
|
|
1876
|
+
SVG_ELEMENTS,
|
|
1877
|
+
TokenTypes,
|
|
1878
|
+
TokenizerContextTypes,
|
|
1676
1879
|
VisitorKeys,
|
|
1677
1880
|
meta,
|
|
1678
1881
|
name2 as name,
|
|
1882
|
+
parse17 as parse,
|
|
1679
1883
|
parseForESLint,
|
|
1680
1884
|
parseSVG
|
|
1681
1885
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svg-eslint-parser",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"description": "An SVG parser that produces output compatible with ESLint.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"eslint-parser",
|
|
@@ -60,12 +60,15 @@
|
|
|
60
60
|
"node": ">=18.18.0"
|
|
61
61
|
},
|
|
62
62
|
"nano-staged": {
|
|
63
|
-
"*.{js,ts,mjs,cjs,json,md,yml,yaml}": "eslint --fix"
|
|
63
|
+
"*.{js,ts,mjs,cjs,vue,json,md,yml,yaml}": "eslint --fix"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "tsup",
|
|
67
67
|
"coverage": "vitest --coverage",
|
|
68
|
+
"deploy": "run-s build docs:build",
|
|
68
69
|
"dev": "tsup --watch src",
|
|
70
|
+
"docs:build": "pnpm -C docs run build",
|
|
71
|
+
"docs:dev": "pnpm -C docs run dev",
|
|
69
72
|
"lint": "eslint .",
|
|
70
73
|
"release": "run-s release:check release:publish",
|
|
71
74
|
"release:check": "run-s lint typecheck test",
|