@eslint/core
Advanced tools
Comparing version 0.2.0 to 0.3.0
{ | ||
"name": "@eslint/core", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Runtime-agnostic core of ESLint", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -34,8 +34,7 @@ /** | ||
/** | ||
* Represents an AST node or token with location information. | ||
* Represents an AST node or token with location information in ESLint format. | ||
*/ | ||
export interface SyntaxElement { | ||
loc: SourceLocation; | ||
range: [number, number]; | ||
[key: string]: any; | ||
range: SourceRange; | ||
} | ||
@@ -52,4 +51,13 @@ | ||
/** | ||
* Represents a location coordinate inside the source. | ||
* Represents the start and end coordinates of a node inside the source with an offset. | ||
*/ | ||
export interface SourceLocationWithOffset { | ||
start: PositionWithOffset; | ||
end: PositionWithOffset; | ||
} | ||
/** | ||
* Represents a location coordinate inside the source. ESLint-style formats | ||
* have just `line` and `column` while others may have `offset` as well. | ||
*/ | ||
export interface Position { | ||
@@ -60,2 +68,14 @@ line: number; | ||
/** | ||
* Represents a location coordinate inside the source with an offset. | ||
*/ | ||
export interface PositionWithOffset extends Position { | ||
offset: number; | ||
} | ||
/** | ||
* Represents a range of characters in the source. | ||
*/ | ||
export type SourceRange = [number, number]; | ||
//------------------------------------------------------------------------------ | ||
@@ -163,4 +183,4 @@ // Config | ||
className: string, | ||
node: SyntaxElement, | ||
ancestry: Array<SyntaxElement>, | ||
node: object, | ||
ancestry: Array<object>, | ||
): boolean; | ||
@@ -229,3 +249,3 @@ | ||
*/ | ||
export interface OkParseResult { | ||
export interface OkParseResult<T extends object = object> { | ||
/** | ||
@@ -242,3 +262,3 @@ * Indicates if the parse was successful. If true, the parse was successful | ||
*/ | ||
ast: SyntaxElement; | ||
ast: T; | ||
@@ -274,3 +294,5 @@ /** | ||
export type ParseResult = OkParseResult | NotOkParseResult; | ||
export type ParseResult<T extends object = object> = | ||
| OkParseResult<T> | ||
| NotOkParseResult; | ||
@@ -301,3 +323,3 @@ /** | ||
*/ | ||
ast: SyntaxElement; | ||
ast: object; | ||
@@ -312,2 +334,12 @@ /** | ||
/** | ||
* Retrieves the equivalent of `loc` for a given node or token. | ||
*/ | ||
getLoc(nodeOrToken: object): SourceLocation; | ||
/** | ||
* Retrieves the equivalent of `range` for a given node or token. | ||
*/ | ||
getRange(nodeOrToken: object): SourceRange; | ||
/** | ||
* Traversal of AST. | ||
@@ -335,3 +367,3 @@ */ | ||
*/ | ||
getInlineConfigNodes?(): Array<SyntaxElement>; | ||
getInlineConfigNodes?(): Array<object>; | ||
@@ -383,3 +415,3 @@ /** | ||
kind: 1; | ||
target: SyntaxElement; | ||
target: object; | ||
phase: 1 /* enter */ | 2 /* exit */; | ||
@@ -413,3 +445,3 @@ args: Array<any>; | ||
*/ | ||
node: SyntaxElement; | ||
node: object; | ||
@@ -416,0 +448,0 @@ /** |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25979
381