svg-eslint-parser 0.0.3 → 0.0.5
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 +3 -4
- package/dist/chunk-CzXV76rE.js +18 -0
- package/dist/index.d.ts +537 -0
- package/dist/index.js +1982 -0
- package/package.json +32 -40
- package/dist/index.d.mts +0 -575
- package/dist/index.mjs +0 -2183
package/README.md
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
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)
|
|
7
6
|
[](https://github.com/ntnyq/svg-eslint-parser/blob/main/LICENSE)
|
|
8
7
|
|
|
9
8
|
> :package: An SVG parser that produces output compatible with ESLint.
|
|
@@ -15,15 +14,15 @@
|
|
|
15
14
|
|
|
16
15
|
## Install
|
|
17
16
|
|
|
18
|
-
```
|
|
17
|
+
```shell
|
|
19
18
|
npm install svg-eslint-parser -D
|
|
20
19
|
```
|
|
21
20
|
|
|
22
|
-
```
|
|
21
|
+
```shell
|
|
23
22
|
yarn add svg-eslint-parser -D
|
|
24
23
|
```
|
|
25
24
|
|
|
26
|
-
```
|
|
25
|
+
```shell
|
|
27
26
|
pnpm add svg-eslint-parser -D
|
|
28
27
|
```
|
|
29
28
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { __exportAll as t };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
import * as eslint0 from "eslint";
|
|
2
|
+
import { SourceCode } from "eslint";
|
|
3
|
+
|
|
4
|
+
//#region src/meta.d.ts
|
|
5
|
+
declare const meta: {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/parser/error.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* parse error
|
|
13
|
+
*/
|
|
14
|
+
declare class ParseError extends SyntaxError {
|
|
15
|
+
index: number;
|
|
16
|
+
lineNumber: number;
|
|
17
|
+
column: number;
|
|
18
|
+
constructor(message: string, offset: number, line: number, column: number);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/constants/parse.d.ts
|
|
22
|
+
/**
|
|
23
|
+
* svg comment start
|
|
24
|
+
*/
|
|
25
|
+
declare const COMMENT_START = "<!--";
|
|
26
|
+
/**
|
|
27
|
+
* svg comment end
|
|
28
|
+
*/
|
|
29
|
+
declare const COMMENT_END = "-->";
|
|
30
|
+
/**
|
|
31
|
+
* xml declaration start
|
|
32
|
+
*/
|
|
33
|
+
declare const XML_DECLARATION_START = "<?xml";
|
|
34
|
+
/**
|
|
35
|
+
* xml declaration end
|
|
36
|
+
*/
|
|
37
|
+
declare const XML_DECLARATION_END = "?>";
|
|
38
|
+
/**
|
|
39
|
+
* regexp for open tag start
|
|
40
|
+
* @regex101 https://regex101.com/?regex=%5E%3C%5Cw&flavor=javascript
|
|
41
|
+
*/
|
|
42
|
+
declare const RE_OPEN_TAG_START: RegExp;
|
|
43
|
+
/**
|
|
44
|
+
* regexp for open tag name
|
|
45
|
+
* @regex101 https://regex101.com/?regex=%5E%3C%28%5CS%2B%29&flavor=javascript
|
|
46
|
+
*/
|
|
47
|
+
declare const RE_OPEN_TAG_NAME: RegExp;
|
|
48
|
+
/**
|
|
49
|
+
* regexp for close tag name
|
|
50
|
+
* @regex101 https://regex101.com/?regex=%5E%3C%5C%2F%28%28%3F%3A.%7C%5Cr%3F%5Cn%29*%29%3E%24&flavor=javascript
|
|
51
|
+
*/
|
|
52
|
+
declare const RE_CLOSE_TAG_NAME: RegExp;
|
|
53
|
+
/**
|
|
54
|
+
* regexp for incomplete closing tag
|
|
55
|
+
* @regex101 https://regex101.com/?regex=%3C%5C%2F%5B%5E%3E%5D%2B%24&flavor=javascript
|
|
56
|
+
*/
|
|
57
|
+
declare const RE_INCOMPLETE_CLOSING_TAG: RegExp;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/constants/nodeTypes.d.ts
|
|
60
|
+
declare enum NodeTypes {
|
|
61
|
+
Attribute = "Attribute",
|
|
62
|
+
AttributeKey = "AttributeKey",
|
|
63
|
+
AttributeValue = "AttributeValue",
|
|
64
|
+
AttributeValueWrapperEnd = "AttributeValueWrapperEnd",
|
|
65
|
+
AttributeValueWrapperStart = "AttributeValueWrapperStart",
|
|
66
|
+
CloseTag = "CloseTag",
|
|
67
|
+
Comment = "Comment",
|
|
68
|
+
CommentClose = "CommentClose",
|
|
69
|
+
CommentContent = "CommentContent",
|
|
70
|
+
CommentOpen = "CommentOpen",
|
|
71
|
+
Doctype = "Doctype",
|
|
72
|
+
DoctypeAttribute = "DoctypeAttribute",
|
|
73
|
+
DoctypeAttributeValue = "DoctypeAttributeValue",
|
|
74
|
+
DoctypeAttributeWrapperEnd = "DoctypeAttributeWrapperEnd",
|
|
75
|
+
DoctypeAttributeWrapperStart = "DoctypeAttributeWrapperStart",
|
|
76
|
+
DoctypeClose = "DoctypeClose",
|
|
77
|
+
DoctypeOpen = "DoctypeOpen",
|
|
78
|
+
Document = "Document",
|
|
79
|
+
OpenTagEnd = "OpenTagEnd",
|
|
80
|
+
OpenTagStart = "OpenTagStart",
|
|
81
|
+
Program = "Program",
|
|
82
|
+
Tag = "Tag",
|
|
83
|
+
Text = "Text",
|
|
84
|
+
XMLDeclaration = "XMLDeclaration",
|
|
85
|
+
XMLDeclarationAttribute = "XMLDeclarationAttribute",
|
|
86
|
+
XMLDeclarationAttributeKey = "XMLDeclarationAttributeKey",
|
|
87
|
+
XMLDeclarationAttributeValue = "XMLDeclarationAttributeValue",
|
|
88
|
+
XMLDeclarationAttributeValueWrapperEnd = "XMLDeclarationAttributeValueWrapperEnd",
|
|
89
|
+
XMLDeclarationAttributeValueWrapperStart = "XMLDeclarationAttributeValueWrapperStart",
|
|
90
|
+
XMLDeclarationClose = "XMLDeclarationClose",
|
|
91
|
+
XMLDeclarationOpen = "XMLDeclarationOpen",
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/constants/tokenTypes.d.ts
|
|
95
|
+
declare enum TokenTypes {
|
|
96
|
+
Attribute = "Attribute",
|
|
97
|
+
AttributeAssignment = "AttributeAssignment",
|
|
98
|
+
AttributeKey = "AttributeKey",
|
|
99
|
+
AttributeValue = "AttributeValue",
|
|
100
|
+
AttributeValueWrapperEnd = "AttributeValueWrapperEnd",
|
|
101
|
+
AttributeValueWrapperStart = "AttributeValueWrapperStart",
|
|
102
|
+
CloseTag = "CloseTag",
|
|
103
|
+
Comment = "Comment",
|
|
104
|
+
CommentClose = "CommentClose",
|
|
105
|
+
CommentContent = "CommentContent",
|
|
106
|
+
CommentOpen = "CommentOpen",
|
|
107
|
+
Doctype = "Doctype",
|
|
108
|
+
DoctypeAttributeValue = "DoctypeAttributeValue",
|
|
109
|
+
DoctypeAttributeWrapperEnd = "DoctypeAttributeWrapperEnd",
|
|
110
|
+
DoctypeAttributeWrapperStart = "DoctypeAttributeWrapperStart",
|
|
111
|
+
DoctypeClose = "DoctypeClose",
|
|
112
|
+
DoctypeOpen = "DoctypeOpen",
|
|
113
|
+
Document = "Document",
|
|
114
|
+
OpenTagEnd = "OpenTagEnd",
|
|
115
|
+
OpenTagStart = "OpenTagStart",
|
|
116
|
+
Program = "Program",
|
|
117
|
+
Tag = "Tag",
|
|
118
|
+
Text = "Text",
|
|
119
|
+
XMLDeclarationAttribute = "XMLDeclarationAttribute",
|
|
120
|
+
XMLDeclarationAttributeAssignment = "XMLDeclarationAttributeAssignment",
|
|
121
|
+
XMLDeclarationAttributeKey = "XMLDeclarationAttributeKey",
|
|
122
|
+
XMLDeclarationAttributeValue = "XMLDeclarationAttributeValue",
|
|
123
|
+
XMLDeclarationAttributeValueWrapperEnd = "XMLDeclarationAttributeValueWrapperEnd",
|
|
124
|
+
XMLDeclarationAttributeValueWrapperStart = "XMLDeclarationAttributeValueWrapperStart",
|
|
125
|
+
XMLDeclarationClose = "XMLDeclarationClose",
|
|
126
|
+
XMLDeclarationOpen = "XMLDeclarationOpen",
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/constants/specialChar.d.ts
|
|
130
|
+
declare const SPECIAL_CHAR: {
|
|
131
|
+
closingCorner: string;
|
|
132
|
+
colon: string;
|
|
133
|
+
comma: string;
|
|
134
|
+
doubleQuote: string;
|
|
135
|
+
equal: string;
|
|
136
|
+
exclamation: string;
|
|
137
|
+
hyphen: string;
|
|
138
|
+
newline: string;
|
|
139
|
+
openingCorner: string;
|
|
140
|
+
question: string;
|
|
141
|
+
return: string;
|
|
142
|
+
singleQuote: string;
|
|
143
|
+
slash: string;
|
|
144
|
+
space: string;
|
|
145
|
+
tab: string;
|
|
146
|
+
};
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/constants/svgElements.d.ts
|
|
149
|
+
/**
|
|
150
|
+
* @copyright {@link https://github.com/davidohlin/svg-elements}
|
|
151
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Element}
|
|
152
|
+
*/
|
|
153
|
+
declare const SVG_ELEMENTS: Set<string>;
|
|
154
|
+
/**
|
|
155
|
+
* obsolete and deprecated elements
|
|
156
|
+
*
|
|
157
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Element#obsolete_and_deprecated_elements}
|
|
158
|
+
*/
|
|
159
|
+
declare const DEPRECATED_SVG_ELEMENTS: Set<string>;
|
|
160
|
+
/**
|
|
161
|
+
* self closing svg elements
|
|
162
|
+
*/
|
|
163
|
+
declare const SELF_CLOSING_ELEMENTS: Set<string>;
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/constants/tokenizerContextTypes.d.ts
|
|
166
|
+
declare enum TokenizerContextTypes {
|
|
167
|
+
AttributeKey = "AttributeKey",
|
|
168
|
+
Attributes = "Attributes",
|
|
169
|
+
AttributeValue = "AttributeValue",
|
|
170
|
+
AttributeValueBare = "AttributeValueBare",
|
|
171
|
+
AttributeValueWrapped = "AttributeValueWrapped",
|
|
172
|
+
CloseTag = "CloseTag",
|
|
173
|
+
CommentClose = "CommentClose",
|
|
174
|
+
CommentContent = "CommentContent",
|
|
175
|
+
CommentOpen = "CommentOpen",
|
|
176
|
+
Data = "Data",
|
|
177
|
+
DoctypeAttributeBare = "DoctypeAttributeBare",
|
|
178
|
+
DoctypeAttributes = "DoctypeAttributes",
|
|
179
|
+
DoctypeAttributeWrapped = "DoctypeAttributeWrapped",
|
|
180
|
+
DoctypeClose = "DoctypeClose",
|
|
181
|
+
DoctypeOpen = "DoctypeOpen",
|
|
182
|
+
OpenTagEnd = "OpenTagEnd",
|
|
183
|
+
OpenTagStart = "OpenTagStart",
|
|
184
|
+
XMLDeclarationAttributeKey = "XMLDeclarationAttributeKey",
|
|
185
|
+
XMLDeclarationAttributes = "XMLDeclarationAttributes",
|
|
186
|
+
XMLDeclarationAttributeValue = "XMLDeclarationAttributeValue",
|
|
187
|
+
XMLDeclarationAttributeValueWrapped = "XMLDeclarationAttributeValueWrapped",
|
|
188
|
+
XMLDeclarationClose = "XMLDeclarationClose",
|
|
189
|
+
XMLDeclarationOpen = "XMLDeclarationOpen",
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/constants/constructTreeContextTypes.d.ts
|
|
193
|
+
declare enum ConstructTreeContextTypes {
|
|
194
|
+
Attribute = "Attribute",
|
|
195
|
+
Attributes = "Attributes",
|
|
196
|
+
AttributeValue = "AttributeValue",
|
|
197
|
+
Comment = "Comment",
|
|
198
|
+
Doctype = "Doctype",
|
|
199
|
+
DoctypeAttribute = "DoctypeAttribute",
|
|
200
|
+
DoctypeAttributes = "DoctypeAttributes",
|
|
201
|
+
Tag = "Tag",
|
|
202
|
+
TagContent = "TagContent",
|
|
203
|
+
TagName = "TagName",
|
|
204
|
+
XMLDeclaration = "XMLDeclaration",
|
|
205
|
+
XMLDeclarationAttribute = "XMLDeclarationAttribute",
|
|
206
|
+
XMLDeclarationAttributes = "XMLDeclarationAttributes",
|
|
207
|
+
XMLDeclarationAttributeValue = "XMLDeclarationAttributeValue",
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/types/ast/common.d.ts
|
|
211
|
+
interface Locations {
|
|
212
|
+
loc: SourceLocation;
|
|
213
|
+
range: Range;
|
|
214
|
+
}
|
|
215
|
+
interface Position {
|
|
216
|
+
/**
|
|
217
|
+
* 0 based index (>= 0)
|
|
218
|
+
*/
|
|
219
|
+
column: number;
|
|
220
|
+
/**
|
|
221
|
+
* 1 based index (>= 1)
|
|
222
|
+
*/
|
|
223
|
+
line: number;
|
|
224
|
+
}
|
|
225
|
+
type Range = [number, number];
|
|
226
|
+
interface SourceLocation {
|
|
227
|
+
/**
|
|
228
|
+
* end position of source
|
|
229
|
+
*/
|
|
230
|
+
end: Position;
|
|
231
|
+
/**
|
|
232
|
+
* start position of source
|
|
233
|
+
*/
|
|
234
|
+
start: Position;
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/types/ast/token.d.ts
|
|
238
|
+
/**
|
|
239
|
+
* any token
|
|
240
|
+
*/
|
|
241
|
+
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>;
|
|
242
|
+
/**
|
|
243
|
+
* token
|
|
244
|
+
*/
|
|
245
|
+
interface Token<T extends TokenTypes> extends Locations {
|
|
246
|
+
/**
|
|
247
|
+
* node type
|
|
248
|
+
*/
|
|
249
|
+
type: T;
|
|
250
|
+
/**
|
|
251
|
+
* token value
|
|
252
|
+
*/
|
|
253
|
+
value: string;
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/types/ast/node.d.ts
|
|
257
|
+
interface BaseNode extends Locations {
|
|
258
|
+
type: NodeTypes;
|
|
259
|
+
}
|
|
260
|
+
interface SimpleNode<T extends NodeTypes> extends BaseNode {
|
|
261
|
+
type: T;
|
|
262
|
+
value: string;
|
|
263
|
+
}
|
|
264
|
+
type TextNode = SimpleNode<NodeTypes.Text>;
|
|
265
|
+
/**
|
|
266
|
+
* attribute
|
|
267
|
+
* @pg
|
|
268
|
+
*/
|
|
269
|
+
type AttributeKeyNode = SimpleNode<NodeTypes.AttributeKey>;
|
|
270
|
+
interface AttributeNode extends BaseNode {
|
|
271
|
+
key: AttributeKeyNode;
|
|
272
|
+
type: NodeTypes.Attribute;
|
|
273
|
+
value: AttributeValueNode;
|
|
274
|
+
endWrapper?: AttributeValueWrapperEndNode;
|
|
275
|
+
startWrapper?: AttributeValueWrapperStartNode;
|
|
276
|
+
}
|
|
277
|
+
type AttributeValueNode = SimpleNode<NodeTypes.AttributeValue>;
|
|
278
|
+
type AttributeValueWrapperEndNode = SimpleNode<NodeTypes.AttributeValueWrapperEnd>;
|
|
279
|
+
type AttributeValueWrapperStartNode = SimpleNode<NodeTypes.AttributeValueWrapperStart>;
|
|
280
|
+
/**
|
|
281
|
+
* comment
|
|
282
|
+
* @pg
|
|
283
|
+
*/
|
|
284
|
+
type CommentCloseNode = SimpleNode<NodeTypes.CommentClose>;
|
|
285
|
+
type CommentContentNode = SimpleNode<NodeTypes.CommentContent>;
|
|
286
|
+
interface CommentNode extends BaseNode {
|
|
287
|
+
close: CommentCloseNode;
|
|
288
|
+
open: CommentOpenNode;
|
|
289
|
+
type: NodeTypes.Comment;
|
|
290
|
+
value: CommentContentNode;
|
|
291
|
+
}
|
|
292
|
+
type CommentOpenNode = SimpleNode<NodeTypes.CommentOpen>;
|
|
293
|
+
/**
|
|
294
|
+
* doctype
|
|
295
|
+
* @pg
|
|
296
|
+
*/
|
|
297
|
+
interface DoctypeAttributeNode extends BaseNode {
|
|
298
|
+
type: NodeTypes.DoctypeAttribute;
|
|
299
|
+
endWrapper?: DoctypeAttributeWrapperEndNode;
|
|
300
|
+
startWrapper?: DoctypeAttributeWrapperStartNode;
|
|
301
|
+
value?: DoctypeAttributeValueNode;
|
|
302
|
+
}
|
|
303
|
+
type DoctypeAttributeValueNode = SimpleNode<NodeTypes.DoctypeAttributeValue>;
|
|
304
|
+
type DoctypeAttributeWrapperEndNode = SimpleNode<NodeTypes.DoctypeAttributeWrapperEnd>;
|
|
305
|
+
type DoctypeAttributeWrapperStartNode = SimpleNode<NodeTypes.DoctypeAttributeWrapperStart>;
|
|
306
|
+
type DoctypeCloseNode = SimpleNode<NodeTypes.DoctypeClose>;
|
|
307
|
+
interface DoctypeNode extends BaseNode {
|
|
308
|
+
attributes: DoctypeAttributeNode[];
|
|
309
|
+
close: DoctypeCloseNode;
|
|
310
|
+
open: DoctypeOpenNode;
|
|
311
|
+
type: NodeTypes.Doctype;
|
|
312
|
+
}
|
|
313
|
+
type DoctypeOpenNode = SimpleNode<NodeTypes.DoctypeOpen>;
|
|
314
|
+
/**
|
|
315
|
+
* tag
|
|
316
|
+
* @pg
|
|
317
|
+
*/
|
|
318
|
+
type CloseTagNode = SimpleNode<NodeTypes.CloseTag>;
|
|
319
|
+
type OpenTagEndNode = SimpleNode<NodeTypes.OpenTagEnd>;
|
|
320
|
+
type OpenTagStartNode = SimpleNode<NodeTypes.OpenTagStart>;
|
|
321
|
+
interface TagNode extends BaseNode {
|
|
322
|
+
attributes: AttributeNode[];
|
|
323
|
+
children: NestableNode[];
|
|
324
|
+
name: string;
|
|
325
|
+
openEnd: OpenTagEndNode;
|
|
326
|
+
openStart: OpenTagStartNode;
|
|
327
|
+
selfClosing: boolean;
|
|
328
|
+
type: NodeTypes.Tag;
|
|
329
|
+
close?: CloseTagNode;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* XML declaration
|
|
333
|
+
*/
|
|
334
|
+
type XMLDeclarationAttributeKeyNode = SimpleNode<NodeTypes.XMLDeclarationAttributeKey>;
|
|
335
|
+
interface XMLDeclarationAttributeNode extends BaseNode {
|
|
336
|
+
key: XMLDeclarationAttributeKeyNode;
|
|
337
|
+
type: NodeTypes.XMLDeclarationAttribute;
|
|
338
|
+
value: XMLDeclarationAttributeValueNode;
|
|
339
|
+
endWrapper?: XMLDeclarationAttributeValueWrapperEndNode;
|
|
340
|
+
startWrapper?: XMLDeclarationAttributeValueWrapperStartNode;
|
|
341
|
+
}
|
|
342
|
+
type XMLDeclarationAttributeValueNode = SimpleNode<NodeTypes.XMLDeclarationAttributeValue>;
|
|
343
|
+
type XMLDeclarationAttributeValueWrapperEndNode = SimpleNode<NodeTypes.XMLDeclarationAttributeValueWrapperEnd>;
|
|
344
|
+
type XMLDeclarationAttributeValueWrapperStartNode = SimpleNode<NodeTypes.XMLDeclarationAttributeValueWrapperStart>;
|
|
345
|
+
type XMLDeclarationCloseNode = SimpleNode<NodeTypes.XMLDeclarationClose>;
|
|
346
|
+
interface XMLDeclarationNode extends BaseNode {
|
|
347
|
+
attributes: XMLDeclarationAttributeNode[];
|
|
348
|
+
close: XMLDeclarationCloseNode;
|
|
349
|
+
open: XMLDeclarationOpenNode;
|
|
350
|
+
type: NodeTypes.XMLDeclaration;
|
|
351
|
+
}
|
|
352
|
+
type XMLDeclarationOpenNode = SimpleNode<NodeTypes.XMLDeclarationOpen>;
|
|
353
|
+
/**
|
|
354
|
+
* nestable node
|
|
355
|
+
* @pg
|
|
356
|
+
*/
|
|
357
|
+
type NestableNode = CommentNode | TagNode | TextNode | XMLDeclarationNode;
|
|
358
|
+
/**
|
|
359
|
+
* program
|
|
360
|
+
* @pg
|
|
361
|
+
*/
|
|
362
|
+
interface DocumentNode extends BaseNode {
|
|
363
|
+
children: NestableNode[];
|
|
364
|
+
type: NodeTypes.Document;
|
|
365
|
+
}
|
|
366
|
+
interface Program extends BaseNode {
|
|
367
|
+
body: DocumentNode[];
|
|
368
|
+
comments: CommentContentNode[];
|
|
369
|
+
tokens: AnyToken[];
|
|
370
|
+
type: NodeTypes.Program;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* any node
|
|
374
|
+
* @pg
|
|
375
|
+
*/
|
|
376
|
+
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;
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region src/types/parse.d.ts
|
|
379
|
+
interface Options {
|
|
380
|
+
comment?: boolean;
|
|
381
|
+
/**
|
|
382
|
+
* eslint features
|
|
383
|
+
*/
|
|
384
|
+
eslintScopeManager?: boolean;
|
|
385
|
+
eslintVisitorKeys?: boolean;
|
|
386
|
+
filePath?: string;
|
|
387
|
+
/**
|
|
388
|
+
* required for eslint parse
|
|
389
|
+
*/
|
|
390
|
+
loc?: boolean;
|
|
391
|
+
range?: boolean;
|
|
392
|
+
tokens?: boolean;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* @see {@link https://eslint.org/docs/latest/extend/custom-parsers#parseforeslint-return-object}
|
|
396
|
+
*/
|
|
397
|
+
interface ParseForESLintResult {
|
|
398
|
+
ast: Program;
|
|
399
|
+
scopeManager: any;
|
|
400
|
+
services: {
|
|
401
|
+
isSVG: boolean;
|
|
402
|
+
};
|
|
403
|
+
visitorKeys: SourceCode.VisitorKeys;
|
|
404
|
+
}
|
|
405
|
+
interface ParseResult {
|
|
406
|
+
ast: DocumentNode;
|
|
407
|
+
tokens: AnyToken[];
|
|
408
|
+
}
|
|
409
|
+
//#endregion
|
|
410
|
+
//#region src/types/contextualNode.d.ts
|
|
411
|
+
type AnyContextualNode = ContextualAttributeNode | ContextualCommentNode | ContextualDoctypeAttributeNode | ContextualDoctypeNode | ContextualDocumentNode | ContextualTagNode | ContextualXMLDeclarationAttributeNode | ContextuaLXMLDeclarationNode;
|
|
412
|
+
type ContextualAttributeNode = ContextualNode<AttributeNode, 'key' | 'value'>;
|
|
413
|
+
type ContextualCommentNode = ContextualNode<CommentNode, 'close' | 'open' | 'value'>;
|
|
414
|
+
type ContextualDoctypeAttributeNode = ContextualNode<DoctypeAttributeNode, 'value'>;
|
|
415
|
+
type ContextualDoctypeNode = ContextualNode<DoctypeNode, 'close' | 'open'> & {
|
|
416
|
+
attributes: ContextualDoctypeAttributeNode[];
|
|
417
|
+
};
|
|
418
|
+
type ContextualDocumentNode = Omit<ContextualNode<DocumentNode, never>, 'children'> & {
|
|
419
|
+
children: Array<DocumentNode['children'][number] | Exclude<AnyContextualNode, ContextualDoctypeNode>>;
|
|
420
|
+
};
|
|
421
|
+
type ContextualNode<T extends AnyNode, K extends keyof T> = PartialBy<T, K> & {
|
|
422
|
+
parentRef?: any;
|
|
423
|
+
};
|
|
424
|
+
type ContextualTagNode = ContextualNode<TagNode, 'close' | 'name' | 'openEnd' | 'openStart' | 'selfClosing'> & {
|
|
425
|
+
attributes: ContextualAttributeNode[];
|
|
426
|
+
children: Array<ContextualCommentNode | ContextualDoctypeNode | ContextualTagNode | TagNode['children'][number]>;
|
|
427
|
+
};
|
|
428
|
+
type ContextualXMLDeclarationAttributeNode = ContextualNode<XMLDeclarationAttributeNode, 'key' | 'value'>;
|
|
429
|
+
type ContextuaLXMLDeclarationNode = ContextualNode<XMLDeclarationNode, 'close' | 'open'> & {
|
|
430
|
+
attributes: ContextualXMLDeclarationAttributeNode[];
|
|
431
|
+
};
|
|
432
|
+
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/tokenizer/chars.d.ts
|
|
435
|
+
declare class Chars {
|
|
436
|
+
value: string;
|
|
437
|
+
range: Range;
|
|
438
|
+
constructor(value: string, range: Range);
|
|
439
|
+
concat(chars: Chars): void;
|
|
440
|
+
equals(chars: string): boolean;
|
|
441
|
+
length(): number;
|
|
442
|
+
}
|
|
443
|
+
//#endregion
|
|
444
|
+
//#region src/tokenizer/charsBuffer.d.ts
|
|
445
|
+
declare class CharsBuffer {
|
|
446
|
+
charsBuffer: Chars[];
|
|
447
|
+
concat(chars: Chars): void;
|
|
448
|
+
concatBuffer(buffer: CharsBuffer): void;
|
|
449
|
+
length(): number;
|
|
450
|
+
clear(): void;
|
|
451
|
+
value(): string;
|
|
452
|
+
last(): Chars;
|
|
453
|
+
first(): Chars;
|
|
454
|
+
removeLast(): void;
|
|
455
|
+
removeFirst(): void;
|
|
456
|
+
replace(other: CharsBuffer): void;
|
|
457
|
+
}
|
|
458
|
+
//#endregion
|
|
459
|
+
//#region src/tokenizer/sourceCode.d.ts
|
|
460
|
+
declare class SourceCode$1 {
|
|
461
|
+
readonly source: string;
|
|
462
|
+
private charsList;
|
|
463
|
+
private charsIndex;
|
|
464
|
+
constructor(source: string);
|
|
465
|
+
getLocationOf(range: Range): SourceLocation;
|
|
466
|
+
current(): Chars;
|
|
467
|
+
next(): void;
|
|
468
|
+
prev(): void;
|
|
469
|
+
isEof(): boolean;
|
|
470
|
+
index(): number;
|
|
471
|
+
private createCharsList;
|
|
472
|
+
}
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region src/types/tokenizerState.d.ts
|
|
475
|
+
type TokenizerState = {
|
|
476
|
+
accumulatedContent: CharsBuffer;
|
|
477
|
+
contextParams: ContextParams;
|
|
478
|
+
currentContext: TokenizerContextTypes;
|
|
479
|
+
decisionBuffer: CharsBuffer;
|
|
480
|
+
sourceCode: SourceCode$1;
|
|
481
|
+
tokens: {
|
|
482
|
+
push(token: AnyToken): void;
|
|
483
|
+
};
|
|
484
|
+
};
|
|
485
|
+
type ContextParams = {
|
|
486
|
+
[TokenizerContextTypes.Attributes]?: {
|
|
487
|
+
tagName: string;
|
|
488
|
+
};
|
|
489
|
+
[TokenizerContextTypes.AttributeValueWrapped]?: {
|
|
490
|
+
wrapper: string;
|
|
491
|
+
};
|
|
492
|
+
[TokenizerContextTypes.DoctypeAttributeWrapped]?: {
|
|
493
|
+
wrapper: string;
|
|
494
|
+
};
|
|
495
|
+
[TokenizerContextTypes.OpenTagEnd]?: {
|
|
496
|
+
tagName: string;
|
|
497
|
+
};
|
|
498
|
+
[TokenizerContextTypes.XMLDeclarationAttributeValueWrapped]?: {
|
|
499
|
+
wrapper: string;
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/types/constructTreeState.d.ts
|
|
504
|
+
type ConstructTreeState<N extends AnyContextualNode> = {
|
|
505
|
+
caretPosition: number;
|
|
506
|
+
currentNode: N;
|
|
507
|
+
rootNode: DocumentNode;
|
|
508
|
+
currentContext: {
|
|
509
|
+
type: ConstructTreeContextTypes;
|
|
510
|
+
content?: any[];
|
|
511
|
+
parentRef?: any;
|
|
512
|
+
};
|
|
513
|
+
};
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region src/types/constructTreeHandler.d.ts
|
|
516
|
+
interface ConstructTreeHandler {
|
|
517
|
+
construct: (token: AnyToken, state: ConstructTreeState<any>) => ConstructTreeState<any>;
|
|
518
|
+
}
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region src/types/tokenizerContextHandler.d.ts
|
|
521
|
+
interface TokenizeHandler {
|
|
522
|
+
parse: (chars: CharsBuffer, state: TokenizerState) => void;
|
|
523
|
+
handleContentEnd?: (state: TokenizerState) => void;
|
|
524
|
+
}
|
|
525
|
+
declare namespace index_d_exports {
|
|
526
|
+
export { 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 };
|
|
527
|
+
}
|
|
528
|
+
//#endregion
|
|
529
|
+
//#region src/parser/parseForESLint.d.ts
|
|
530
|
+
declare function parseForESLint(source: string, options?: Options): ParseForESLintResult;
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/index.d.ts
|
|
533
|
+
declare const name: string;
|
|
534
|
+
declare const VisitorKeys: eslint0.SourceCode.VisitorKeys;
|
|
535
|
+
declare function parse(code: string, options?: Options): Program;
|
|
536
|
+
//#endregion
|
|
537
|
+
export { type index_d_exports as AST, AnyContextualNode, AnyNode, AnyToken, AttributeKeyNode, AttributeNode, AttributeValueNode, AttributeValueWrapperEndNode, AttributeValueWrapperStartNode, BaseNode, COMMENT_END, COMMENT_START, CloseTagNode, CommentCloseNode, CommentContentNode, CommentNode, CommentOpenNode, ConstructTreeContextTypes, ConstructTreeHandler, ConstructTreeState, ContextuaLXMLDeclarationNode, ContextualAttributeNode, ContextualCommentNode, ContextualDoctypeAttributeNode, ContextualDoctypeNode, ContextualDocumentNode, ContextualNode, ContextualTagNode, ContextualXMLDeclarationAttributeNode, DEPRECATED_SVG_ELEMENTS, DoctypeAttributeNode, DoctypeAttributeValueNode, DoctypeAttributeWrapperEndNode, DoctypeAttributeWrapperStartNode, DoctypeCloseNode, DoctypeNode, DoctypeOpenNode, DocumentNode, Locations, NestableNode, NodeTypes, OpenTagEndNode, OpenTagStartNode, Options, ParseError, ParseForESLintResult, ParseResult, PartialBy, Position, Program, RE_CLOSE_TAG_NAME, RE_INCOMPLETE_CLOSING_TAG, RE_OPEN_TAG_NAME, RE_OPEN_TAG_START, Range, SELF_CLOSING_ELEMENTS, SPECIAL_CHAR, SVG_ELEMENTS, SimpleNode, SourceLocation, TagNode, TextNode, Token, TokenTypes, TokenizeHandler, TokenizerContextTypes, TokenizerState, VisitorKeys, XMLDeclarationAttributeKeyNode, XMLDeclarationAttributeNode, XMLDeclarationAttributeValueNode, XMLDeclarationAttributeValueWrapperEndNode, XMLDeclarationAttributeValueWrapperStartNode, XMLDeclarationCloseNode, XMLDeclarationNode, XMLDeclarationOpenNode, XML_DECLARATION_END, XML_DECLARATION_START, meta, name, parse, parseForESLint };
|