@vue-vine/eslint-parser 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/dist/index.d.mts +795 -0
- package/dist/index.d.ts +795 -0
- package/dist/index.js +7646 -0
- package/dist/index.mjs +7646 -0
- package/package.json +48 -0
package/dist/index.d.ts
ADDED
@@ -0,0 +1,795 @@
|
|
1
|
+
import { TSESTree } from '@typescript-eslint/types';
|
2
|
+
import { parseForESLint as parseForESLint$1, ParserOptions } from '@typescript-eslint/parser';
|
3
|
+
import { ScopeManager } from 'eslint-scope';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* HTML parse errors.
|
7
|
+
*/
|
8
|
+
declare class ParseError extends SyntaxError {
|
9
|
+
code?: ErrorCode;
|
10
|
+
index: number;
|
11
|
+
lineNumber: number;
|
12
|
+
column: number;
|
13
|
+
/**
|
14
|
+
* Create new parser error object.
|
15
|
+
* @param code The error code. See also: https://html.spec.whatwg.org/multipage/parsing.html#parse-errors
|
16
|
+
* @param offset The offset number of this error.
|
17
|
+
* @param line The line number of this error.
|
18
|
+
* @param column The column number of this error.
|
19
|
+
*/
|
20
|
+
static fromCode(code: ErrorCode, offset: number, line: number, column: number): ParseError;
|
21
|
+
/**
|
22
|
+
* Normalize the error object.
|
23
|
+
* @param x The error object to normalize.
|
24
|
+
*/
|
25
|
+
static normalize(x: any): ParseError | null;
|
26
|
+
/**
|
27
|
+
* Initialize this ParseError instance.
|
28
|
+
* @param message The error message.
|
29
|
+
* @param code The error code. See also: https://html.spec.whatwg.org/multipage/parsing.html#parse-errors
|
30
|
+
* @param offset The offset number of this error.
|
31
|
+
* @param line The line number of this error.
|
32
|
+
* @param column The column number of this error.
|
33
|
+
*/
|
34
|
+
constructor(message: string, code: ErrorCode | undefined, offset: number, line: number, column: number);
|
35
|
+
/**
|
36
|
+
* Type guard for ParseError.
|
37
|
+
* @param x The value to check.
|
38
|
+
* @returns `true` if the value has `message`, `pos`, `loc` properties.
|
39
|
+
*/
|
40
|
+
static isParseError(x: any): x is ParseError;
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* The error codes of HTML syntax errors.
|
44
|
+
* https://html.spec.whatwg.org/multipage/parsing.html#parse-errors
|
45
|
+
*/
|
46
|
+
type ErrorCode = 'abrupt-closing-of-empty-comment' | 'absence-of-digits-in-numeric-character-reference' | 'cdata-in-html-content' | 'character-reference-outside-unicode-range' | 'control-character-in-input-stream' | 'control-character-reference' | 'eof-before-tag-name' | 'eof-in-cdata' | 'eof-in-comment' | 'eof-in-tag' | 'incorrectly-closed-comment' | 'incorrectly-opened-comment' | 'invalid-first-character-of-tag-name' | 'missing-attribute-value' | 'missing-end-tag-name' | 'missing-semicolon-after-character-reference' | 'missing-whitespace-between-attributes' | 'nested-comment' | 'noncharacter-character-reference' | 'noncharacter-in-input-stream' | 'null-character-reference' | 'surrogate-character-reference' | 'surrogate-in-input-stream' | 'unexpected-character-in-attribute-name' | 'unexpected-character-in-unquoted-attribute-value' | 'unexpected-equals-sign-before-attribute-name' | 'unexpected-null-character' | 'unexpected-question-mark-instead-of-tag-name' | 'unexpected-solidus-in-tag' | 'unknown-named-character-reference' | 'end-tag-with-attributes' | 'duplicate-attribute' | 'end-tag-with-trailing-solidus' | 'non-void-html-element-start-tag-with-trailing-solidus' | 'x-invalid-end-tag' | 'x-invalid-namespace' | 'x-missing-interpolation-end';
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Location information in lines and columns.
|
50
|
+
*/
|
51
|
+
interface Location {
|
52
|
+
/**
|
53
|
+
* The line number. This is 1-based.
|
54
|
+
*/
|
55
|
+
line: number;
|
56
|
+
/**
|
57
|
+
* The column number. This is 0-based.
|
58
|
+
*/
|
59
|
+
column: number;
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* Range information in lines and columns.
|
63
|
+
*/
|
64
|
+
interface LocationRange {
|
65
|
+
/**
|
66
|
+
* The start location.
|
67
|
+
*/
|
68
|
+
start: Location;
|
69
|
+
/**
|
70
|
+
* The end location.
|
71
|
+
*/
|
72
|
+
end: Location;
|
73
|
+
}
|
74
|
+
/**
|
75
|
+
* Location information in offsets.
|
76
|
+
* This is 0-based.
|
77
|
+
*/
|
78
|
+
type Offset = number;
|
79
|
+
/**
|
80
|
+
* Range information in offsets.
|
81
|
+
* The 1st element is the start offset.
|
82
|
+
* The 2nd element is the end offset.
|
83
|
+
*
|
84
|
+
* This is 0-based.
|
85
|
+
*/
|
86
|
+
type OffsetRange = [Offset, Offset];
|
87
|
+
/**
|
88
|
+
* Objects which have their location.
|
89
|
+
*/
|
90
|
+
interface HasLocation {
|
91
|
+
range: OffsetRange;
|
92
|
+
loc: LocationRange;
|
93
|
+
start?: number;
|
94
|
+
end?: number;
|
95
|
+
}
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Tokens.
|
99
|
+
*/
|
100
|
+
interface Token extends HasLocation {
|
101
|
+
/**
|
102
|
+
* Token types.
|
103
|
+
*/
|
104
|
+
type: string;
|
105
|
+
/**
|
106
|
+
* Processed values.
|
107
|
+
*/
|
108
|
+
value: string;
|
109
|
+
}
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Objects which have their parent.
|
113
|
+
*/
|
114
|
+
interface HasParent {
|
115
|
+
parent?: Node | null;
|
116
|
+
}
|
117
|
+
/**
|
118
|
+
* The union type for all nodes.
|
119
|
+
*/
|
120
|
+
type Node = ESLintNode | VNode | VForExpression | VOnExpression | VSlotScopeExpression | VFilterSequenceExpression | VFilter;
|
121
|
+
/**
|
122
|
+
* The union type for ESLint nodes.
|
123
|
+
*/
|
124
|
+
type ESLintNode = ESLintIdentifier | ESLintLiteral | ESLintProgram | ESLintSwitchCase | ESLintCatchClause | ESLintVariableDeclarator | ESLintStatement | ESLintExpression | ESLintProperty | ESLintAssignmentProperty | ESLintSuper | ESLintTemplateElement | ESLintSpreadElement | ESLintPattern | ESLintClassBody | ESLintMethodDefinition | ESLintPropertyDefinition | ESLintStaticBlock | ESLintPrivateIdentifier | ESLintModuleDeclaration | ESLintModuleSpecifier | ESLintImportExpression | ESLintLegacyRestProperty;
|
125
|
+
/**
|
126
|
+
* The parsing result of ESLint custom parsers.
|
127
|
+
*/
|
128
|
+
interface ESLintExtendedProgram {
|
129
|
+
ast: ESLintProgram;
|
130
|
+
services?: Record<string, unknown>;
|
131
|
+
visitorKeys?: {
|
132
|
+
[type: string]: string[];
|
133
|
+
};
|
134
|
+
scopeManager?: ScopeManager;
|
135
|
+
}
|
136
|
+
interface ESLintProgram extends HasLocation, HasParent {
|
137
|
+
type: 'Program';
|
138
|
+
sourceType: 'script' | 'module';
|
139
|
+
body: (ESLintStatement | ESLintModuleDeclaration)[];
|
140
|
+
templateBody?: VElement & HasConcreteInfo;
|
141
|
+
tokens?: Token[];
|
142
|
+
comments?: Token[];
|
143
|
+
errors?: ParseError[];
|
144
|
+
}
|
145
|
+
type ESLintStatement = ESLintExpressionStatement | ESLintBlockStatement | ESLintEmptyStatement | ESLintDebuggerStatement | ESLintWithStatement | ESLintReturnStatement | ESLintLabeledStatement | ESLintBreakStatement | ESLintContinueStatement | ESLintIfStatement | ESLintSwitchStatement | ESLintThrowStatement | ESLintTryStatement | ESLintWhileStatement | ESLintDoWhileStatement | ESLintForStatement | ESLintForInStatement | ESLintForOfStatement | ESLintDeclaration;
|
146
|
+
interface ESLintEmptyStatement extends HasLocation, HasParent {
|
147
|
+
type: 'EmptyStatement';
|
148
|
+
}
|
149
|
+
interface ESLintBlockStatement extends HasLocation, HasParent {
|
150
|
+
type: 'BlockStatement';
|
151
|
+
body: ESLintStatement[];
|
152
|
+
}
|
153
|
+
interface ESLintExpressionStatement extends HasLocation, HasParent {
|
154
|
+
type: 'ExpressionStatement';
|
155
|
+
expression: ESLintExpression;
|
156
|
+
}
|
157
|
+
interface ESLintIfStatement extends HasLocation, HasParent {
|
158
|
+
type: 'IfStatement';
|
159
|
+
test: ESLintExpression;
|
160
|
+
consequent: ESLintStatement;
|
161
|
+
alternate: ESLintStatement | null;
|
162
|
+
}
|
163
|
+
interface ESLintSwitchStatement extends HasLocation, HasParent {
|
164
|
+
type: 'SwitchStatement';
|
165
|
+
discriminant: ESLintExpression;
|
166
|
+
cases: ESLintSwitchCase[];
|
167
|
+
}
|
168
|
+
interface ESLintSwitchCase extends HasLocation, HasParent {
|
169
|
+
type: 'SwitchCase';
|
170
|
+
test: ESLintExpression | null;
|
171
|
+
consequent: ESLintStatement[];
|
172
|
+
}
|
173
|
+
interface ESLintWhileStatement extends HasLocation, HasParent {
|
174
|
+
type: 'WhileStatement';
|
175
|
+
test: ESLintExpression;
|
176
|
+
body: ESLintStatement;
|
177
|
+
}
|
178
|
+
interface ESLintDoWhileStatement extends HasLocation, HasParent {
|
179
|
+
type: 'DoWhileStatement';
|
180
|
+
body: ESLintStatement;
|
181
|
+
test: ESLintExpression;
|
182
|
+
}
|
183
|
+
interface ESLintForStatement extends HasLocation, HasParent {
|
184
|
+
type: 'ForStatement';
|
185
|
+
init: ESLintVariableDeclaration | ESLintExpression | null;
|
186
|
+
test: ESLintExpression | null;
|
187
|
+
update: ESLintExpression | null;
|
188
|
+
body: ESLintStatement;
|
189
|
+
}
|
190
|
+
interface ESLintForInStatement extends HasLocation, HasParent {
|
191
|
+
type: 'ForInStatement';
|
192
|
+
left: ESLintVariableDeclaration | ESLintPattern;
|
193
|
+
right: ESLintExpression;
|
194
|
+
body: ESLintStatement;
|
195
|
+
}
|
196
|
+
interface ESLintForOfStatement extends HasLocation, HasParent {
|
197
|
+
type: 'ForOfStatement';
|
198
|
+
left: ESLintVariableDeclaration | ESLintPattern;
|
199
|
+
right: ESLintExpression;
|
200
|
+
body: ESLintStatement;
|
201
|
+
await: boolean;
|
202
|
+
}
|
203
|
+
interface ESLintLabeledStatement extends HasLocation, HasParent {
|
204
|
+
type: 'LabeledStatement';
|
205
|
+
label: ESLintIdentifier;
|
206
|
+
body: ESLintStatement;
|
207
|
+
}
|
208
|
+
interface ESLintBreakStatement extends HasLocation, HasParent {
|
209
|
+
type: 'BreakStatement';
|
210
|
+
label: ESLintIdentifier | null;
|
211
|
+
}
|
212
|
+
interface ESLintContinueStatement extends HasLocation, HasParent {
|
213
|
+
type: 'ContinueStatement';
|
214
|
+
label: ESLintIdentifier | null;
|
215
|
+
}
|
216
|
+
interface ESLintReturnStatement extends HasLocation, HasParent {
|
217
|
+
type: 'ReturnStatement';
|
218
|
+
argument: ESLintExpression | null;
|
219
|
+
}
|
220
|
+
interface ESLintThrowStatement extends HasLocation, HasParent {
|
221
|
+
type: 'ThrowStatement';
|
222
|
+
argument: ESLintExpression;
|
223
|
+
}
|
224
|
+
interface ESLintTryStatement extends HasLocation, HasParent {
|
225
|
+
type: 'TryStatement';
|
226
|
+
block: ESLintBlockStatement;
|
227
|
+
handler: ESLintCatchClause | null;
|
228
|
+
finalizer: ESLintBlockStatement | null;
|
229
|
+
}
|
230
|
+
interface ESLintCatchClause extends HasLocation, HasParent {
|
231
|
+
type: 'CatchClause';
|
232
|
+
param: ESLintPattern | null;
|
233
|
+
body: ESLintBlockStatement;
|
234
|
+
}
|
235
|
+
interface ESLintWithStatement extends HasLocation, HasParent {
|
236
|
+
type: 'WithStatement';
|
237
|
+
object: ESLintExpression;
|
238
|
+
body: ESLintStatement;
|
239
|
+
}
|
240
|
+
interface ESLintDebuggerStatement extends HasLocation, HasParent {
|
241
|
+
type: 'DebuggerStatement';
|
242
|
+
}
|
243
|
+
type ESLintDeclaration = ESLintFunctionDeclaration | ESLintVariableDeclaration | ESLintClassDeclaration;
|
244
|
+
interface ESLintFunctionDeclaration extends HasLocation, HasParent {
|
245
|
+
type: 'FunctionDeclaration';
|
246
|
+
async: boolean;
|
247
|
+
generator: boolean;
|
248
|
+
id: ESLintIdentifier | null;
|
249
|
+
params: ESLintPattern[];
|
250
|
+
body: ESLintBlockStatement;
|
251
|
+
}
|
252
|
+
interface ESLintVariableDeclaration extends HasLocation, HasParent {
|
253
|
+
type: 'VariableDeclaration';
|
254
|
+
kind: 'var' | 'let' | 'const';
|
255
|
+
declarations: ESLintVariableDeclarator[];
|
256
|
+
}
|
257
|
+
interface ESLintVariableDeclarator extends HasLocation, HasParent {
|
258
|
+
type: 'VariableDeclarator';
|
259
|
+
id: ESLintPattern;
|
260
|
+
init: ESLintExpression | null;
|
261
|
+
}
|
262
|
+
interface ESLintClassDeclaration extends HasLocation, HasParent {
|
263
|
+
type: 'ClassDeclaration';
|
264
|
+
id: ESLintIdentifier | null;
|
265
|
+
superClass: ESLintExpression | null;
|
266
|
+
body: ESLintClassBody;
|
267
|
+
}
|
268
|
+
interface ESLintClassBody extends HasLocation, HasParent {
|
269
|
+
type: 'ClassBody';
|
270
|
+
body: (ESLintMethodDefinition | ESLintPropertyDefinition | ESLintStaticBlock)[];
|
271
|
+
}
|
272
|
+
interface ESLintMethodDefinition extends HasLocation, HasParent {
|
273
|
+
type: 'MethodDefinition';
|
274
|
+
kind: 'constructor' | 'method' | 'get' | 'set';
|
275
|
+
computed: boolean;
|
276
|
+
static: boolean;
|
277
|
+
key: ESLintExpression | ESLintPrivateIdentifier;
|
278
|
+
value: ESLintFunctionExpression;
|
279
|
+
}
|
280
|
+
interface ESLintPropertyDefinition extends HasLocation, HasParent {
|
281
|
+
type: 'PropertyDefinition';
|
282
|
+
computed: boolean;
|
283
|
+
static: boolean;
|
284
|
+
key: ESLintExpression | ESLintPrivateIdentifier;
|
285
|
+
value: ESLintExpression | null;
|
286
|
+
}
|
287
|
+
interface ESLintStaticBlock extends HasLocation, HasParent, Omit<ESLintBlockStatement, 'type'> {
|
288
|
+
type: 'StaticBlock';
|
289
|
+
body: ESLintStatement[];
|
290
|
+
}
|
291
|
+
interface ESLintPrivateIdentifier extends HasLocation, HasParent {
|
292
|
+
type: 'PrivateIdentifier';
|
293
|
+
name: string;
|
294
|
+
}
|
295
|
+
type ESLintModuleDeclaration = ESLintImportDeclaration | ESLintExportNamedDeclaration | ESLintExportDefaultDeclaration | ESLintExportAllDeclaration;
|
296
|
+
type ESLintModuleSpecifier = ESLintImportSpecifier | ESLintImportDefaultSpecifier | ESLintImportNamespaceSpecifier | ESLintExportSpecifier;
|
297
|
+
interface ESLintImportDeclaration extends HasLocation, HasParent {
|
298
|
+
type: 'ImportDeclaration';
|
299
|
+
specifiers: (ESLintImportSpecifier | ESLintImportDefaultSpecifier | ESLintImportNamespaceSpecifier)[];
|
300
|
+
source: ESLintLiteral;
|
301
|
+
}
|
302
|
+
interface ESLintImportSpecifier extends HasLocation, HasParent {
|
303
|
+
type: 'ImportSpecifier';
|
304
|
+
imported: ESLintIdentifier | ESLintStringLiteral;
|
305
|
+
local: ESLintIdentifier;
|
306
|
+
}
|
307
|
+
interface ESLintImportDefaultSpecifier extends HasLocation, HasParent {
|
308
|
+
type: 'ImportDefaultSpecifier';
|
309
|
+
local: ESLintIdentifier;
|
310
|
+
}
|
311
|
+
interface ESLintImportNamespaceSpecifier extends HasLocation, HasParent {
|
312
|
+
type: 'ImportNamespaceSpecifier';
|
313
|
+
local: ESLintIdentifier;
|
314
|
+
}
|
315
|
+
interface ESLintImportExpression extends HasLocation, HasParent {
|
316
|
+
type: 'ImportExpression';
|
317
|
+
source: ESLintExpression;
|
318
|
+
}
|
319
|
+
interface ESLintExportNamedDeclaration extends HasLocation, HasParent {
|
320
|
+
type: 'ExportNamedDeclaration';
|
321
|
+
declaration?: ESLintDeclaration | null;
|
322
|
+
specifiers: ESLintExportSpecifier[];
|
323
|
+
source?: ESLintLiteral | null;
|
324
|
+
}
|
325
|
+
interface ESLintExportSpecifier extends HasLocation, HasParent {
|
326
|
+
type: 'ExportSpecifier';
|
327
|
+
local: ESLintIdentifier | ESLintStringLiteral;
|
328
|
+
exported: ESLintIdentifier | ESLintStringLiteral;
|
329
|
+
}
|
330
|
+
interface ESLintExportDefaultDeclaration extends HasLocation, HasParent {
|
331
|
+
type: 'ExportDefaultDeclaration';
|
332
|
+
declaration: ESLintDeclaration | ESLintExpression;
|
333
|
+
}
|
334
|
+
interface ESLintExportAllDeclaration extends HasLocation, HasParent {
|
335
|
+
type: 'ExportAllDeclaration';
|
336
|
+
exported: ESLintIdentifier | ESLintStringLiteral | null;
|
337
|
+
source: ESLintLiteral;
|
338
|
+
}
|
339
|
+
type ESLintExpression = ESLintThisExpression | ESLintArrayExpression | ESLintObjectExpression | ESLintFunctionExpression | ESLintArrowFunctionExpression | ESLintYieldExpression | ESLintLiteral | ESLintUnaryExpression | ESLintUpdateExpression | ESLintBinaryExpression | ESLintAssignmentExpression | ESLintLogicalExpression | ESLintMemberExpression | ESLintConditionalExpression | ESLintCallExpression | ESLintNewExpression | ESLintSequenceExpression | ESLintTemplateLiteral | ESLintTaggedTemplateExpression | ESLintClassExpression | ESLintMetaProperty | ESLintIdentifier | ESLintAwaitExpression | ESLintChainExpression;
|
340
|
+
interface ESLintIdentifier extends HasLocation, HasParent {
|
341
|
+
type: 'Identifier';
|
342
|
+
name: string;
|
343
|
+
}
|
344
|
+
interface ESLintLiteralBase extends HasLocation, HasParent {
|
345
|
+
type: 'Literal';
|
346
|
+
value: string | boolean | null | number | RegExp | bigint;
|
347
|
+
raw: string;
|
348
|
+
regex?: {
|
349
|
+
pattern: string;
|
350
|
+
flags: string;
|
351
|
+
};
|
352
|
+
bigint?: string;
|
353
|
+
}
|
354
|
+
interface ESLintStringLiteral extends ESLintLiteralBase {
|
355
|
+
value: string;
|
356
|
+
regex?: undefined;
|
357
|
+
bigint?: undefined;
|
358
|
+
}
|
359
|
+
interface ESLintBooleanLiteral extends ESLintLiteralBase {
|
360
|
+
value: boolean;
|
361
|
+
regex?: undefined;
|
362
|
+
bigint?: undefined;
|
363
|
+
}
|
364
|
+
interface ESLintNullLiteral extends ESLintLiteralBase {
|
365
|
+
value: null;
|
366
|
+
regex?: undefined;
|
367
|
+
bigint?: undefined;
|
368
|
+
}
|
369
|
+
interface ESLintNumberLiteral extends ESLintLiteralBase {
|
370
|
+
value: number;
|
371
|
+
regex?: undefined;
|
372
|
+
bigint?: undefined;
|
373
|
+
}
|
374
|
+
interface ESLintRegExpLiteral extends ESLintLiteralBase {
|
375
|
+
value: null | RegExp;
|
376
|
+
regex: {
|
377
|
+
pattern: string;
|
378
|
+
flags: string;
|
379
|
+
};
|
380
|
+
bigint?: undefined;
|
381
|
+
}
|
382
|
+
interface ESLintBigIntLiteral extends ESLintLiteralBase {
|
383
|
+
value: null | bigint;
|
384
|
+
regex?: undefined;
|
385
|
+
bigint: string;
|
386
|
+
}
|
387
|
+
type ESLintLiteral = ESLintStringLiteral | ESLintBooleanLiteral | ESLintNullLiteral | ESLintNumberLiteral | ESLintRegExpLiteral | ESLintBigIntLiteral;
|
388
|
+
interface ESLintThisExpression extends HasLocation, HasParent {
|
389
|
+
type: 'ThisExpression';
|
390
|
+
}
|
391
|
+
interface ESLintArrayExpression extends HasLocation, HasParent {
|
392
|
+
type: 'ArrayExpression';
|
393
|
+
elements: (ESLintExpression | ESLintSpreadElement)[];
|
394
|
+
}
|
395
|
+
interface ESLintObjectExpression extends HasLocation, HasParent {
|
396
|
+
type: 'ObjectExpression';
|
397
|
+
properties: (ESLintProperty | ESLintSpreadElement | ESLintLegacySpreadProperty)[];
|
398
|
+
}
|
399
|
+
interface ESLintProperty extends HasLocation, HasParent {
|
400
|
+
type: 'Property';
|
401
|
+
kind: 'init' | 'get' | 'set';
|
402
|
+
method: boolean;
|
403
|
+
shorthand: boolean;
|
404
|
+
computed: boolean;
|
405
|
+
key: ESLintExpression;
|
406
|
+
value: ESLintExpression | ESLintPattern;
|
407
|
+
}
|
408
|
+
interface ESLintFunctionExpression extends HasLocation, HasParent {
|
409
|
+
type: 'FunctionExpression';
|
410
|
+
async: boolean;
|
411
|
+
generator: boolean;
|
412
|
+
id: ESLintIdentifier | null;
|
413
|
+
params: ESLintPattern[];
|
414
|
+
body: ESLintBlockStatement;
|
415
|
+
}
|
416
|
+
interface ESLintArrowFunctionExpression extends HasLocation, HasParent {
|
417
|
+
type: 'ArrowFunctionExpression';
|
418
|
+
async: boolean;
|
419
|
+
generator: boolean;
|
420
|
+
id: ESLintIdentifier | null;
|
421
|
+
params: ESLintPattern[];
|
422
|
+
body: ESLintBlockStatement;
|
423
|
+
}
|
424
|
+
interface ESLintSequenceExpression extends HasLocation, HasParent {
|
425
|
+
type: 'SequenceExpression';
|
426
|
+
expressions: ESLintExpression[];
|
427
|
+
}
|
428
|
+
interface ESLintUnaryExpression extends HasLocation, HasParent {
|
429
|
+
type: 'UnaryExpression';
|
430
|
+
operator: '-' | '+' | '!' | '~' | 'typeof' | 'void' | 'delete';
|
431
|
+
prefix: boolean;
|
432
|
+
argument: ESLintExpression;
|
433
|
+
}
|
434
|
+
interface ESLintBinaryExpression extends HasLocation, HasParent {
|
435
|
+
type: 'BinaryExpression';
|
436
|
+
operator: '==' | '!=' | '===' | '!==' | '<' | '<=' | '>' | '>=' | '<<' | '>>' | '>>>' | '+' | '-' | '*' | '/' | '%' | '**' | '|' | '^' | '&' | 'in' | 'instanceof';
|
437
|
+
left: ESLintExpression | ESLintPrivateIdentifier;
|
438
|
+
right: ESLintExpression;
|
439
|
+
}
|
440
|
+
interface ESLintAssignmentExpression extends HasLocation, HasParent {
|
441
|
+
type: 'AssignmentExpression';
|
442
|
+
operator: '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '**=' | '<<=' | '>>=' | '>>>=' | '|=' | '^=' | '&=' | '||=' | '&&=' | '??=';
|
443
|
+
left: ESLintPattern;
|
444
|
+
right: ESLintExpression;
|
445
|
+
}
|
446
|
+
interface ESLintUpdateExpression extends HasLocation, HasParent {
|
447
|
+
type: 'UpdateExpression';
|
448
|
+
operator: '++' | '--';
|
449
|
+
argument: ESLintExpression;
|
450
|
+
prefix: boolean;
|
451
|
+
}
|
452
|
+
interface ESLintLogicalExpression extends HasLocation, HasParent {
|
453
|
+
type: 'LogicalExpression';
|
454
|
+
operator: '||' | '&&' | '??';
|
455
|
+
left: ESLintExpression;
|
456
|
+
right: ESLintExpression;
|
457
|
+
}
|
458
|
+
interface ESLintConditionalExpression extends HasLocation, HasParent {
|
459
|
+
type: 'ConditionalExpression';
|
460
|
+
test: ESLintExpression;
|
461
|
+
alternate: ESLintExpression;
|
462
|
+
consequent: ESLintExpression;
|
463
|
+
}
|
464
|
+
interface ESLintCallExpression extends HasLocation, HasParent {
|
465
|
+
type: 'CallExpression';
|
466
|
+
optional: boolean;
|
467
|
+
callee: ESLintExpression | ESLintSuper;
|
468
|
+
arguments: (ESLintExpression | ESLintSpreadElement)[];
|
469
|
+
}
|
470
|
+
interface ESLintSuper extends HasLocation, HasParent {
|
471
|
+
type: 'Super';
|
472
|
+
}
|
473
|
+
interface ESLintNewExpression extends HasLocation, HasParent {
|
474
|
+
type: 'NewExpression';
|
475
|
+
callee: ESLintExpression;
|
476
|
+
arguments: (ESLintExpression | ESLintSpreadElement)[];
|
477
|
+
}
|
478
|
+
interface ESLintMemberExpression extends HasLocation, HasParent {
|
479
|
+
type: 'MemberExpression';
|
480
|
+
optional: boolean;
|
481
|
+
computed: boolean;
|
482
|
+
object: ESLintExpression | ESLintSuper;
|
483
|
+
property: ESLintExpression | ESLintPrivateIdentifier;
|
484
|
+
}
|
485
|
+
interface ESLintYieldExpression extends HasLocation, HasParent {
|
486
|
+
type: 'YieldExpression';
|
487
|
+
delegate: boolean;
|
488
|
+
argument: ESLintExpression | null;
|
489
|
+
}
|
490
|
+
interface ESLintAwaitExpression extends HasLocation, HasParent {
|
491
|
+
type: 'AwaitExpression';
|
492
|
+
argument: ESLintExpression;
|
493
|
+
}
|
494
|
+
interface ESLintTemplateLiteral extends HasLocation, HasParent {
|
495
|
+
type: 'TemplateLiteral';
|
496
|
+
quasis: ESLintTemplateElement[];
|
497
|
+
expressions: ESLintExpression[];
|
498
|
+
}
|
499
|
+
interface ESLintTaggedTemplateExpression extends HasLocation, HasParent {
|
500
|
+
type: 'TaggedTemplateExpression';
|
501
|
+
tag: ESLintExpression;
|
502
|
+
quasi: ESLintTemplateLiteral;
|
503
|
+
}
|
504
|
+
interface ESLintTemplateElement extends HasLocation, HasParent {
|
505
|
+
type: 'TemplateElement';
|
506
|
+
tail: boolean;
|
507
|
+
value: {
|
508
|
+
cooked: string | null;
|
509
|
+
raw: string;
|
510
|
+
};
|
511
|
+
}
|
512
|
+
interface ESLintClassExpression extends HasLocation, HasParent {
|
513
|
+
type: 'ClassExpression';
|
514
|
+
id: ESLintIdentifier | null;
|
515
|
+
superClass: ESLintExpression | null;
|
516
|
+
body: ESLintClassBody;
|
517
|
+
}
|
518
|
+
interface ESLintMetaProperty extends HasLocation, HasParent {
|
519
|
+
type: 'MetaProperty';
|
520
|
+
meta: ESLintIdentifier;
|
521
|
+
property: ESLintIdentifier;
|
522
|
+
}
|
523
|
+
type ESLintPattern = ESLintIdentifier | ESLintObjectPattern | ESLintArrayPattern | ESLintRestElement | ESLintAssignmentPattern | ESLintMemberExpression | ESLintLegacyRestProperty;
|
524
|
+
interface ESLintObjectPattern extends HasLocation, HasParent {
|
525
|
+
type: 'ObjectPattern';
|
526
|
+
properties: (ESLintAssignmentProperty | ESLintRestElement | ESLintLegacyRestProperty)[];
|
527
|
+
}
|
528
|
+
interface ESLintAssignmentProperty extends ESLintProperty {
|
529
|
+
value: ESLintPattern;
|
530
|
+
kind: 'init';
|
531
|
+
method: false;
|
532
|
+
}
|
533
|
+
interface ESLintArrayPattern extends HasLocation, HasParent {
|
534
|
+
type: 'ArrayPattern';
|
535
|
+
elements: ESLintPattern[];
|
536
|
+
}
|
537
|
+
interface ESLintRestElement extends HasLocation, HasParent {
|
538
|
+
type: 'RestElement';
|
539
|
+
argument: ESLintPattern;
|
540
|
+
}
|
541
|
+
interface ESLintSpreadElement extends HasLocation, HasParent {
|
542
|
+
type: 'SpreadElement';
|
543
|
+
argument: ESLintExpression;
|
544
|
+
}
|
545
|
+
interface ESLintAssignmentPattern extends HasLocation, HasParent {
|
546
|
+
type: 'AssignmentPattern';
|
547
|
+
left: ESLintPattern;
|
548
|
+
right: ESLintExpression;
|
549
|
+
}
|
550
|
+
type ESLintChainElement = ESLintCallExpression | ESLintMemberExpression;
|
551
|
+
interface ESLintChainExpression extends HasLocation, HasParent {
|
552
|
+
type: 'ChainExpression';
|
553
|
+
expression: ESLintChainElement;
|
554
|
+
}
|
555
|
+
/**
|
556
|
+
* Legacy for babel-eslint and espree.
|
557
|
+
*/
|
558
|
+
interface ESLintLegacyRestProperty extends HasLocation, HasParent {
|
559
|
+
type: 'RestProperty' | 'ExperimentalRestProperty';
|
560
|
+
argument: ESLintPattern;
|
561
|
+
}
|
562
|
+
/**
|
563
|
+
* Legacy for babel-eslint and espree.
|
564
|
+
*/
|
565
|
+
interface ESLintLegacySpreadProperty extends HasLocation, HasParent {
|
566
|
+
type: 'SpreadProperty' | 'ExperimentalSpreadProperty';
|
567
|
+
argument: ESLintExpression;
|
568
|
+
}
|
569
|
+
/**
|
570
|
+
* Constants of namespaces.
|
571
|
+
* @see https://infra.spec.whatwg.org/#namespaces
|
572
|
+
*/
|
573
|
+
declare const NS: Readonly<{
|
574
|
+
HTML: "http://www.w3.org/1999/xhtml";
|
575
|
+
MathML: "http://www.w3.org/1998/Math/MathML";
|
576
|
+
SVG: "http://www.w3.org/2000/svg";
|
577
|
+
XLink: "http://www.w3.org/1999/xlink";
|
578
|
+
XML: "http://www.w3.org/XML/1998/namespace";
|
579
|
+
XMLNS: "http://www.w3.org/2000/xmlns/";
|
580
|
+
}>;
|
581
|
+
/**
|
582
|
+
* Type of namespaces.
|
583
|
+
*/
|
584
|
+
type Namespace = typeof NS.HTML | typeof NS.MathML | typeof NS.SVG | typeof NS.XLink | typeof NS.XML | typeof NS.XMLNS;
|
585
|
+
/**
|
586
|
+
* Type of variable definitions.
|
587
|
+
*/
|
588
|
+
interface Variable {
|
589
|
+
id: ESLintIdentifier;
|
590
|
+
kind: 'v-for' | 'scope';
|
591
|
+
references: Reference[];
|
592
|
+
}
|
593
|
+
/**
|
594
|
+
* Type of variable references.
|
595
|
+
*/
|
596
|
+
interface Reference {
|
597
|
+
id: ESLintIdentifier;
|
598
|
+
mode: 'rw' | 'r' | 'w';
|
599
|
+
variable: Variable | null;
|
600
|
+
isValueReference?: boolean;
|
601
|
+
isTypeReference?: boolean;
|
602
|
+
}
|
603
|
+
/**
|
604
|
+
* The node of `v-for` directives.
|
605
|
+
*/
|
606
|
+
interface VForExpression extends HasLocation, HasParent {
|
607
|
+
type: 'VForExpression';
|
608
|
+
parent: VExpressionContainer;
|
609
|
+
left: ESLintPattern[];
|
610
|
+
right: ESLintExpression;
|
611
|
+
}
|
612
|
+
/**
|
613
|
+
* The node of `v-on` directives.
|
614
|
+
*/
|
615
|
+
interface VOnExpression extends HasLocation, HasParent {
|
616
|
+
type: 'VOnExpression';
|
617
|
+
parent: VExpressionContainer;
|
618
|
+
body: ESLintStatement[];
|
619
|
+
}
|
620
|
+
/**
|
621
|
+
* The node of `slot-scope` directives.
|
622
|
+
*/
|
623
|
+
interface VSlotScopeExpression extends HasLocation, HasParent {
|
624
|
+
type: 'VSlotScopeExpression';
|
625
|
+
parent: VExpressionContainer;
|
626
|
+
params: ESLintPattern[];
|
627
|
+
}
|
628
|
+
/**
|
629
|
+
* The node of a filter sequence which is separated by `|`.
|
630
|
+
*/
|
631
|
+
interface VFilterSequenceExpression extends HasLocation, HasParent {
|
632
|
+
type: 'VFilterSequenceExpression';
|
633
|
+
parent: VExpressionContainer;
|
634
|
+
expression: ESLintExpression;
|
635
|
+
filters: VFilter[];
|
636
|
+
}
|
637
|
+
/**
|
638
|
+
* The node of a filter sequence which is separated by `|`.
|
639
|
+
*/
|
640
|
+
interface VFilter extends HasLocation, HasParent {
|
641
|
+
type: 'VFilter';
|
642
|
+
parent: VFilterSequenceExpression;
|
643
|
+
callee: ESLintIdentifier;
|
644
|
+
arguments: (ESLintExpression | ESLintSpreadElement)[];
|
645
|
+
}
|
646
|
+
/**
|
647
|
+
* The union type of any nodes.
|
648
|
+
*/
|
649
|
+
type VNode = VAttribute | VDirective | VDirectiveKey | VTemplateRoot | VElement | VEndTag | VExpressionContainer | VIdentifier | VLiteral | VStartTag | VText;
|
650
|
+
/**
|
651
|
+
* Text nodes.
|
652
|
+
*/
|
653
|
+
interface VText extends HasLocation, HasParent {
|
654
|
+
type: 'VText';
|
655
|
+
parent: VTemplateRoot | VElement;
|
656
|
+
value: string;
|
657
|
+
}
|
658
|
+
/**
|
659
|
+
* The node of JavaScript expression in text.
|
660
|
+
* e.g. `{{ name }}`
|
661
|
+
*/
|
662
|
+
interface VExpressionContainer extends HasLocation, HasParent {
|
663
|
+
type: 'VExpressionContainer';
|
664
|
+
parent: VTemplateRoot | VElement | VDirective | VDirectiveKey;
|
665
|
+
expression: ESLintExpression | VFilterSequenceExpression | VForExpression | VOnExpression | VSlotScopeExpression | null;
|
666
|
+
references: Reference[];
|
667
|
+
}
|
668
|
+
/**
|
669
|
+
* Attribute name nodes.
|
670
|
+
*/
|
671
|
+
interface VIdentifier extends HasLocation, HasParent {
|
672
|
+
type: 'VIdentifier';
|
673
|
+
parent: VAttribute | VDirectiveKey;
|
674
|
+
name: string;
|
675
|
+
rawName: string;
|
676
|
+
}
|
677
|
+
/**
|
678
|
+
* Attribute name nodes.
|
679
|
+
*/
|
680
|
+
interface VDirectiveKey extends HasLocation, HasParent {
|
681
|
+
type: 'VDirectiveKey';
|
682
|
+
parent: VDirective;
|
683
|
+
name: VIdentifier;
|
684
|
+
argument: VExpressionContainer | VIdentifier | null;
|
685
|
+
modifiers: VIdentifier[];
|
686
|
+
}
|
687
|
+
/**
|
688
|
+
* Attribute value nodes.
|
689
|
+
*/
|
690
|
+
interface VLiteral extends HasLocation, HasParent {
|
691
|
+
type: 'VLiteral';
|
692
|
+
parent: VAttribute;
|
693
|
+
value: string;
|
694
|
+
}
|
695
|
+
/**
|
696
|
+
* Static attribute nodes.
|
697
|
+
*/
|
698
|
+
interface VAttribute extends HasLocation, HasParent {
|
699
|
+
type: 'VAttribute';
|
700
|
+
parent: VStartTag;
|
701
|
+
directive: false;
|
702
|
+
key: VIdentifier;
|
703
|
+
value: VLiteral | null;
|
704
|
+
}
|
705
|
+
/**
|
706
|
+
* Directive nodes.
|
707
|
+
*/
|
708
|
+
interface VDirective extends HasLocation, HasParent {
|
709
|
+
type: 'VAttribute';
|
710
|
+
parent: VStartTag;
|
711
|
+
directive: true;
|
712
|
+
key: VDirectiveKey;
|
713
|
+
value: VExpressionContainer | null;
|
714
|
+
}
|
715
|
+
/**
|
716
|
+
* Start tag nodes.
|
717
|
+
*/
|
718
|
+
interface VStartTag extends HasLocation, HasParent {
|
719
|
+
type: 'VStartTag';
|
720
|
+
parent: VElement;
|
721
|
+
selfClosing: boolean;
|
722
|
+
attributes: (VAttribute | VDirective)[];
|
723
|
+
}
|
724
|
+
/**
|
725
|
+
* End tag nodes.
|
726
|
+
*/
|
727
|
+
interface VEndTag extends HasLocation, HasParent {
|
728
|
+
type: 'VEndTag';
|
729
|
+
parent: VElement;
|
730
|
+
}
|
731
|
+
/**
|
732
|
+
* The property which has concrete information.
|
733
|
+
*/
|
734
|
+
interface HasConcreteInfo {
|
735
|
+
tokens: Token[];
|
736
|
+
comments: Token[];
|
737
|
+
errors: ParseError[];
|
738
|
+
}
|
739
|
+
/**
|
740
|
+
* Element nodes.
|
741
|
+
*/
|
742
|
+
interface VElement extends HasLocation, HasParent {
|
743
|
+
type: 'VElement';
|
744
|
+
parent: VTemplateRoot | VElement;
|
745
|
+
namespace: Namespace;
|
746
|
+
name: string;
|
747
|
+
rawName: string;
|
748
|
+
startTag: VStartTag;
|
749
|
+
children: (VElement | VText | VExpressionContainer)[];
|
750
|
+
endTag: VEndTag | null;
|
751
|
+
variables: Variable[];
|
752
|
+
}
|
753
|
+
/**
|
754
|
+
* Root nodes.
|
755
|
+
*/
|
756
|
+
interface VTemplateRoot extends HasLocation {
|
757
|
+
type: 'VTemplateRoot';
|
758
|
+
parent: TSESTree.Node;
|
759
|
+
children: (VElement | VText | VExpressionContainer)[];
|
760
|
+
}
|
761
|
+
|
762
|
+
/**
|
763
|
+
* The type of basic ESLint custom parser.
|
764
|
+
* e.g. espree
|
765
|
+
*/
|
766
|
+
interface BasicParserObject<R = ESLintProgram> {
|
767
|
+
parse: (code: string, options: any) => R;
|
768
|
+
parseForESLint: undefined;
|
769
|
+
}
|
770
|
+
/**
|
771
|
+
* The type of ESLint custom parser enhanced for ESLint.
|
772
|
+
* e.g. @babel/eslint-parser, @typescript-eslint/parser
|
773
|
+
*/
|
774
|
+
interface EnhancedParserObject<R = ESLintExtendedProgram> {
|
775
|
+
parseForESLint: (code: string, options: any) => R;
|
776
|
+
parse: undefined;
|
777
|
+
}
|
778
|
+
/**
|
779
|
+
* The type of ESLint (custom) parsers.
|
780
|
+
*/
|
781
|
+
type ParserObject<R1 = ESLintExtendedProgram, R2 = ESLintProgram> = EnhancedParserObject<R1> | BasicParserObject<R2>;
|
782
|
+
|
783
|
+
type VineESLintAST = TSESTree.Program;
|
784
|
+
type ParseForESLintResult = ReturnType<typeof parseForESLint$1>;
|
785
|
+
type VineESLintParserOptions = ParserOptions & {
|
786
|
+
parser?: boolean | string | ParserObject | Record<string, string | ParserObject | undefined>;
|
787
|
+
ecmaFeatures?: ParserOptions['ecmaFeatures'] & {
|
788
|
+
[key: string]: any;
|
789
|
+
};
|
790
|
+
};
|
791
|
+
|
792
|
+
declare function parse(code: string, parserOptions: VineESLintParserOptions): VineESLintAST;
|
793
|
+
declare function parseForESLint(code: string, parserOptions: VineESLintParserOptions): ParseForESLintResult;
|
794
|
+
|
795
|
+
export { parse, parseForESLint };
|