astro-eslint-parser 2.0.0 → 3.0.0
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/lib/index.d.mts +113 -18
- package/lib/index.mjs +880 -1182
- package/package.json +10 -13
package/lib/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TSESTree } from "@typescript-eslint/types";
|
|
2
2
|
import { ScopeManager } from "@typescript-eslint/scope-manager";
|
|
3
|
-
import
|
|
4
|
-
import { AttributeNode, Node, ParentNode } from "@astrojs/compiler/types";
|
|
3
|
+
import * as compilerBinding from "@astrojs/compiler-binding";
|
|
5
4
|
import { VisitorKeys as VisitorKeys$1 } from "@typescript-eslint/visitor-keys";
|
|
6
5
|
|
|
7
6
|
//#region src/context/index.d.ts
|
|
@@ -42,7 +41,6 @@ declare class Context {
|
|
|
42
41
|
declare class LinesAndColumns {
|
|
43
42
|
private readonly lineStartIndices;
|
|
44
43
|
private readonly code;
|
|
45
|
-
private readonly normalizedLineFeed;
|
|
46
44
|
constructor(origCode: string);
|
|
47
45
|
getLocFromIndex(index: number): {
|
|
48
46
|
line: number;
|
|
@@ -52,17 +50,6 @@ declare class LinesAndColumns {
|
|
|
52
50
|
line: number;
|
|
53
51
|
column: number;
|
|
54
52
|
}): number;
|
|
55
|
-
getNormalizedLineFeed(): NormalizedLineFeed;
|
|
56
|
-
}
|
|
57
|
-
declare class NormalizedLineFeed {
|
|
58
|
-
readonly code: string;
|
|
59
|
-
private readonly offsets;
|
|
60
|
-
get needRemap(): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Remap index
|
|
63
|
-
*/
|
|
64
|
-
readonly remapIndex: (index: number) => number;
|
|
65
|
-
constructor(code: string, offsets: number[]);
|
|
66
53
|
}
|
|
67
54
|
//#endregion
|
|
68
55
|
//#region src/ast/base.d.ts
|
|
@@ -218,6 +205,111 @@ type SourceLocation = TSESTree.SourceLocation;
|
|
|
218
205
|
type Range = TSESTree.Range;
|
|
219
206
|
type Position = TSESTree.Position;
|
|
220
207
|
//#endregion
|
|
208
|
+
//#region src/astro/types.d.ts
|
|
209
|
+
type DiagnosticMessage = compilerBinding.DiagnosticMessage;
|
|
210
|
+
type ParseResult = {
|
|
211
|
+
ast: AstroRootNode;
|
|
212
|
+
diagnostics: DiagnosticMessage[];
|
|
213
|
+
};
|
|
214
|
+
type LocatedNode = {
|
|
215
|
+
start: number;
|
|
216
|
+
end: number;
|
|
217
|
+
};
|
|
218
|
+
type UnknownNode = LocatedNode & {
|
|
219
|
+
type: unknown;
|
|
220
|
+
};
|
|
221
|
+
type AstroRootNode = LocatedNode & {
|
|
222
|
+
type: "AstroRoot";
|
|
223
|
+
frontmatter?: AstroFrontmatterNode;
|
|
224
|
+
body: TemplateNode[];
|
|
225
|
+
};
|
|
226
|
+
type AstroFrontmatterNode = LocatedNode & {
|
|
227
|
+
type: "AstroFrontmatter";
|
|
228
|
+
program: ProgramNode;
|
|
229
|
+
};
|
|
230
|
+
type AstroScriptNode = LocatedNode & {
|
|
231
|
+
type: "AstroScript";
|
|
232
|
+
program: ProgramNode;
|
|
233
|
+
};
|
|
234
|
+
type ProgramNode = LocatedNode & {
|
|
235
|
+
type: "Program";
|
|
236
|
+
body: UnknownNode[];
|
|
237
|
+
sourceType: "module" | "script";
|
|
238
|
+
};
|
|
239
|
+
type TemplateNode = AstroCommentNode | AstroDoctypeNode | JSXElementNode | JSXExpressionContainerNode | JSXFragmentNode | JSXTextNode;
|
|
240
|
+
type AstroCommentNode = LocatedNode & {
|
|
241
|
+
type: "AstroComment";
|
|
242
|
+
value: string;
|
|
243
|
+
};
|
|
244
|
+
type AstroDoctypeNode = LocatedNode & {
|
|
245
|
+
type: "AstroDoctype";
|
|
246
|
+
value: string;
|
|
247
|
+
};
|
|
248
|
+
type JSXElementNode = LocatedNode & {
|
|
249
|
+
type: "JSXElement";
|
|
250
|
+
openingElement: JSXOpeningElementNode;
|
|
251
|
+
closingElement: JSXClosingElementNode | null;
|
|
252
|
+
children: (TemplateNode | AstroScriptNode)[];
|
|
253
|
+
};
|
|
254
|
+
type JSXOpeningElementNode = LocatedNode & {
|
|
255
|
+
type: "JSXOpeningElement";
|
|
256
|
+
name: JSXNameNode;
|
|
257
|
+
attributes: AttributeNode[];
|
|
258
|
+
selfClosing: boolean;
|
|
259
|
+
};
|
|
260
|
+
type JSXClosingElementNode = LocatedNode & {
|
|
261
|
+
type: "JSXClosingElement";
|
|
262
|
+
name: JSXNameNode;
|
|
263
|
+
};
|
|
264
|
+
type JSXFragmentNode = LocatedNode & {
|
|
265
|
+
type: "JSXFragment";
|
|
266
|
+
openingFragment: JSXFragmentBoundaryNode;
|
|
267
|
+
closingFragment?: JSXFragmentBoundaryNode | null;
|
|
268
|
+
children: TemplateNode[];
|
|
269
|
+
};
|
|
270
|
+
type JSXFragmentBoundaryNode = LocatedNode & {
|
|
271
|
+
type: "JSXOpeningFragment" | "JSXClosingFragment";
|
|
272
|
+
};
|
|
273
|
+
type JSXExpressionContainerNode = LocatedNode & {
|
|
274
|
+
type: "JSXExpressionContainer";
|
|
275
|
+
expression: UnknownNode;
|
|
276
|
+
};
|
|
277
|
+
type JSXTextNode = LocatedNode & {
|
|
278
|
+
type: "JSXText";
|
|
279
|
+
value?: string;
|
|
280
|
+
raw?: string;
|
|
281
|
+
};
|
|
282
|
+
type AttributeNode = JSXAttributeNode | JSXSpreadAttributeNode;
|
|
283
|
+
type JSXAttributeNode = LocatedNode & {
|
|
284
|
+
type: "JSXAttribute";
|
|
285
|
+
name: JSXNameNode;
|
|
286
|
+
value: JSXExpressionContainerNode | LiteralNode | null;
|
|
287
|
+
};
|
|
288
|
+
type JSXSpreadAttributeNode = LocatedNode & {
|
|
289
|
+
type: "JSXSpreadAttribute";
|
|
290
|
+
argument: LocatedNode;
|
|
291
|
+
};
|
|
292
|
+
type LiteralNode = LocatedNode & {
|
|
293
|
+
type: "Literal";
|
|
294
|
+
value: unknown;
|
|
295
|
+
raw?: string;
|
|
296
|
+
};
|
|
297
|
+
type JSXNameNode = JSXIdentifierNode | JSXMemberExpressionNode | JSXNamespacedNameNode;
|
|
298
|
+
type JSXIdentifierNode = LocatedNode & {
|
|
299
|
+
type: "JSXIdentifier";
|
|
300
|
+
name: string;
|
|
301
|
+
};
|
|
302
|
+
type JSXMemberExpressionNode = LocatedNode & {
|
|
303
|
+
type: "JSXMemberExpression";
|
|
304
|
+
object: JSXIdentifierNode | JSXMemberExpressionNode;
|
|
305
|
+
property: JSXIdentifierNode;
|
|
306
|
+
};
|
|
307
|
+
type JSXNamespacedNameNode = LocatedNode & {
|
|
308
|
+
type: "JSXNamespacedName";
|
|
309
|
+
namespace: JSXIdentifierNode;
|
|
310
|
+
name: JSXIdentifierNode;
|
|
311
|
+
};
|
|
312
|
+
//#endregion
|
|
221
313
|
//#region src/parser/index.d.ts
|
|
222
314
|
/**
|
|
223
315
|
* Parse source code
|
|
@@ -235,13 +327,16 @@ declare function parseForESLint$1(code: string, options?: any): {
|
|
|
235
327
|
scopeManager: ScopeManager;
|
|
236
328
|
};
|
|
237
329
|
//#endregion
|
|
330
|
+
//#region src/astro/walker.d.ts
|
|
331
|
+
type WalkContext = {
|
|
332
|
+
/** Skip walking the children of the current node. */skipChildren: () => void; /** Stop walking entirely. */
|
|
333
|
+
break: () => void;
|
|
334
|
+
};
|
|
335
|
+
//#endregion
|
|
238
336
|
//#region src/astro-tools/index.d.ts
|
|
239
337
|
interface ParseTemplateResult {
|
|
240
338
|
result: ParseResult;
|
|
241
|
-
|
|
242
|
-
calcAttributeValueStartOffset: (node: AttributeNode) => number;
|
|
243
|
-
calcAttributeEndOffset: (node: AttributeNode) => number;
|
|
244
|
-
walk: (parent: ParentNode, enter: (n: Node | AttributeNode, parents: ParentNode[]) => void, leave?: (n: Node | AttributeNode, parents: ParentNode[]) => void) => void;
|
|
339
|
+
walk: (parent: UnknownNode, enter: (n: UnknownNode, parents: UnknownNode[], ctx: WalkContext) => void, leave?: (n: UnknownNode, parents: UnknownNode[], ctx: WalkContext) => void) => void;
|
|
245
340
|
getLocFromIndex: (index: number) => {
|
|
246
341
|
line: number;
|
|
247
342
|
column: number;
|