svg-eslint-parser 0.0.0 → 0.0.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/dist/index.cjs +53 -46
- package/dist/index.d.cts +13 -8
- package/dist/index.d.ts +13 -8
- package/dist/index.js +53 -46
- package/package.json +5 -2
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
31
31
|
|
|
32
32
|
// package.json
|
|
33
33
|
var name = "svg-eslint-parser";
|
|
34
|
-
var version = "0.0.
|
|
34
|
+
var version = "0.0.1";
|
|
35
35
|
|
|
36
36
|
// src/meta.ts
|
|
37
37
|
var meta = {
|
|
@@ -53,14 +53,6 @@ var ParseError = class extends SyntaxError {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
// src/constants/char.ts
|
|
57
|
-
var SPECIAL_CHAR = {
|
|
58
|
-
newline: "\n",
|
|
59
|
-
return: "\r",
|
|
60
|
-
space: " ",
|
|
61
|
-
tab: " "
|
|
62
|
-
};
|
|
63
|
-
|
|
64
56
|
// src/constants/parse.ts
|
|
65
57
|
var COMMENT_START = "<!--";
|
|
66
58
|
var COMMENT_END = "-->";
|
|
@@ -68,6 +60,26 @@ var RE_OPEN_TAG_START = /^<\w/;
|
|
|
68
60
|
var RE_OPEN_TAG_NAME = /^<(\S+)/;
|
|
69
61
|
var RE_CLOSE_TAG_NAME = /^<\/((?:.|\n)*)>$/;
|
|
70
62
|
|
|
63
|
+
// src/constants/specialChar.ts
|
|
64
|
+
var SPECIAL_CHAR = {
|
|
65
|
+
closingCorner: `>`,
|
|
66
|
+
colon: `:`,
|
|
67
|
+
comma: `,`,
|
|
68
|
+
doubleQuote: `"`,
|
|
69
|
+
equal: `=`,
|
|
70
|
+
exclamation: `!`,
|
|
71
|
+
hyphen: `-`,
|
|
72
|
+
newline: `
|
|
73
|
+
`,
|
|
74
|
+
openingCorner: `<`,
|
|
75
|
+
question: `?`,
|
|
76
|
+
return: `\r`,
|
|
77
|
+
singleQuote: `'`,
|
|
78
|
+
slash: `/`,
|
|
79
|
+
space: ` `,
|
|
80
|
+
tab: ` `
|
|
81
|
+
};
|
|
82
|
+
|
|
71
83
|
// src/constants/svgElements.ts
|
|
72
84
|
var SELF_CLOSING_ELEMENTS = /* @__PURE__ */ new Set([
|
|
73
85
|
"animate",
|
|
@@ -206,6 +218,12 @@ function createNodeFrom(token) {
|
|
|
206
218
|
return result;
|
|
207
219
|
}
|
|
208
220
|
|
|
221
|
+
// src/utils/getLastAttribute.ts
|
|
222
|
+
function getLastAttribute(state) {
|
|
223
|
+
const attributes = state.currentNode.attributes;
|
|
224
|
+
return last(attributes);
|
|
225
|
+
}
|
|
226
|
+
|
|
209
227
|
// src/utils/parseOpenTagName.ts
|
|
210
228
|
function parseOpenTagName(openTagStartTokenContent) {
|
|
211
229
|
const match = openTagStartTokenContent.match(RE_OPEN_TAG_NAME);
|
|
@@ -242,12 +260,12 @@ function calculateTokenLocation(source, range) {
|
|
|
242
260
|
function calculateTokenCharactersRange(state, options) {
|
|
243
261
|
const startPosition = state.sourceCode.index() - (state.accumulatedContent.length() - 1) - state.decisionBuffer.length();
|
|
244
262
|
let endPosition;
|
|
245
|
-
if (options.keepBuffer) {
|
|
263
|
+
if (!options.keepBuffer) {
|
|
246
264
|
endPosition = state.sourceCode.index() - state.decisionBuffer.length();
|
|
247
265
|
} else {
|
|
248
266
|
endPosition = state.sourceCode.index();
|
|
249
267
|
}
|
|
250
|
-
return [startPosition, endPosition];
|
|
268
|
+
return [startPosition, endPosition + 1];
|
|
251
269
|
}
|
|
252
270
|
|
|
253
271
|
// src/utils/calculateTokenPosition.ts
|
|
@@ -441,10 +459,6 @@ function construct5(token, state) {
|
|
|
441
459
|
state.caretPosition++;
|
|
442
460
|
return state;
|
|
443
461
|
}
|
|
444
|
-
function getLastAttribute(state) {
|
|
445
|
-
const attributes = state.currentNode.attributes;
|
|
446
|
-
return last(attributes);
|
|
447
|
-
}
|
|
448
462
|
function handleOpenTagEnd2(state) {
|
|
449
463
|
state.currentContext = state.currentContext.parentRef;
|
|
450
464
|
return state;
|
|
@@ -626,23 +640,19 @@ function construct8(token, state) {
|
|
|
626
640
|
state.caretPosition++;
|
|
627
641
|
return state;
|
|
628
642
|
}
|
|
629
|
-
function getLastAttribute2(state) {
|
|
630
|
-
const attributes = state.currentNode.attributes;
|
|
631
|
-
return last(attributes);
|
|
632
|
-
}
|
|
633
643
|
function handleValueEnd(state) {
|
|
634
644
|
state.currentContext = state.currentContext.parentRef;
|
|
635
645
|
return state;
|
|
636
646
|
}
|
|
637
647
|
function handleAttributeValue(state, token) {
|
|
638
|
-
const attribute =
|
|
648
|
+
const attribute = getLastAttribute(state);
|
|
639
649
|
attribute.value = createNodeFrom(token);
|
|
640
650
|
updateNodeEnd(attribute, token);
|
|
641
651
|
state.caretPosition++;
|
|
642
652
|
return state;
|
|
643
653
|
}
|
|
644
654
|
function handleAttributeValueWrapperStart(state, token) {
|
|
645
|
-
const attribute =
|
|
655
|
+
const attribute = getLastAttribute(state);
|
|
646
656
|
attribute.startWrapper = createNodeFrom(token);
|
|
647
657
|
if (!attribute.key) {
|
|
648
658
|
attribute.range = cloneRange(token.range);
|
|
@@ -652,7 +662,7 @@ function handleAttributeValueWrapperStart(state, token) {
|
|
|
652
662
|
return state;
|
|
653
663
|
}
|
|
654
664
|
function handleAttributeValueWrapperEnd(state, token) {
|
|
655
|
-
const attribute =
|
|
665
|
+
const attribute = getLastAttribute(state);
|
|
656
666
|
attribute.endWrapper = createNodeFrom(token);
|
|
657
667
|
updateNodeEnd(attribute, token);
|
|
658
668
|
state.caretPosition++;
|
|
@@ -680,16 +690,12 @@ function construct9(token, state) {
|
|
|
680
690
|
state.caretPosition++;
|
|
681
691
|
return state;
|
|
682
692
|
}
|
|
683
|
-
function getLastAttribute3(state) {
|
|
684
|
-
const attributes = state.currentNode.attributes;
|
|
685
|
-
return last(attributes);
|
|
686
|
-
}
|
|
687
693
|
function handleDoctypeClose2(state) {
|
|
688
694
|
state.currentContext = state.currentContext.parentRef;
|
|
689
695
|
return state;
|
|
690
696
|
}
|
|
691
697
|
function handleDoctypeAttributeWrapperStart(state, token) {
|
|
692
|
-
const attribute =
|
|
698
|
+
const attribute = getLastAttribute(state);
|
|
693
699
|
if (attribute.value !== void 0) {
|
|
694
700
|
state.currentContext = state.currentContext.parentRef;
|
|
695
701
|
return state;
|
|
@@ -700,7 +706,7 @@ function handleDoctypeAttributeWrapperStart(state, token) {
|
|
|
700
706
|
return state;
|
|
701
707
|
}
|
|
702
708
|
function handleDoctypeAttributeWrapperEnd(state, token) {
|
|
703
|
-
const attribute =
|
|
709
|
+
const attribute = getLastAttribute(state);
|
|
704
710
|
attribute.endWrapper = createNodeFrom(token);
|
|
705
711
|
updateNodeEnd(attribute, token);
|
|
706
712
|
state.currentContext = state.currentContext.parentRef;
|
|
@@ -708,7 +714,7 @@ function handleDoctypeAttributeWrapperEnd(state, token) {
|
|
|
708
714
|
return state;
|
|
709
715
|
}
|
|
710
716
|
function handleDoctypeAttributeValue(state, token) {
|
|
711
|
-
const attribute =
|
|
717
|
+
const attribute = getLastAttribute(state);
|
|
712
718
|
if (attribute.value !== void 0) {
|
|
713
719
|
state.currentContext = state.currentContext.parentRef;
|
|
714
720
|
return state;
|
|
@@ -880,7 +886,7 @@ function parse(chars, state) {
|
|
|
880
886
|
if (value === "</") {
|
|
881
887
|
return parseOpeningCornerBraceWithSlash(state);
|
|
882
888
|
}
|
|
883
|
-
if (value ===
|
|
889
|
+
if (value === SPECIAL_CHAR.openingCorner || value === "<!" || value === "<!-") {
|
|
884
890
|
return state.sourceCode.next();
|
|
885
891
|
}
|
|
886
892
|
if (value === COMMENT_START) {
|
|
@@ -977,7 +983,7 @@ __export(closeTag_exports, {
|
|
|
977
983
|
});
|
|
978
984
|
function parse2(chars, state) {
|
|
979
985
|
const value = chars.value();
|
|
980
|
-
if (value ===
|
|
986
|
+
if (value === SPECIAL_CHAR.closingCorner) {
|
|
981
987
|
return parseClosingCornerBrace(state);
|
|
982
988
|
}
|
|
983
989
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1005,10 +1011,10 @@ __export(attributes_exports2, {
|
|
|
1005
1011
|
});
|
|
1006
1012
|
function parse3(chars, state) {
|
|
1007
1013
|
const value = chars.value();
|
|
1008
|
-
if (value ===
|
|
1014
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) {
|
|
1009
1015
|
return parseTagEnd(state);
|
|
1010
1016
|
}
|
|
1011
|
-
if (value ===
|
|
1017
|
+
if (value === SPECIAL_CHAR.equal) {
|
|
1012
1018
|
return parseEqual(state);
|
|
1013
1019
|
}
|
|
1014
1020
|
if (!isWhitespace(value)) {
|
|
@@ -1051,7 +1057,7 @@ __export(openTagEnd_exports, {
|
|
|
1051
1057
|
parse: () => parse4
|
|
1052
1058
|
});
|
|
1053
1059
|
function parse4(chars, state) {
|
|
1054
|
-
if (chars.value() ===
|
|
1060
|
+
if (chars.value() === SPECIAL_CHAR.closingCorner) {
|
|
1055
1061
|
return parseClosingCornerBrace2(state);
|
|
1056
1062
|
}
|
|
1057
1063
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1083,7 +1089,7 @@ function parse5(chars, state) {
|
|
|
1083
1089
|
if (isWhitespace(value)) {
|
|
1084
1090
|
return parseWhitespace(state);
|
|
1085
1091
|
}
|
|
1086
|
-
if (value ===
|
|
1092
|
+
if (value === SPECIAL_CHAR.closingCorner) {
|
|
1087
1093
|
return parseClosingCornerBrace3(state);
|
|
1088
1094
|
}
|
|
1089
1095
|
state.decisionBuffer.clear();
|
|
@@ -1146,7 +1152,7 @@ function parse7(chars, state) {
|
|
|
1146
1152
|
}
|
|
1147
1153
|
function isKeyBreak(chars) {
|
|
1148
1154
|
const value = chars.value();
|
|
1149
|
-
return value ===
|
|
1155
|
+
return value === SPECIAL_CHAR.equal || value === SPECIAL_CHAR.slash || value === SPECIAL_CHAR.closingCorner || isWhitespace(value);
|
|
1150
1156
|
}
|
|
1151
1157
|
function parseKeyEnd(state) {
|
|
1152
1158
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
@@ -1167,10 +1173,11 @@ __export(openTagStart_exports, {
|
|
|
1167
1173
|
parse: () => parse8
|
|
1168
1174
|
});
|
|
1169
1175
|
function parse8(chars, state) {
|
|
1170
|
-
|
|
1176
|
+
const value = chars.value();
|
|
1177
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) {
|
|
1171
1178
|
return parseTagEnd2(state);
|
|
1172
1179
|
}
|
|
1173
|
-
if (isWhitespace(
|
|
1180
|
+
if (isWhitespace(value)) {
|
|
1174
1181
|
return parseWhitespace2(state);
|
|
1175
1182
|
}
|
|
1176
1183
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1214,10 +1221,10 @@ __export(attributeValue_exports2, {
|
|
|
1214
1221
|
});
|
|
1215
1222
|
function parse9(chars, state) {
|
|
1216
1223
|
const value = chars.value();
|
|
1217
|
-
if (value ===
|
|
1224
|
+
if (value === SPECIAL_CHAR.doubleQuote || value === SPECIAL_CHAR.singleQuote) {
|
|
1218
1225
|
return parseWrapper(state);
|
|
1219
1226
|
}
|
|
1220
|
-
if (value ===
|
|
1227
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) {
|
|
1221
1228
|
return parseTagEnd3(state);
|
|
1222
1229
|
}
|
|
1223
1230
|
if (!isWhitespace(value)) {
|
|
@@ -1262,7 +1269,7 @@ __export(commentContent_exports, {
|
|
|
1262
1269
|
});
|
|
1263
1270
|
function parse10(chars, state) {
|
|
1264
1271
|
const value = chars.value();
|
|
1265
|
-
if (value ===
|
|
1272
|
+
if (value === SPECIAL_CHAR.hyphen || value === "--") {
|
|
1266
1273
|
return state.sourceCode.next();
|
|
1267
1274
|
}
|
|
1268
1275
|
if (value === COMMENT_END) {
|
|
@@ -1300,10 +1307,10 @@ __export(doctypeAttributes_exports2, {
|
|
|
1300
1307
|
});
|
|
1301
1308
|
function parse11(chars, state) {
|
|
1302
1309
|
const value = chars.value();
|
|
1303
|
-
if (value ===
|
|
1310
|
+
if (value === SPECIAL_CHAR.doubleQuote || value === SPECIAL_CHAR.singleQuote) {
|
|
1304
1311
|
return parseWrapper2(state);
|
|
1305
1312
|
}
|
|
1306
|
-
if (value ===
|
|
1313
|
+
if (value === SPECIAL_CHAR.closingCorner) {
|
|
1307
1314
|
return parseClosingCornerBrace4(state);
|
|
1308
1315
|
}
|
|
1309
1316
|
if (!isWhitespace(value)) {
|
|
@@ -1348,7 +1355,7 @@ __export(attributeValueBare_exports, {
|
|
|
1348
1355
|
});
|
|
1349
1356
|
function parse12(chars, state) {
|
|
1350
1357
|
const value = chars.value();
|
|
1351
|
-
if (isWhitespace(value) || value ===
|
|
1358
|
+
if (isWhitespace(value) || value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) {
|
|
1352
1359
|
return parseValueEnd(state);
|
|
1353
1360
|
}
|
|
1354
1361
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1375,7 +1382,7 @@ __export(doctypeAttributeBare_exports, {
|
|
|
1375
1382
|
});
|
|
1376
1383
|
function parse13(chars, state) {
|
|
1377
1384
|
const value = chars.value();
|
|
1378
|
-
if (isWhitespace(value) || value ===
|
|
1385
|
+
if (isWhitespace(value) || value === SPECIAL_CHAR.closingCorner) {
|
|
1379
1386
|
return parseAttributeEnd(state);
|
|
1380
1387
|
}
|
|
1381
1388
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1603,11 +1610,11 @@ var import_eslint_visitor_keys = require("eslint-visitor-keys");
|
|
|
1603
1610
|
var keys = {
|
|
1604
1611
|
Program: ["body"],
|
|
1605
1612
|
Document: ["children"],
|
|
1613
|
+
XMLDeclaration: [],
|
|
1606
1614
|
Doctype: ["open", "close", "attributes"],
|
|
1607
1615
|
DoctypeOpen: [],
|
|
1608
1616
|
DoctypeClose: [],
|
|
1609
1617
|
DoctypeAttribute: ["key"],
|
|
1610
|
-
DoctypeAttributeKey: [],
|
|
1611
1618
|
DoctypeAttributeValue: [],
|
|
1612
1619
|
DoctypeAttributeWrapperEnd: [],
|
|
1613
1620
|
DoctypeAttributeWrapperStart: [],
|
package/dist/index.d.cts
CHANGED
|
@@ -20,11 +20,11 @@ declare enum NodeTypes {
|
|
|
20
20
|
Program = "Program",
|
|
21
21
|
Document = "Document",
|
|
22
22
|
Text = "Text",
|
|
23
|
+
XMLDeclaration = "XMLDeclaration",
|
|
23
24
|
Doctype = "Doctype",
|
|
24
25
|
DoctypeOpen = "DoctypeOpen",
|
|
25
26
|
DoctypeClose = "DoctypeClose",
|
|
26
27
|
DoctypeAttribute = "DoctypeAttribute",
|
|
27
|
-
DoctypeAttributeKey = "DoctypeAttributeKey",
|
|
28
28
|
DoctypeAttributeValue = "DoctypeAttributeValue",
|
|
29
29
|
DoctypeAttributeWrapperEnd = "DoctypeAttributeWrapperEnd",
|
|
30
30
|
DoctypeAttributeWrapperStart = "DoctypeAttributeWrapperStart",
|
|
@@ -182,9 +182,7 @@ type CommentOpenNode = SimpleNode<NodeTypes.CommentOpen>;
|
|
|
182
182
|
/**
|
|
183
183
|
* doctype
|
|
184
184
|
*/
|
|
185
|
-
type DoctypeAttributeKeyNode = SimpleNode<NodeTypes.DoctypeAttributeKey>;
|
|
186
185
|
interface DoctypeAttributeNode extends BaseNode {
|
|
187
|
-
key: DoctypeAttributeKeyNode;
|
|
188
186
|
type: NodeTypes.DoctypeAttribute;
|
|
189
187
|
endWrapper?: DoctypeAttributeWrapperEndNode;
|
|
190
188
|
startWrapper?: DoctypeAttributeWrapperStartNode;
|
|
@@ -206,6 +204,13 @@ interface DocumentNode extends BaseNode {
|
|
|
206
204
|
type: NodeTypes.Document;
|
|
207
205
|
}
|
|
208
206
|
type TextNode = SimpleNode<NodeTypes.Text>;
|
|
207
|
+
interface XMLDeclarationNode extends BaseNode {
|
|
208
|
+
/**
|
|
209
|
+
* TODO: create XMLDeclarationAttributeNode
|
|
210
|
+
*/
|
|
211
|
+
attributes: AttributeNode[];
|
|
212
|
+
type: NodeTypes.XMLDeclaration;
|
|
213
|
+
}
|
|
209
214
|
/**
|
|
210
215
|
* tag
|
|
211
216
|
*/
|
|
@@ -234,11 +239,11 @@ interface Program extends BaseNode {
|
|
|
234
239
|
/**
|
|
235
240
|
* nestable node
|
|
236
241
|
*/
|
|
237
|
-
type NestableNode = CommentNode | TagNode | TextNode;
|
|
242
|
+
type NestableNode = CommentNode | TagNode | TextNode | XMLDeclarationNode;
|
|
238
243
|
/**
|
|
239
244
|
* any node
|
|
240
245
|
*/
|
|
241
|
-
type AnyNode = AttributeKeyNode | AttributeNode | AttributeValueNode | AttributeValueWrapperEndNode | AttributeValueWrapperStartNode | CloseTagNode | CommentCloseNode | CommentContentNode | CommentNode | CommentOpenNode |
|
|
246
|
+
type AnyNode = AttributeKeyNode | AttributeNode | AttributeValueNode | AttributeValueWrapperEndNode | AttributeValueWrapperStartNode | CloseTagNode | CommentCloseNode | CommentContentNode | CommentNode | CommentOpenNode | DoctypeAttributeNode | DoctypeAttributeValueNode | DoctypeAttributeWrapperEndNode | DoctypeAttributeWrapperStartNode | DoctypeCloseNode | DoctypeNode | DoctypeOpenNode | DocumentNode | OpenTagEndNode | OpenTagStartNode | Program | TagNode | TextNode | XMLDeclarationNode;
|
|
242
247
|
|
|
243
248
|
interface Options {
|
|
244
249
|
}
|
|
@@ -257,7 +262,7 @@ interface ParseResult {
|
|
|
257
262
|
type AnyContextualNode = ContextualAttributeNode | ContextualCommentNode | ContextualDoctypeAttributeNode | ContextualDoctypeNode | ContextualDocumentNode | ContextualTagNode;
|
|
258
263
|
type ContextualAttributeNode = ContextualNode<AttributeNode, 'key' | 'value'>;
|
|
259
264
|
type ContextualCommentNode = ContextualNode<CommentNode, 'close' | 'open' | 'value'>;
|
|
260
|
-
type ContextualDoctypeAttributeNode = ContextualNode<DoctypeAttributeNode, '
|
|
265
|
+
type ContextualDoctypeAttributeNode = ContextualNode<DoctypeAttributeNode, 'value'>;
|
|
261
266
|
type ContextualDoctypeNode = ContextualNode<DoctypeNode, 'close' | 'open'> & {
|
|
262
267
|
attributes: ContextualDoctypeAttributeNode[];
|
|
263
268
|
};
|
|
@@ -378,7 +383,6 @@ type index_ContextualDoctypeNode = ContextualDoctypeNode;
|
|
|
378
383
|
type index_ContextualDocumentNode = ContextualDocumentNode;
|
|
379
384
|
type index_ContextualNode<T extends AnyNode, K extends keyof T> = ContextualNode<T, K>;
|
|
380
385
|
type index_ContextualTagNode = ContextualTagNode;
|
|
381
|
-
type index_DoctypeAttributeKeyNode = DoctypeAttributeKeyNode;
|
|
382
386
|
type index_DoctypeAttributeNode = DoctypeAttributeNode;
|
|
383
387
|
type index_DoctypeAttributeValueNode = DoctypeAttributeValueNode;
|
|
384
388
|
type index_DoctypeAttributeWrapperEndNode = DoctypeAttributeWrapperEndNode;
|
|
@@ -405,8 +409,9 @@ type index_TextNode = TextNode;
|
|
|
405
409
|
type index_Token<T extends TokenTypes> = Token<T>;
|
|
406
410
|
type index_TokenizeHandler = TokenizeHandler;
|
|
407
411
|
type index_TokenizerState = TokenizerState;
|
|
412
|
+
type index_XMLDeclarationNode = XMLDeclarationNode;
|
|
408
413
|
declare namespace index {
|
|
409
|
-
export type { index_AnyContextualNode as AnyContextualNode, index_AnyNode as AnyNode, index_AnyToken as AnyToken, index_AttributeKeyNode as AttributeKeyNode, index_AttributeNode as AttributeNode, index_AttributeValueNode as AttributeValueNode, index_AttributeValueWrapperEndNode as AttributeValueWrapperEndNode, index_AttributeValueWrapperStartNode as AttributeValueWrapperStartNode, index_BaseNode as BaseNode, index_CloseTagNode as CloseTagNode, index_CommentCloseNode as CommentCloseNode, index_CommentContentNode as CommentContentNode, index_CommentNode as CommentNode, index_CommentOpenNode as CommentOpenNode, index_ConstructTreeHandler as ConstructTreeHandler, index_ConstructTreeState as ConstructTreeState, index_ContextualAttributeNode as ContextualAttributeNode, index_ContextualCommentNode as ContextualCommentNode, index_ContextualDoctypeAttributeNode as ContextualDoctypeAttributeNode, index_ContextualDoctypeNode as ContextualDoctypeNode, index_ContextualDocumentNode as ContextualDocumentNode, index_ContextualNode as ContextualNode, index_ContextualTagNode as ContextualTagNode,
|
|
414
|
+
export type { index_AnyContextualNode as AnyContextualNode, index_AnyNode as AnyNode, index_AnyToken as AnyToken, index_AttributeKeyNode as AttributeKeyNode, index_AttributeNode as AttributeNode, index_AttributeValueNode as AttributeValueNode, index_AttributeValueWrapperEndNode as AttributeValueWrapperEndNode, index_AttributeValueWrapperStartNode as AttributeValueWrapperStartNode, index_BaseNode as BaseNode, index_CloseTagNode as CloseTagNode, index_CommentCloseNode as CommentCloseNode, index_CommentContentNode as CommentContentNode, index_CommentNode as CommentNode, index_CommentOpenNode as CommentOpenNode, index_ConstructTreeHandler as ConstructTreeHandler, index_ConstructTreeState as ConstructTreeState, index_ContextualAttributeNode as ContextualAttributeNode, index_ContextualCommentNode as ContextualCommentNode, index_ContextualDoctypeAttributeNode as ContextualDoctypeAttributeNode, index_ContextualDoctypeNode as ContextualDoctypeNode, index_ContextualDocumentNode as ContextualDocumentNode, index_ContextualNode as ContextualNode, index_ContextualTagNode as ContextualTagNode, index_DoctypeAttributeNode as DoctypeAttributeNode, index_DoctypeAttributeValueNode as DoctypeAttributeValueNode, index_DoctypeAttributeWrapperEndNode as DoctypeAttributeWrapperEndNode, index_DoctypeAttributeWrapperStartNode as DoctypeAttributeWrapperStartNode, index_DoctypeCloseNode as DoctypeCloseNode, index_DoctypeNode as DoctypeNode, index_DoctypeOpenNode as DoctypeOpenNode, index_DocumentNode as DocumentNode, index_Locations as Locations, index_NestableNode as NestableNode, index_OpenTagEndNode as OpenTagEndNode, index_OpenTagStartNode as OpenTagStartNode, index_Options as Options, index_ParseForESLintResult as ParseForESLintResult, index_ParseResult as ParseResult, index_PartialBy as PartialBy, index_Position as Position, index_Program as Program, index_Range as Range, index_SimpleNode as SimpleNode, index_SourceLocation as SourceLocation, index_TagNode as TagNode, index_TextNode as TextNode, index_Token as Token, index_TokenizeHandler as TokenizeHandler, index_TokenizerState as TokenizerState, index_XMLDeclarationNode as XMLDeclarationNode };
|
|
410
415
|
}
|
|
411
416
|
|
|
412
417
|
declare function parseForESLint(source: string, options?: Options): ParseForESLintResult;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,11 +20,11 @@ declare enum NodeTypes {
|
|
|
20
20
|
Program = "Program",
|
|
21
21
|
Document = "Document",
|
|
22
22
|
Text = "Text",
|
|
23
|
+
XMLDeclaration = "XMLDeclaration",
|
|
23
24
|
Doctype = "Doctype",
|
|
24
25
|
DoctypeOpen = "DoctypeOpen",
|
|
25
26
|
DoctypeClose = "DoctypeClose",
|
|
26
27
|
DoctypeAttribute = "DoctypeAttribute",
|
|
27
|
-
DoctypeAttributeKey = "DoctypeAttributeKey",
|
|
28
28
|
DoctypeAttributeValue = "DoctypeAttributeValue",
|
|
29
29
|
DoctypeAttributeWrapperEnd = "DoctypeAttributeWrapperEnd",
|
|
30
30
|
DoctypeAttributeWrapperStart = "DoctypeAttributeWrapperStart",
|
|
@@ -182,9 +182,7 @@ type CommentOpenNode = SimpleNode<NodeTypes.CommentOpen>;
|
|
|
182
182
|
/**
|
|
183
183
|
* doctype
|
|
184
184
|
*/
|
|
185
|
-
type DoctypeAttributeKeyNode = SimpleNode<NodeTypes.DoctypeAttributeKey>;
|
|
186
185
|
interface DoctypeAttributeNode extends BaseNode {
|
|
187
|
-
key: DoctypeAttributeKeyNode;
|
|
188
186
|
type: NodeTypes.DoctypeAttribute;
|
|
189
187
|
endWrapper?: DoctypeAttributeWrapperEndNode;
|
|
190
188
|
startWrapper?: DoctypeAttributeWrapperStartNode;
|
|
@@ -206,6 +204,13 @@ interface DocumentNode extends BaseNode {
|
|
|
206
204
|
type: NodeTypes.Document;
|
|
207
205
|
}
|
|
208
206
|
type TextNode = SimpleNode<NodeTypes.Text>;
|
|
207
|
+
interface XMLDeclarationNode extends BaseNode {
|
|
208
|
+
/**
|
|
209
|
+
* TODO: create XMLDeclarationAttributeNode
|
|
210
|
+
*/
|
|
211
|
+
attributes: AttributeNode[];
|
|
212
|
+
type: NodeTypes.XMLDeclaration;
|
|
213
|
+
}
|
|
209
214
|
/**
|
|
210
215
|
* tag
|
|
211
216
|
*/
|
|
@@ -234,11 +239,11 @@ interface Program extends BaseNode {
|
|
|
234
239
|
/**
|
|
235
240
|
* nestable node
|
|
236
241
|
*/
|
|
237
|
-
type NestableNode = CommentNode | TagNode | TextNode;
|
|
242
|
+
type NestableNode = CommentNode | TagNode | TextNode | XMLDeclarationNode;
|
|
238
243
|
/**
|
|
239
244
|
* any node
|
|
240
245
|
*/
|
|
241
|
-
type AnyNode = AttributeKeyNode | AttributeNode | AttributeValueNode | AttributeValueWrapperEndNode | AttributeValueWrapperStartNode | CloseTagNode | CommentCloseNode | CommentContentNode | CommentNode | CommentOpenNode |
|
|
246
|
+
type AnyNode = AttributeKeyNode | AttributeNode | AttributeValueNode | AttributeValueWrapperEndNode | AttributeValueWrapperStartNode | CloseTagNode | CommentCloseNode | CommentContentNode | CommentNode | CommentOpenNode | DoctypeAttributeNode | DoctypeAttributeValueNode | DoctypeAttributeWrapperEndNode | DoctypeAttributeWrapperStartNode | DoctypeCloseNode | DoctypeNode | DoctypeOpenNode | DocumentNode | OpenTagEndNode | OpenTagStartNode | Program | TagNode | TextNode | XMLDeclarationNode;
|
|
242
247
|
|
|
243
248
|
interface Options {
|
|
244
249
|
}
|
|
@@ -257,7 +262,7 @@ interface ParseResult {
|
|
|
257
262
|
type AnyContextualNode = ContextualAttributeNode | ContextualCommentNode | ContextualDoctypeAttributeNode | ContextualDoctypeNode | ContextualDocumentNode | ContextualTagNode;
|
|
258
263
|
type ContextualAttributeNode = ContextualNode<AttributeNode, 'key' | 'value'>;
|
|
259
264
|
type ContextualCommentNode = ContextualNode<CommentNode, 'close' | 'open' | 'value'>;
|
|
260
|
-
type ContextualDoctypeAttributeNode = ContextualNode<DoctypeAttributeNode, '
|
|
265
|
+
type ContextualDoctypeAttributeNode = ContextualNode<DoctypeAttributeNode, 'value'>;
|
|
261
266
|
type ContextualDoctypeNode = ContextualNode<DoctypeNode, 'close' | 'open'> & {
|
|
262
267
|
attributes: ContextualDoctypeAttributeNode[];
|
|
263
268
|
};
|
|
@@ -378,7 +383,6 @@ type index_ContextualDoctypeNode = ContextualDoctypeNode;
|
|
|
378
383
|
type index_ContextualDocumentNode = ContextualDocumentNode;
|
|
379
384
|
type index_ContextualNode<T extends AnyNode, K extends keyof T> = ContextualNode<T, K>;
|
|
380
385
|
type index_ContextualTagNode = ContextualTagNode;
|
|
381
|
-
type index_DoctypeAttributeKeyNode = DoctypeAttributeKeyNode;
|
|
382
386
|
type index_DoctypeAttributeNode = DoctypeAttributeNode;
|
|
383
387
|
type index_DoctypeAttributeValueNode = DoctypeAttributeValueNode;
|
|
384
388
|
type index_DoctypeAttributeWrapperEndNode = DoctypeAttributeWrapperEndNode;
|
|
@@ -405,8 +409,9 @@ type index_TextNode = TextNode;
|
|
|
405
409
|
type index_Token<T extends TokenTypes> = Token<T>;
|
|
406
410
|
type index_TokenizeHandler = TokenizeHandler;
|
|
407
411
|
type index_TokenizerState = TokenizerState;
|
|
412
|
+
type index_XMLDeclarationNode = XMLDeclarationNode;
|
|
408
413
|
declare namespace index {
|
|
409
|
-
export type { index_AnyContextualNode as AnyContextualNode, index_AnyNode as AnyNode, index_AnyToken as AnyToken, index_AttributeKeyNode as AttributeKeyNode, index_AttributeNode as AttributeNode, index_AttributeValueNode as AttributeValueNode, index_AttributeValueWrapperEndNode as AttributeValueWrapperEndNode, index_AttributeValueWrapperStartNode as AttributeValueWrapperStartNode, index_BaseNode as BaseNode, index_CloseTagNode as CloseTagNode, index_CommentCloseNode as CommentCloseNode, index_CommentContentNode as CommentContentNode, index_CommentNode as CommentNode, index_CommentOpenNode as CommentOpenNode, index_ConstructTreeHandler as ConstructTreeHandler, index_ConstructTreeState as ConstructTreeState, index_ContextualAttributeNode as ContextualAttributeNode, index_ContextualCommentNode as ContextualCommentNode, index_ContextualDoctypeAttributeNode as ContextualDoctypeAttributeNode, index_ContextualDoctypeNode as ContextualDoctypeNode, index_ContextualDocumentNode as ContextualDocumentNode, index_ContextualNode as ContextualNode, index_ContextualTagNode as ContextualTagNode,
|
|
414
|
+
export type { index_AnyContextualNode as AnyContextualNode, index_AnyNode as AnyNode, index_AnyToken as AnyToken, index_AttributeKeyNode as AttributeKeyNode, index_AttributeNode as AttributeNode, index_AttributeValueNode as AttributeValueNode, index_AttributeValueWrapperEndNode as AttributeValueWrapperEndNode, index_AttributeValueWrapperStartNode as AttributeValueWrapperStartNode, index_BaseNode as BaseNode, index_CloseTagNode as CloseTagNode, index_CommentCloseNode as CommentCloseNode, index_CommentContentNode as CommentContentNode, index_CommentNode as CommentNode, index_CommentOpenNode as CommentOpenNode, index_ConstructTreeHandler as ConstructTreeHandler, index_ConstructTreeState as ConstructTreeState, index_ContextualAttributeNode as ContextualAttributeNode, index_ContextualCommentNode as ContextualCommentNode, index_ContextualDoctypeAttributeNode as ContextualDoctypeAttributeNode, index_ContextualDoctypeNode as ContextualDoctypeNode, index_ContextualDocumentNode as ContextualDocumentNode, index_ContextualNode as ContextualNode, index_ContextualTagNode as ContextualTagNode, index_DoctypeAttributeNode as DoctypeAttributeNode, index_DoctypeAttributeValueNode as DoctypeAttributeValueNode, index_DoctypeAttributeWrapperEndNode as DoctypeAttributeWrapperEndNode, index_DoctypeAttributeWrapperStartNode as DoctypeAttributeWrapperStartNode, index_DoctypeCloseNode as DoctypeCloseNode, index_DoctypeNode as DoctypeNode, index_DoctypeOpenNode as DoctypeOpenNode, index_DocumentNode as DocumentNode, index_Locations as Locations, index_NestableNode as NestableNode, index_OpenTagEndNode as OpenTagEndNode, index_OpenTagStartNode as OpenTagStartNode, index_Options as Options, index_ParseForESLintResult as ParseForESLintResult, index_ParseResult as ParseResult, index_PartialBy as PartialBy, index_Position as Position, index_Program as Program, index_Range as Range, index_SimpleNode as SimpleNode, index_SourceLocation as SourceLocation, index_TagNode as TagNode, index_TextNode as TextNode, index_Token as Token, index_TokenizeHandler as TokenizeHandler, index_TokenizerState as TokenizerState, index_XMLDeclarationNode as XMLDeclarationNode };
|
|
410
415
|
}
|
|
411
416
|
|
|
412
417
|
declare function parseForESLint(source: string, options?: Options): ParseForESLintResult;
|
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.1";
|
|
10
10
|
|
|
11
11
|
// src/meta.ts
|
|
12
12
|
var meta = {
|
|
@@ -28,14 +28,6 @@ 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 = "-->";
|
|
@@ -43,6 +35,26 @@ var RE_OPEN_TAG_START = /^<\w/;
|
|
|
43
35
|
var RE_OPEN_TAG_NAME = /^<(\S+)/;
|
|
44
36
|
var RE_CLOSE_TAG_NAME = /^<\/((?:.|\n)*)>$/;
|
|
45
37
|
|
|
38
|
+
// src/constants/specialChar.ts
|
|
39
|
+
var SPECIAL_CHAR = {
|
|
40
|
+
closingCorner: `>`,
|
|
41
|
+
colon: `:`,
|
|
42
|
+
comma: `,`,
|
|
43
|
+
doubleQuote: `"`,
|
|
44
|
+
equal: `=`,
|
|
45
|
+
exclamation: `!`,
|
|
46
|
+
hyphen: `-`,
|
|
47
|
+
newline: `
|
|
48
|
+
`,
|
|
49
|
+
openingCorner: `<`,
|
|
50
|
+
question: `?`,
|
|
51
|
+
return: `\r`,
|
|
52
|
+
singleQuote: `'`,
|
|
53
|
+
slash: `/`,
|
|
54
|
+
space: ` `,
|
|
55
|
+
tab: ` `
|
|
56
|
+
};
|
|
57
|
+
|
|
46
58
|
// src/constants/svgElements.ts
|
|
47
59
|
var SELF_CLOSING_ELEMENTS = /* @__PURE__ */ new Set([
|
|
48
60
|
"animate",
|
|
@@ -181,6 +193,12 @@ function createNodeFrom(token) {
|
|
|
181
193
|
return result;
|
|
182
194
|
}
|
|
183
195
|
|
|
196
|
+
// src/utils/getLastAttribute.ts
|
|
197
|
+
function getLastAttribute(state) {
|
|
198
|
+
const attributes = state.currentNode.attributes;
|
|
199
|
+
return last(attributes);
|
|
200
|
+
}
|
|
201
|
+
|
|
184
202
|
// src/utils/parseOpenTagName.ts
|
|
185
203
|
function parseOpenTagName(openTagStartTokenContent) {
|
|
186
204
|
const match = openTagStartTokenContent.match(RE_OPEN_TAG_NAME);
|
|
@@ -217,12 +235,12 @@ function calculateTokenLocation(source, range) {
|
|
|
217
235
|
function calculateTokenCharactersRange(state, options) {
|
|
218
236
|
const startPosition = state.sourceCode.index() - (state.accumulatedContent.length() - 1) - state.decisionBuffer.length();
|
|
219
237
|
let endPosition;
|
|
220
|
-
if (options.keepBuffer) {
|
|
238
|
+
if (!options.keepBuffer) {
|
|
221
239
|
endPosition = state.sourceCode.index() - state.decisionBuffer.length();
|
|
222
240
|
} else {
|
|
223
241
|
endPosition = state.sourceCode.index();
|
|
224
242
|
}
|
|
225
|
-
return [startPosition, endPosition];
|
|
243
|
+
return [startPosition, endPosition + 1];
|
|
226
244
|
}
|
|
227
245
|
|
|
228
246
|
// src/utils/calculateTokenPosition.ts
|
|
@@ -416,10 +434,6 @@ function construct5(token, state) {
|
|
|
416
434
|
state.caretPosition++;
|
|
417
435
|
return state;
|
|
418
436
|
}
|
|
419
|
-
function getLastAttribute(state) {
|
|
420
|
-
const attributes = state.currentNode.attributes;
|
|
421
|
-
return last(attributes);
|
|
422
|
-
}
|
|
423
437
|
function handleOpenTagEnd2(state) {
|
|
424
438
|
state.currentContext = state.currentContext.parentRef;
|
|
425
439
|
return state;
|
|
@@ -601,23 +615,19 @@ function construct8(token, state) {
|
|
|
601
615
|
state.caretPosition++;
|
|
602
616
|
return state;
|
|
603
617
|
}
|
|
604
|
-
function getLastAttribute2(state) {
|
|
605
|
-
const attributes = state.currentNode.attributes;
|
|
606
|
-
return last(attributes);
|
|
607
|
-
}
|
|
608
618
|
function handleValueEnd(state) {
|
|
609
619
|
state.currentContext = state.currentContext.parentRef;
|
|
610
620
|
return state;
|
|
611
621
|
}
|
|
612
622
|
function handleAttributeValue(state, token) {
|
|
613
|
-
const attribute =
|
|
623
|
+
const attribute = getLastAttribute(state);
|
|
614
624
|
attribute.value = createNodeFrom(token);
|
|
615
625
|
updateNodeEnd(attribute, token);
|
|
616
626
|
state.caretPosition++;
|
|
617
627
|
return state;
|
|
618
628
|
}
|
|
619
629
|
function handleAttributeValueWrapperStart(state, token) {
|
|
620
|
-
const attribute =
|
|
630
|
+
const attribute = getLastAttribute(state);
|
|
621
631
|
attribute.startWrapper = createNodeFrom(token);
|
|
622
632
|
if (!attribute.key) {
|
|
623
633
|
attribute.range = cloneRange(token.range);
|
|
@@ -627,7 +637,7 @@ function handleAttributeValueWrapperStart(state, token) {
|
|
|
627
637
|
return state;
|
|
628
638
|
}
|
|
629
639
|
function handleAttributeValueWrapperEnd(state, token) {
|
|
630
|
-
const attribute =
|
|
640
|
+
const attribute = getLastAttribute(state);
|
|
631
641
|
attribute.endWrapper = createNodeFrom(token);
|
|
632
642
|
updateNodeEnd(attribute, token);
|
|
633
643
|
state.caretPosition++;
|
|
@@ -655,16 +665,12 @@ function construct9(token, state) {
|
|
|
655
665
|
state.caretPosition++;
|
|
656
666
|
return state;
|
|
657
667
|
}
|
|
658
|
-
function getLastAttribute3(state) {
|
|
659
|
-
const attributes = state.currentNode.attributes;
|
|
660
|
-
return last(attributes);
|
|
661
|
-
}
|
|
662
668
|
function handleDoctypeClose2(state) {
|
|
663
669
|
state.currentContext = state.currentContext.parentRef;
|
|
664
670
|
return state;
|
|
665
671
|
}
|
|
666
672
|
function handleDoctypeAttributeWrapperStart(state, token) {
|
|
667
|
-
const attribute =
|
|
673
|
+
const attribute = getLastAttribute(state);
|
|
668
674
|
if (attribute.value !== void 0) {
|
|
669
675
|
state.currentContext = state.currentContext.parentRef;
|
|
670
676
|
return state;
|
|
@@ -675,7 +681,7 @@ function handleDoctypeAttributeWrapperStart(state, token) {
|
|
|
675
681
|
return state;
|
|
676
682
|
}
|
|
677
683
|
function handleDoctypeAttributeWrapperEnd(state, token) {
|
|
678
|
-
const attribute =
|
|
684
|
+
const attribute = getLastAttribute(state);
|
|
679
685
|
attribute.endWrapper = createNodeFrom(token);
|
|
680
686
|
updateNodeEnd(attribute, token);
|
|
681
687
|
state.currentContext = state.currentContext.parentRef;
|
|
@@ -683,7 +689,7 @@ function handleDoctypeAttributeWrapperEnd(state, token) {
|
|
|
683
689
|
return state;
|
|
684
690
|
}
|
|
685
691
|
function handleDoctypeAttributeValue(state, token) {
|
|
686
|
-
const attribute =
|
|
692
|
+
const attribute = getLastAttribute(state);
|
|
687
693
|
if (attribute.value !== void 0) {
|
|
688
694
|
state.currentContext = state.currentContext.parentRef;
|
|
689
695
|
return state;
|
|
@@ -855,7 +861,7 @@ function parse(chars, state) {
|
|
|
855
861
|
if (value === "</") {
|
|
856
862
|
return parseOpeningCornerBraceWithSlash(state);
|
|
857
863
|
}
|
|
858
|
-
if (value ===
|
|
864
|
+
if (value === SPECIAL_CHAR.openingCorner || value === "<!" || value === "<!-") {
|
|
859
865
|
return state.sourceCode.next();
|
|
860
866
|
}
|
|
861
867
|
if (value === COMMENT_START) {
|
|
@@ -952,7 +958,7 @@ __export(closeTag_exports, {
|
|
|
952
958
|
});
|
|
953
959
|
function parse2(chars, state) {
|
|
954
960
|
const value = chars.value();
|
|
955
|
-
if (value ===
|
|
961
|
+
if (value === SPECIAL_CHAR.closingCorner) {
|
|
956
962
|
return parseClosingCornerBrace(state);
|
|
957
963
|
}
|
|
958
964
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -980,10 +986,10 @@ __export(attributes_exports2, {
|
|
|
980
986
|
});
|
|
981
987
|
function parse3(chars, state) {
|
|
982
988
|
const value = chars.value();
|
|
983
|
-
if (value ===
|
|
989
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) {
|
|
984
990
|
return parseTagEnd(state);
|
|
985
991
|
}
|
|
986
|
-
if (value ===
|
|
992
|
+
if (value === SPECIAL_CHAR.equal) {
|
|
987
993
|
return parseEqual(state);
|
|
988
994
|
}
|
|
989
995
|
if (!isWhitespace(value)) {
|
|
@@ -1026,7 +1032,7 @@ __export(openTagEnd_exports, {
|
|
|
1026
1032
|
parse: () => parse4
|
|
1027
1033
|
});
|
|
1028
1034
|
function parse4(chars, state) {
|
|
1029
|
-
if (chars.value() ===
|
|
1035
|
+
if (chars.value() === SPECIAL_CHAR.closingCorner) {
|
|
1030
1036
|
return parseClosingCornerBrace2(state);
|
|
1031
1037
|
}
|
|
1032
1038
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1058,7 +1064,7 @@ function parse5(chars, state) {
|
|
|
1058
1064
|
if (isWhitespace(value)) {
|
|
1059
1065
|
return parseWhitespace(state);
|
|
1060
1066
|
}
|
|
1061
|
-
if (value ===
|
|
1067
|
+
if (value === SPECIAL_CHAR.closingCorner) {
|
|
1062
1068
|
return parseClosingCornerBrace3(state);
|
|
1063
1069
|
}
|
|
1064
1070
|
state.decisionBuffer.clear();
|
|
@@ -1121,7 +1127,7 @@ function parse7(chars, state) {
|
|
|
1121
1127
|
}
|
|
1122
1128
|
function isKeyBreak(chars) {
|
|
1123
1129
|
const value = chars.value();
|
|
1124
|
-
return value ===
|
|
1130
|
+
return value === SPECIAL_CHAR.equal || value === SPECIAL_CHAR.slash || value === SPECIAL_CHAR.closingCorner || isWhitespace(value);
|
|
1125
1131
|
}
|
|
1126
1132
|
function parseKeyEnd(state) {
|
|
1127
1133
|
const position = calculateTokenPosition(state, { keepBuffer: false });
|
|
@@ -1142,10 +1148,11 @@ __export(openTagStart_exports, {
|
|
|
1142
1148
|
parse: () => parse8
|
|
1143
1149
|
});
|
|
1144
1150
|
function parse8(chars, state) {
|
|
1145
|
-
|
|
1151
|
+
const value = chars.value();
|
|
1152
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) {
|
|
1146
1153
|
return parseTagEnd2(state);
|
|
1147
1154
|
}
|
|
1148
|
-
if (isWhitespace(
|
|
1155
|
+
if (isWhitespace(value)) {
|
|
1149
1156
|
return parseWhitespace2(state);
|
|
1150
1157
|
}
|
|
1151
1158
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1189,10 +1196,10 @@ __export(attributeValue_exports2, {
|
|
|
1189
1196
|
});
|
|
1190
1197
|
function parse9(chars, state) {
|
|
1191
1198
|
const value = chars.value();
|
|
1192
|
-
if (value ===
|
|
1199
|
+
if (value === SPECIAL_CHAR.doubleQuote || value === SPECIAL_CHAR.singleQuote) {
|
|
1193
1200
|
return parseWrapper(state);
|
|
1194
1201
|
}
|
|
1195
|
-
if (value ===
|
|
1202
|
+
if (value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) {
|
|
1196
1203
|
return parseTagEnd3(state);
|
|
1197
1204
|
}
|
|
1198
1205
|
if (!isWhitespace(value)) {
|
|
@@ -1237,7 +1244,7 @@ __export(commentContent_exports, {
|
|
|
1237
1244
|
});
|
|
1238
1245
|
function parse10(chars, state) {
|
|
1239
1246
|
const value = chars.value();
|
|
1240
|
-
if (value ===
|
|
1247
|
+
if (value === SPECIAL_CHAR.hyphen || value === "--") {
|
|
1241
1248
|
return state.sourceCode.next();
|
|
1242
1249
|
}
|
|
1243
1250
|
if (value === COMMENT_END) {
|
|
@@ -1275,10 +1282,10 @@ __export(doctypeAttributes_exports2, {
|
|
|
1275
1282
|
});
|
|
1276
1283
|
function parse11(chars, state) {
|
|
1277
1284
|
const value = chars.value();
|
|
1278
|
-
if (value ===
|
|
1285
|
+
if (value === SPECIAL_CHAR.doubleQuote || value === SPECIAL_CHAR.singleQuote) {
|
|
1279
1286
|
return parseWrapper2(state);
|
|
1280
1287
|
}
|
|
1281
|
-
if (value ===
|
|
1288
|
+
if (value === SPECIAL_CHAR.closingCorner) {
|
|
1282
1289
|
return parseClosingCornerBrace4(state);
|
|
1283
1290
|
}
|
|
1284
1291
|
if (!isWhitespace(value)) {
|
|
@@ -1323,7 +1330,7 @@ __export(attributeValueBare_exports, {
|
|
|
1323
1330
|
});
|
|
1324
1331
|
function parse12(chars, state) {
|
|
1325
1332
|
const value = chars.value();
|
|
1326
|
-
if (isWhitespace(value) || value ===
|
|
1333
|
+
if (isWhitespace(value) || value === SPECIAL_CHAR.closingCorner || value === SPECIAL_CHAR.slash) {
|
|
1327
1334
|
return parseValueEnd(state);
|
|
1328
1335
|
}
|
|
1329
1336
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1350,7 +1357,7 @@ __export(doctypeAttributeBare_exports, {
|
|
|
1350
1357
|
});
|
|
1351
1358
|
function parse13(chars, state) {
|
|
1352
1359
|
const value = chars.value();
|
|
1353
|
-
if (isWhitespace(value) || value ===
|
|
1360
|
+
if (isWhitespace(value) || value === SPECIAL_CHAR.closingCorner) {
|
|
1354
1361
|
return parseAttributeEnd(state);
|
|
1355
1362
|
}
|
|
1356
1363
|
state.accumulatedContent.concatBuffer(state.decisionBuffer);
|
|
@@ -1578,11 +1585,11 @@ import { unionWith } from "eslint-visitor-keys";
|
|
|
1578
1585
|
var keys = {
|
|
1579
1586
|
Program: ["body"],
|
|
1580
1587
|
Document: ["children"],
|
|
1588
|
+
XMLDeclaration: [],
|
|
1581
1589
|
Doctype: ["open", "close", "attributes"],
|
|
1582
1590
|
DoctypeOpen: [],
|
|
1583
1591
|
DoctypeClose: [],
|
|
1584
1592
|
DoctypeAttribute: ["key"],
|
|
1585
|
-
DoctypeAttributeKey: [],
|
|
1586
1593
|
DoctypeAttributeValue: [],
|
|
1587
1594
|
DoctypeAttributeWrapperEnd: [],
|
|
1588
1595
|
DoctypeAttributeWrapperStart: [],
|
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.1",
|
|
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",
|