svg-eslint-parser 0.0.2 → 0.0.3
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 +1 -1
- package/dist/{index.d.cts → index.d.mts} +165 -77
- package/dist/{index.js → index.mjs} +856 -558
- package/package.json +38 -40
- package/dist/index.cjs +0 -1926
- package/dist/index.d.ts +0 -487
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://github.com/ntnyq/svg-eslint-parser/actions)
|
|
4
4
|
[](https://www.npmjs.com/package/svg-eslint-parser)
|
|
5
5
|
[](https://www.npmjs.com/package/svg-eslint-parser)
|
|
6
|
-
[](https://codecov.io/github/ntnyq/svg-eslint-parser)
|
|
6
|
+
[](https://codecov.io/github/ntnyq/svg-eslint-parser)
|
|
7
7
|
[](https://github.com/ntnyq/svg-eslint-parser/blob/main/LICENSE)
|
|
8
8
|
|
|
9
9
|
> :package: An SVG parser that produces output compatible with ESLint.
|
|
@@ -24,6 +24,14 @@ declare const COMMENT_START = "<!--";
|
|
|
24
24
|
* svg comment end
|
|
25
25
|
*/
|
|
26
26
|
declare const COMMENT_END = "-->";
|
|
27
|
+
/**
|
|
28
|
+
* xml declaration start
|
|
29
|
+
*/
|
|
30
|
+
declare const XML_DECLARATION_START = "<?xml";
|
|
31
|
+
/**
|
|
32
|
+
* xml declaration end
|
|
33
|
+
*/
|
|
34
|
+
declare const XML_DECLARATION_END = "?>";
|
|
27
35
|
/**
|
|
28
36
|
* regexp for open tag start
|
|
29
37
|
* @regex101 https://regex101.com/?regex=%5E%3C%5Cw&flavor=javascript
|
|
@@ -46,56 +54,71 @@ declare const RE_CLOSE_TAG_NAME: RegExp;
|
|
|
46
54
|
declare const RE_INCOMPLETE_CLOSING_TAG: RegExp;
|
|
47
55
|
|
|
48
56
|
declare enum NodeTypes {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
Attribute = "Attribute",
|
|
58
|
+
AttributeKey = "AttributeKey",
|
|
59
|
+
AttributeValue = "AttributeValue",
|
|
60
|
+
AttributeValueWrapperEnd = "AttributeValueWrapperEnd",
|
|
61
|
+
AttributeValueWrapperStart = "AttributeValueWrapperStart",
|
|
62
|
+
CloseTag = "CloseTag",
|
|
63
|
+
Comment = "Comment",
|
|
64
|
+
CommentClose = "CommentClose",
|
|
65
|
+
CommentContent = "CommentContent",
|
|
66
|
+
CommentOpen = "CommentOpen",
|
|
53
67
|
Doctype = "Doctype",
|
|
54
|
-
DoctypeOpen = "DoctypeOpen",
|
|
55
|
-
DoctypeClose = "DoctypeClose",
|
|
56
68
|
DoctypeAttribute = "DoctypeAttribute",
|
|
57
69
|
DoctypeAttributeValue = "DoctypeAttributeValue",
|
|
58
70
|
DoctypeAttributeWrapperEnd = "DoctypeAttributeWrapperEnd",
|
|
59
71
|
DoctypeAttributeWrapperStart = "DoctypeAttributeWrapperStart",
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
DoctypeClose = "DoctypeClose",
|
|
73
|
+
DoctypeOpen = "DoctypeOpen",
|
|
74
|
+
Document = "Document",
|
|
62
75
|
OpenTagEnd = "OpenTagEnd",
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
OpenTagStart = "OpenTagStart",
|
|
77
|
+
Program = "Program",
|
|
78
|
+
Tag = "Tag",
|
|
79
|
+
Text = "Text",
|
|
80
|
+
XMLDeclaration = "XMLDeclaration",
|
|
81
|
+
XMLDeclarationAttribute = "XMLDeclarationAttribute",
|
|
82
|
+
XMLDeclarationAttributeKey = "XMLDeclarationAttributeKey",
|
|
83
|
+
XMLDeclarationAttributeValue = "XMLDeclarationAttributeValue",
|
|
84
|
+
XMLDeclarationAttributeValueWrapperEnd = "XMLDeclarationAttributeValueWrapperEnd",
|
|
85
|
+
XMLDeclarationAttributeValueWrapperStart = "XMLDeclarationAttributeValueWrapperStart",
|
|
86
|
+
XMLDeclarationClose = "XMLDeclarationClose",
|
|
87
|
+
XMLDeclarationOpen = "XMLDeclarationOpen"
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare enum TokenTypes {
|
|
68
91
|
Attribute = "Attribute",
|
|
92
|
+
AttributeAssignment = "AttributeAssignment",
|
|
69
93
|
AttributeKey = "AttributeKey",
|
|
70
94
|
AttributeValue = "AttributeValue",
|
|
95
|
+
AttributeValueWrapperEnd = "AttributeValueWrapperEnd",
|
|
71
96
|
AttributeValueWrapperStart = "AttributeValueWrapperStart",
|
|
72
|
-
AttributeValueWrapperEnd = "AttributeValueWrapperEnd"
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
declare enum TokenTypes {
|
|
76
|
-
Program = "Program",
|
|
77
|
-
Document = "Document",
|
|
78
|
-
Text = "Text",
|
|
79
|
-
Doctype = "Doctype",
|
|
80
|
-
DoctypeOpen = "DoctypeOpen",
|
|
81
|
-
DoctypeClose = "DoctypeClose",
|
|
82
|
-
DoctypeAttributeValue = "DoctypeAttributeValue",
|
|
83
|
-
DoctypeAttributeWrapperStart = "DoctypeAttributeWrapperStart",
|
|
84
|
-
DoctypeAttributeWrapperEnd = "DoctypeAttributeWrapperEnd",
|
|
85
|
-
Tag = "Tag",
|
|
86
|
-
OpenTagStart = "OpenTagStart",
|
|
87
|
-
OpenTagEnd = "OpenTagEnd",
|
|
88
97
|
CloseTag = "CloseTag",
|
|
89
98
|
Comment = "Comment",
|
|
90
|
-
CommentOpen = "CommentOpen",
|
|
91
99
|
CommentClose = "CommentClose",
|
|
92
100
|
CommentContent = "CommentContent",
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
CommentOpen = "CommentOpen",
|
|
102
|
+
Doctype = "Doctype",
|
|
103
|
+
DoctypeAttributeValue = "DoctypeAttributeValue",
|
|
104
|
+
DoctypeAttributeWrapperEnd = "DoctypeAttributeWrapperEnd",
|
|
105
|
+
DoctypeAttributeWrapperStart = "DoctypeAttributeWrapperStart",
|
|
106
|
+
DoctypeClose = "DoctypeClose",
|
|
107
|
+
DoctypeOpen = "DoctypeOpen",
|
|
108
|
+
Document = "Document",
|
|
109
|
+
OpenTagEnd = "OpenTagEnd",
|
|
110
|
+
OpenTagStart = "OpenTagStart",
|
|
111
|
+
Program = "Program",
|
|
112
|
+
Tag = "Tag",
|
|
113
|
+
Text = "Text",
|
|
114
|
+
XMLDeclarationAttribute = "XMLDeclarationAttribute",
|
|
115
|
+
XMLDeclarationAttributeAssignment = "XMLDeclarationAttributeAssignment",
|
|
116
|
+
XMLDeclarationAttributeKey = "XMLDeclarationAttributeKey",
|
|
117
|
+
XMLDeclarationAttributeValue = "XMLDeclarationAttributeValue",
|
|
118
|
+
XMLDeclarationAttributeValueWrapperEnd = "XMLDeclarationAttributeValueWrapperEnd",
|
|
119
|
+
XMLDeclarationAttributeValueWrapperStart = "XMLDeclarationAttributeValueWrapperStart",
|
|
120
|
+
XMLDeclarationClose = "XMLDeclarationClose",
|
|
121
|
+
XMLDeclarationOpen = "XMLDeclarationOpen"
|
|
99
122
|
}
|
|
100
123
|
|
|
101
124
|
declare const SPECIAL_CHAR: {
|
|
@@ -133,36 +156,46 @@ declare const DEPRECATED_SVG_ELEMENTS: Set<string>;
|
|
|
133
156
|
declare const SELF_CLOSING_ELEMENTS: Set<string>;
|
|
134
157
|
|
|
135
158
|
declare enum TokenizerContextTypes {
|
|
136
|
-
Data = "Data",
|
|
137
|
-
OpenTagStart = "OpenTagStart",
|
|
138
|
-
OpenTagEnd = "OpenTagEnd",
|
|
139
|
-
CloseTag = "CloseTag",
|
|
140
|
-
Attributes = "Attributes",
|
|
141
159
|
AttributeKey = "AttributeKey",
|
|
160
|
+
Attributes = "Attributes",
|
|
142
161
|
AttributeValue = "AttributeValue",
|
|
143
162
|
AttributeValueBare = "AttributeValueBare",
|
|
144
163
|
AttributeValueWrapped = "AttributeValueWrapped",
|
|
164
|
+
CloseTag = "CloseTag",
|
|
165
|
+
CommentClose = "CommentClose",
|
|
145
166
|
CommentContent = "CommentContent",
|
|
146
167
|
CommentOpen = "CommentOpen",
|
|
147
|
-
|
|
148
|
-
DoctypeOpen = "DoctypeOpen",
|
|
149
|
-
DoctypeClose = "DoctypeClose",
|
|
150
|
-
DoctypeAttributes = "DoctypeAttributes",
|
|
168
|
+
Data = "Data",
|
|
151
169
|
DoctypeAttributeBare = "DoctypeAttributeBare",
|
|
152
|
-
|
|
170
|
+
DoctypeAttributes = "DoctypeAttributes",
|
|
171
|
+
DoctypeAttributeWrapped = "DoctypeAttributeWrapped",
|
|
172
|
+
DoctypeClose = "DoctypeClose",
|
|
173
|
+
DoctypeOpen = "DoctypeOpen",
|
|
174
|
+
OpenTagEnd = "OpenTagEnd",
|
|
175
|
+
OpenTagStart = "OpenTagStart",
|
|
176
|
+
XMLDeclarationAttributeKey = "XMLDeclarationAttributeKey",
|
|
177
|
+
XMLDeclarationAttributes = "XMLDeclarationAttributes",
|
|
178
|
+
XMLDeclarationAttributeValue = "XMLDeclarationAttributeValue",
|
|
179
|
+
XMLDeclarationAttributeValueWrapped = "XMLDeclarationAttributeValueWrapped",
|
|
180
|
+
XMLDeclarationClose = "XMLDeclarationClose",
|
|
181
|
+
XMLDeclarationOpen = "XMLDeclarationOpen"
|
|
153
182
|
}
|
|
154
183
|
|
|
155
184
|
declare enum ConstructTreeContextTypes {
|
|
156
|
-
Tag = "Tag",
|
|
157
|
-
TagName = "TagName",
|
|
158
|
-
TagContent = "TagContent",
|
|
159
185
|
Attribute = "Attribute",
|
|
160
186
|
Attributes = "Attributes",
|
|
161
187
|
AttributeValue = "AttributeValue",
|
|
188
|
+
Comment = "Comment",
|
|
162
189
|
Doctype = "Doctype",
|
|
163
190
|
DoctypeAttribute = "DoctypeAttribute",
|
|
164
191
|
DoctypeAttributes = "DoctypeAttributes",
|
|
165
|
-
|
|
192
|
+
Tag = "Tag",
|
|
193
|
+
TagContent = "TagContent",
|
|
194
|
+
TagName = "TagName",
|
|
195
|
+
XMLDeclaration = "XMLDeclaration",
|
|
196
|
+
XMLDeclarationAttribute = "XMLDeclarationAttribute",
|
|
197
|
+
XMLDeclarationAttributes = "XMLDeclarationAttributes",
|
|
198
|
+
XMLDeclarationAttributeValue = "XMLDeclarationAttributeValue"
|
|
166
199
|
}
|
|
167
200
|
|
|
168
201
|
interface Locations {
|
|
@@ -191,6 +224,10 @@ interface SourceLocation {
|
|
|
191
224
|
start: Position;
|
|
192
225
|
}
|
|
193
226
|
|
|
227
|
+
/**
|
|
228
|
+
* any token
|
|
229
|
+
*/
|
|
230
|
+
type AnyToken = Token<TokenTypes.Attribute> | Token<TokenTypes.AttributeAssignment> | Token<TokenTypes.AttributeKey> | Token<TokenTypes.AttributeValue> | Token<TokenTypes.AttributeValueWrapperEnd> | Token<TokenTypes.AttributeValueWrapperStart> | Token<TokenTypes.CloseTag> | Token<TokenTypes.Comment> | Token<TokenTypes.CommentClose> | Token<TokenTypes.CommentContent> | Token<TokenTypes.CommentOpen> | Token<TokenTypes.Doctype> | Token<TokenTypes.DoctypeAttributeValue> | Token<TokenTypes.DoctypeAttributeWrapperEnd> | Token<TokenTypes.DoctypeAttributeWrapperStart> | Token<TokenTypes.DoctypeClose> | Token<TokenTypes.DoctypeOpen> | Token<TokenTypes.Document> | Token<TokenTypes.OpenTagEnd> | Token<TokenTypes.OpenTagStart> | Token<TokenTypes.Program> | Token<TokenTypes.Tag> | Token<TokenTypes.Text> | Token<TokenTypes.XMLDeclarationAttribute> | Token<TokenTypes.XMLDeclarationAttributeAssignment> | Token<TokenTypes.XMLDeclarationAttributeKey> | Token<TokenTypes.XMLDeclarationAttributeValue> | Token<TokenTypes.XMLDeclarationAttributeValueWrapperEnd> | Token<TokenTypes.XMLDeclarationAttributeValueWrapperStart> | Token<TokenTypes.XMLDeclarationClose> | Token<TokenTypes.XMLDeclarationOpen>;
|
|
194
231
|
/**
|
|
195
232
|
* token
|
|
196
233
|
*/
|
|
@@ -204,10 +241,6 @@ interface Token<T extends TokenTypes> extends Locations {
|
|
|
204
241
|
*/
|
|
205
242
|
value: string;
|
|
206
243
|
}
|
|
207
|
-
/**
|
|
208
|
-
* any token
|
|
209
|
-
*/
|
|
210
|
-
type AnyToken = Token<TokenTypes.Attribute> | Token<TokenTypes.AttributeAssignment> | Token<TokenTypes.AttributeKey> | Token<TokenTypes.AttributeValue> | Token<TokenTypes.AttributeValueWrapperEnd> | Token<TokenTypes.AttributeValueWrapperStart> | Token<TokenTypes.CloseTag> | Token<TokenTypes.Comment> | Token<TokenTypes.CommentClose> | Token<TokenTypes.CommentContent> | Token<TokenTypes.CommentOpen> | Token<TokenTypes.Doctype> | Token<TokenTypes.DoctypeAttributeValue> | Token<TokenTypes.DoctypeAttributeWrapperEnd> | Token<TokenTypes.DoctypeAttributeWrapperStart> | Token<TokenTypes.DoctypeClose> | Token<TokenTypes.DoctypeOpen> | Token<TokenTypes.Document> | Token<TokenTypes.OpenTagEnd> | Token<TokenTypes.OpenTagStart> | Token<TokenTypes.Program> | Token<TokenTypes.Tag> | Token<TokenTypes.Text>;
|
|
211
244
|
|
|
212
245
|
interface BaseNode extends Locations {
|
|
213
246
|
type: NodeTypes;
|
|
@@ -216,22 +249,25 @@ interface SimpleNode<T extends NodeTypes> extends BaseNode {
|
|
|
216
249
|
type: T;
|
|
217
250
|
value: string;
|
|
218
251
|
}
|
|
252
|
+
type TextNode = SimpleNode<NodeTypes.Text>;
|
|
219
253
|
/**
|
|
220
254
|
* attribute
|
|
255
|
+
* @pg
|
|
221
256
|
*/
|
|
222
257
|
type AttributeKeyNode = SimpleNode<NodeTypes.AttributeKey>;
|
|
223
258
|
interface AttributeNode extends BaseNode {
|
|
224
259
|
key: AttributeKeyNode;
|
|
225
260
|
type: NodeTypes.Attribute;
|
|
261
|
+
value: AttributeValueNode;
|
|
226
262
|
endWrapper?: AttributeValueWrapperEndNode;
|
|
227
263
|
startWrapper?: AttributeValueWrapperStartNode;
|
|
228
|
-
value?: AttributeValueNode;
|
|
229
264
|
}
|
|
230
265
|
type AttributeValueNode = SimpleNode<NodeTypes.AttributeValue>;
|
|
231
266
|
type AttributeValueWrapperEndNode = SimpleNode<NodeTypes.AttributeValueWrapperEnd>;
|
|
232
267
|
type AttributeValueWrapperStartNode = SimpleNode<NodeTypes.AttributeValueWrapperStart>;
|
|
233
268
|
/**
|
|
234
269
|
* comment
|
|
270
|
+
* @pg
|
|
235
271
|
*/
|
|
236
272
|
type CommentCloseNode = SimpleNode<NodeTypes.CommentClose>;
|
|
237
273
|
type CommentContentNode = SimpleNode<NodeTypes.CommentContent>;
|
|
@@ -244,6 +280,7 @@ interface CommentNode extends BaseNode {
|
|
|
244
280
|
type CommentOpenNode = SimpleNode<NodeTypes.CommentOpen>;
|
|
245
281
|
/**
|
|
246
282
|
* doctype
|
|
283
|
+
* @pg
|
|
247
284
|
*/
|
|
248
285
|
interface DoctypeAttributeNode extends BaseNode {
|
|
249
286
|
type: NodeTypes.DoctypeAttribute;
|
|
@@ -262,20 +299,9 @@ interface DoctypeNode extends BaseNode {
|
|
|
262
299
|
type: NodeTypes.Doctype;
|
|
263
300
|
}
|
|
264
301
|
type DoctypeOpenNode = SimpleNode<NodeTypes.DoctypeOpen>;
|
|
265
|
-
interface DocumentNode extends BaseNode {
|
|
266
|
-
children: NestableNode[];
|
|
267
|
-
type: NodeTypes.Document;
|
|
268
|
-
}
|
|
269
|
-
type TextNode = SimpleNode<NodeTypes.Text>;
|
|
270
|
-
interface XMLDeclarationNode extends BaseNode {
|
|
271
|
-
/**
|
|
272
|
-
* TODO: create XMLDeclarationAttributeNode
|
|
273
|
-
*/
|
|
274
|
-
attributes: AttributeNode[];
|
|
275
|
-
type: NodeTypes.XMLDeclaration;
|
|
276
|
-
}
|
|
277
302
|
/**
|
|
278
303
|
* tag
|
|
304
|
+
* @pg
|
|
279
305
|
*/
|
|
280
306
|
type CloseTagNode = SimpleNode<NodeTypes.CloseTag>;
|
|
281
307
|
type OpenTagEndNode = SimpleNode<NodeTypes.OpenTagEnd>;
|
|
@@ -290,28 +316,74 @@ interface TagNode extends BaseNode {
|
|
|
290
316
|
type: NodeTypes.Tag;
|
|
291
317
|
close?: CloseTagNode;
|
|
292
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* XML declaration
|
|
321
|
+
*/
|
|
322
|
+
type XMLDeclarationAttributeKeyNode = SimpleNode<NodeTypes.XMLDeclarationAttributeKey>;
|
|
323
|
+
interface XMLDeclarationAttributeNode extends BaseNode {
|
|
324
|
+
key: XMLDeclarationAttributeKeyNode;
|
|
325
|
+
type: NodeTypes.XMLDeclarationAttribute;
|
|
326
|
+
value: XMLDeclarationAttributeValueNode;
|
|
327
|
+
endWrapper?: XMLDeclarationAttributeValueWrapperEndNode;
|
|
328
|
+
startWrapper?: XMLDeclarationAttributeValueWrapperStartNode;
|
|
329
|
+
}
|
|
330
|
+
type XMLDeclarationAttributeValueNode = SimpleNode<NodeTypes.XMLDeclarationAttributeValue>;
|
|
331
|
+
type XMLDeclarationAttributeValueWrapperEndNode = SimpleNode<NodeTypes.XMLDeclarationAttributeValueWrapperEnd>;
|
|
332
|
+
type XMLDeclarationAttributeValueWrapperStartNode = SimpleNode<NodeTypes.XMLDeclarationAttributeValueWrapperStart>;
|
|
333
|
+
type XMLDeclarationCloseNode = SimpleNode<NodeTypes.XMLDeclarationClose>;
|
|
334
|
+
interface XMLDeclarationNode extends BaseNode {
|
|
335
|
+
attributes: XMLDeclarationAttributeNode[];
|
|
336
|
+
close: XMLDeclarationCloseNode;
|
|
337
|
+
open: XMLDeclarationOpenNode;
|
|
338
|
+
type: NodeTypes.XMLDeclaration;
|
|
339
|
+
}
|
|
340
|
+
type XMLDeclarationOpenNode = SimpleNode<NodeTypes.XMLDeclarationOpen>;
|
|
341
|
+
/**
|
|
342
|
+
* nestable node
|
|
343
|
+
* @pg
|
|
344
|
+
*/
|
|
345
|
+
type NestableNode = CommentNode | TagNode | TextNode | XMLDeclarationNode;
|
|
293
346
|
/**
|
|
294
347
|
* program
|
|
348
|
+
* @pg
|
|
295
349
|
*/
|
|
350
|
+
interface DocumentNode extends BaseNode {
|
|
351
|
+
children: NestableNode[];
|
|
352
|
+
type: NodeTypes.Document;
|
|
353
|
+
}
|
|
296
354
|
interface Program extends BaseNode {
|
|
297
355
|
body: DocumentNode[];
|
|
298
356
|
comments: CommentContentNode[];
|
|
299
357
|
tokens: AnyToken[];
|
|
300
358
|
type: NodeTypes.Program;
|
|
301
359
|
}
|
|
302
|
-
/**
|
|
303
|
-
* nestable node
|
|
304
|
-
*/
|
|
305
|
-
type NestableNode = CommentNode | TagNode | TextNode | XMLDeclarationNode;
|
|
306
360
|
/**
|
|
307
361
|
* any node
|
|
362
|
+
* @pg
|
|
308
363
|
*/
|
|
309
|
-
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;
|
|
364
|
+
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 | XMLDeclarationAttributeKeyNode | XMLDeclarationAttributeNode | XMLDeclarationAttributeValueNode | XMLDeclarationAttributeValueWrapperEndNode | XMLDeclarationAttributeValueWrapperStartNode | XMLDeclarationCloseNode | XMLDeclarationNode | XMLDeclarationOpenNode;
|
|
310
365
|
|
|
311
366
|
interface Options {
|
|
367
|
+
comment?: boolean;
|
|
368
|
+
/**
|
|
369
|
+
* eslint features
|
|
370
|
+
*/
|
|
371
|
+
eslintScopeManager?: boolean;
|
|
372
|
+
eslintVisitorKeys?: boolean;
|
|
373
|
+
filePath?: string;
|
|
374
|
+
/**
|
|
375
|
+
* required for eslint parse
|
|
376
|
+
*/
|
|
377
|
+
loc?: boolean;
|
|
378
|
+
range?: boolean;
|
|
379
|
+
tokens?: boolean;
|
|
312
380
|
}
|
|
381
|
+
/**
|
|
382
|
+
* @see {@link https://eslint.org/docs/latest/extend/custom-parsers#parseforeslint-return-object}
|
|
383
|
+
*/
|
|
313
384
|
interface ParseForESLintResult {
|
|
314
385
|
ast: Program;
|
|
386
|
+
scopeManager: any;
|
|
315
387
|
services: {
|
|
316
388
|
isSVG: boolean;
|
|
317
389
|
};
|
|
@@ -322,7 +394,7 @@ interface ParseResult {
|
|
|
322
394
|
tokens: AnyToken[];
|
|
323
395
|
}
|
|
324
396
|
|
|
325
|
-
type AnyContextualNode = ContextualAttributeNode | ContextualCommentNode | ContextualDoctypeAttributeNode | ContextualDoctypeNode | ContextualDocumentNode | ContextualTagNode;
|
|
397
|
+
type AnyContextualNode = ContextualAttributeNode | ContextualCommentNode | ContextualDoctypeAttributeNode | ContextualDoctypeNode | ContextualDocumentNode | ContextualTagNode | ContextualXMLDeclarationAttributeNode | ContextuaLXMLDeclarationNode;
|
|
326
398
|
type ContextualAttributeNode = ContextualNode<AttributeNode, 'key' | 'value'>;
|
|
327
399
|
type ContextualCommentNode = ContextualNode<CommentNode, 'close' | 'open' | 'value'>;
|
|
328
400
|
type ContextualDoctypeAttributeNode = ContextualNode<DoctypeAttributeNode, 'value'>;
|
|
@@ -339,6 +411,10 @@ type ContextualTagNode = ContextualNode<TagNode, 'close' | 'name' | 'openEnd' |
|
|
|
339
411
|
attributes: ContextualAttributeNode[];
|
|
340
412
|
children: Array<ContextualCommentNode | ContextualDoctypeNode | ContextualTagNode | TagNode['children'][number]>;
|
|
341
413
|
};
|
|
414
|
+
type ContextualXMLDeclarationAttributeNode = ContextualNode<XMLDeclarationAttributeNode, 'key' | 'value'>;
|
|
415
|
+
type ContextuaLXMLDeclarationNode = ContextualNode<XMLDeclarationNode, 'close' | 'open'> & {
|
|
416
|
+
attributes: ContextualXMLDeclarationAttributeNode[];
|
|
417
|
+
};
|
|
342
418
|
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
343
419
|
|
|
344
420
|
declare class Chars {
|
|
@@ -401,6 +477,9 @@ type ContextParams = {
|
|
|
401
477
|
[TokenizerContextTypes.OpenTagEnd]?: {
|
|
402
478
|
tagName: string;
|
|
403
479
|
};
|
|
480
|
+
[TokenizerContextTypes.XMLDeclarationAttributeValueWrapped]?: {
|
|
481
|
+
wrapper: string;
|
|
482
|
+
};
|
|
404
483
|
};
|
|
405
484
|
|
|
406
485
|
type ConstructTreeState<N extends AnyContextualNode> = {
|
|
@@ -439,6 +518,7 @@ type index_CommentNode = CommentNode;
|
|
|
439
518
|
type index_CommentOpenNode = CommentOpenNode;
|
|
440
519
|
type index_ConstructTreeHandler = ConstructTreeHandler;
|
|
441
520
|
type index_ConstructTreeState<N extends AnyContextualNode> = ConstructTreeState<N>;
|
|
521
|
+
type index_ContextuaLXMLDeclarationNode = ContextuaLXMLDeclarationNode;
|
|
442
522
|
type index_ContextualAttributeNode = ContextualAttributeNode;
|
|
443
523
|
type index_ContextualCommentNode = ContextualCommentNode;
|
|
444
524
|
type index_ContextualDoctypeAttributeNode = ContextualDoctypeAttributeNode;
|
|
@@ -446,6 +526,7 @@ type index_ContextualDoctypeNode = ContextualDoctypeNode;
|
|
|
446
526
|
type index_ContextualDocumentNode = ContextualDocumentNode;
|
|
447
527
|
type index_ContextualNode<T extends AnyNode, K extends keyof T> = ContextualNode<T, K>;
|
|
448
528
|
type index_ContextualTagNode = ContextualTagNode;
|
|
529
|
+
type index_ContextualXMLDeclarationAttributeNode = ContextualXMLDeclarationAttributeNode;
|
|
449
530
|
type index_DoctypeAttributeNode = DoctypeAttributeNode;
|
|
450
531
|
type index_DoctypeAttributeValueNode = DoctypeAttributeValueNode;
|
|
451
532
|
type index_DoctypeAttributeWrapperEndNode = DoctypeAttributeWrapperEndNode;
|
|
@@ -472,16 +553,23 @@ type index_TextNode = TextNode;
|
|
|
472
553
|
type index_Token<T extends TokenTypes> = Token<T>;
|
|
473
554
|
type index_TokenizeHandler = TokenizeHandler;
|
|
474
555
|
type index_TokenizerState = TokenizerState;
|
|
556
|
+
type index_XMLDeclarationAttributeKeyNode = XMLDeclarationAttributeKeyNode;
|
|
557
|
+
type index_XMLDeclarationAttributeNode = XMLDeclarationAttributeNode;
|
|
558
|
+
type index_XMLDeclarationAttributeValueNode = XMLDeclarationAttributeValueNode;
|
|
559
|
+
type index_XMLDeclarationAttributeValueWrapperEndNode = XMLDeclarationAttributeValueWrapperEndNode;
|
|
560
|
+
type index_XMLDeclarationAttributeValueWrapperStartNode = XMLDeclarationAttributeValueWrapperStartNode;
|
|
561
|
+
type index_XMLDeclarationCloseNode = XMLDeclarationCloseNode;
|
|
475
562
|
type index_XMLDeclarationNode = XMLDeclarationNode;
|
|
563
|
+
type index_XMLDeclarationOpenNode = XMLDeclarationOpenNode;
|
|
476
564
|
declare namespace index {
|
|
477
|
-
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 };
|
|
565
|
+
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_ContextuaLXMLDeclarationNode as ContextuaLXMLDeclarationNode, 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_ContextualXMLDeclarationAttributeNode as ContextualXMLDeclarationAttributeNode, 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_XMLDeclarationAttributeKeyNode as XMLDeclarationAttributeKeyNode, index_XMLDeclarationAttributeNode as XMLDeclarationAttributeNode, index_XMLDeclarationAttributeValueNode as XMLDeclarationAttributeValueNode, index_XMLDeclarationAttributeValueWrapperEndNode as XMLDeclarationAttributeValueWrapperEndNode, index_XMLDeclarationAttributeValueWrapperStartNode as XMLDeclarationAttributeValueWrapperStartNode, index_XMLDeclarationCloseNode as XMLDeclarationCloseNode, index_XMLDeclarationNode as XMLDeclarationNode, index_XMLDeclarationOpenNode as XMLDeclarationOpenNode };
|
|
478
566
|
}
|
|
479
567
|
|
|
480
568
|
declare function parseForESLint(source: string, options?: Options): ParseForESLintResult;
|
|
481
569
|
|
|
482
|
-
declare function parseSVG(code: string, options?: Options): Program;
|
|
483
570
|
declare const name: string;
|
|
484
571
|
declare const VisitorKeys: eslint.SourceCode.VisitorKeys;
|
|
485
|
-
declare
|
|
572
|
+
declare function parse(code: string, options?: Options): Program;
|
|
486
573
|
|
|
487
|
-
export { index as AST,
|
|
574
|
+
export { index as AST, COMMENT_END, COMMENT_START, ConstructTreeContextTypes, DEPRECATED_SVG_ELEMENTS, NodeTypes, ParseError, RE_CLOSE_TAG_NAME, RE_INCOMPLETE_CLOSING_TAG, RE_OPEN_TAG_NAME, RE_OPEN_TAG_START, SELF_CLOSING_ELEMENTS, SPECIAL_CHAR, SVG_ELEMENTS, TokenTypes, TokenizerContextTypes, VisitorKeys, XML_DECLARATION_END, XML_DECLARATION_START, meta, name, parse, parseForESLint };
|
|
575
|
+
export type { AnyContextualNode, AnyNode, AnyToken, AttributeKeyNode, AttributeNode, AttributeValueNode, AttributeValueWrapperEndNode, AttributeValueWrapperStartNode, BaseNode, CloseTagNode, CommentCloseNode, CommentContentNode, CommentNode, CommentOpenNode, ConstructTreeHandler, ConstructTreeState, ContextuaLXMLDeclarationNode, ContextualAttributeNode, ContextualCommentNode, ContextualDoctypeAttributeNode, ContextualDoctypeNode, ContextualDocumentNode, ContextualNode, ContextualTagNode, ContextualXMLDeclarationAttributeNode, DoctypeAttributeNode, DoctypeAttributeValueNode, DoctypeAttributeWrapperEndNode, DoctypeAttributeWrapperStartNode, DoctypeCloseNode, DoctypeNode, DoctypeOpenNode, DocumentNode, Locations, NestableNode, OpenTagEndNode, OpenTagStartNode, Options, ParseForESLintResult, ParseResult, PartialBy, Position, Program, Range, SimpleNode, SourceLocation, TagNode, TextNode, Token, TokenizeHandler, TokenizerState, XMLDeclarationAttributeKeyNode, XMLDeclarationAttributeNode, XMLDeclarationAttributeValueNode, XMLDeclarationAttributeValueWrapperEndNode, XMLDeclarationAttributeValueWrapperStartNode, XMLDeclarationCloseNode, XMLDeclarationNode, XMLDeclarationOpenNode };
|