+++ /dev/null
-import { ParserServices, TSESTree } from '../ts-estree';\r
-import { Scope } from './Scope';\r
-declare class TokenStore {\r
- /**\r
- * Checks whether any comments exist or not between the given 2 nodes.\r
- * @param left The node to check.\r
- * @param right The node to check.\r
- * @returns `true` if one or more comments exist.\r
- */\r
- commentsExistBetween(left: TSESTree.Node | TSESTree.Token, right: TSESTree.Node | TSESTree.Token): boolean;\r
- /**\r
- * Gets all comment tokens directly after the given node or token.\r
- * @param nodeOrToken The AST node or token to check for adjacent comment tokens.\r
- * @returns An array of comments in occurrence order.\r
- */\r
- getCommentsAfter(nodeOrToken: TSESTree.Node | TSESTree.Token): TSESTree.Comment[];\r
- /**\r
- * Gets all comment tokens directly before the given node or token.\r
- * @param nodeOrToken The AST node or token to check for adjacent comment tokens.\r
- * @returns An array of comments in occurrence order.\r
- */\r
- getCommentsBefore(nodeOrToken: TSESTree.Node | TSESTree.Token): TSESTree.Comment[];\r
- /**\r
- * Gets all comment tokens inside the given node.\r
- * @param node The AST node to get the comments for.\r
- * @returns An array of comments in occurrence order.\r
- */\r
- getCommentsInside(node: TSESTree.Node): TSESTree.Comment[];\r
- /**\r
- * Gets the first token of the given node.\r
- * @param node The AST node.\r
- * @param option The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.\r
- * @returns An object representing the token.\r
- */\r
- getFirstToken<T extends SourceCode.CursorWithSkipOptions>(node: TSESTree.Node, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;\r
- /**\r
- * Gets the first token between two non-overlapping nodes.\r
- * @param left Node before the desired token range.\r
- * @param right Node after the desired token range.\r
- * @param option The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.\r
- * @returns An object representing the token.\r
- */\r
- getFirstTokenBetween<T extends SourceCode.CursorWithSkipOptions>(left: TSESTree.Node | TSESTree.Token | TSESTree.Comment, right: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;\r
- /**\r
- * Gets the first `count` tokens of the given node.\r
- * @param node The AST node.\r
- * @param options The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.\r
- * @returns Tokens.\r
- */\r
- getFirstTokens<T extends SourceCode.CursorWithCountOptions>(node: TSESTree.Node, options?: T): SourceCode.ReturnTypeFromOptions<T>[];\r
- /**\r
- * Gets the first `count` tokens between two non-overlapping nodes.\r
- * @param left Node before the desired token range.\r
- * @param right Node after the desired token range.\r
- * @param options The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.\r
- * @returns Tokens between left and right.\r
- */\r
- getFirstTokensBetween<T extends SourceCode.CursorWithCountOptions>(left: TSESTree.Node | TSESTree.Token | TSESTree.Comment, right: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T>[];\r
- /**\r
- * Gets the last token of the given node.\r
- * @param node The AST node.\r
- * @param option The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.\r
- * @returns An object representing the token.\r
- */\r
- getLastToken<T extends SourceCode.CursorWithSkipOptions>(node: TSESTree.Node, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;\r
- /**\r
- * Gets the last token between two non-overlapping nodes.\r
- * @param left Node before the desired token range.\r
- * @param right Node after the desired token range.\r
- * @param option The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.\r
- * @returns An object representing the token.\r
- */\r
- getLastTokenBetween<T extends SourceCode.CursorWithSkipOptions>(left: TSESTree.Node | TSESTree.Token | TSESTree.Comment, right: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;\r
- /**\r
- * Gets the last `count` tokens of the given node.\r
- * @param node The AST node.\r
- * @param options The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.\r
- * @returns Tokens.\r
- */\r
- getLastTokens<T extends SourceCode.CursorWithCountOptions>(node: TSESTree.Node, options?: T): SourceCode.ReturnTypeFromOptions<T>[];\r
- /**\r
- * Gets the last `count` tokens between two non-overlapping nodes.\r
- * @param left Node before the desired token range.\r
- * @param right Node after the desired token range.\r
- * @param options The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.\r
- * @returns Tokens between left and right.\r
- */\r
- getLastTokensBetween<T extends SourceCode.CursorWithCountOptions>(left: TSESTree.Node | TSESTree.Token | TSESTree.Comment, right: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T>[];\r
- /**\r
- * Gets the token that follows a given node or token.\r
- * @param node The AST node or token.\r
- * @param option The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.\r
- * @returns An object representing the token.\r
- */\r
- getTokenAfter<T extends SourceCode.CursorWithSkipOptions>(node: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;\r
- /**\r
- * Gets the token that precedes a given node or token.\r
- * @param node The AST node or token.\r
- * @param options The option object\r
- * @returns An object representing the token.\r
- */\r
- getTokenBefore<T extends SourceCode.CursorWithSkipOptions>(node: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;\r
- /**\r
- * Gets the token starting at the specified index.\r
- * @param offset Index of the start of the token's range.\r
- * @param option The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.\r
- * @returns The token starting at index, or null if no such token.\r
- */\r
- getTokenByRangeStart<T extends {\r
- includeComments?: boolean;\r
- }>(offset: number, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;\r
- /**\r
- * Gets all tokens that are related to the given node.\r
- * @param node The AST node.\r
- * @param beforeCount The number of tokens before the node to retrieve.\r
- * @param afterCount The number of tokens after the node to retrieve.\r
- * @returns Array of objects representing tokens.\r
- */\r
- getTokens(node: TSESTree.Node, beforeCount?: number, afterCount?: number): TSESTree.Token[];\r
- /**\r
- * Gets all tokens that are related to the given node.\r
- * @param node The AST node.\r
- * @param options The option object. If this is a function then it's `options.filter`.\r
- * @returns Array of objects representing tokens.\r
- */\r
- getTokens<T extends SourceCode.CursorWithCountOptions>(node: TSESTree.Node, options: T): SourceCode.ReturnTypeFromOptions<T>[];\r
- /**\r
- * Gets the `count` tokens that follows a given node or token.\r
- * @param node The AST node.\r
- * @param options The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.\r
- * @returns Tokens.\r
- */\r
- getTokensAfter<T extends SourceCode.CursorWithCountOptions>(node: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T>[];\r
- /**\r
- * Gets the `count` tokens that precedes a given node or token.\r
- * @param node The AST node.\r
- * @param options The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.\r
- * @returns Tokens.\r
- */\r
- getTokensBefore<T extends SourceCode.CursorWithCountOptions>(node: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T>[];\r
- /**\r
- * Gets all of the tokens between two non-overlapping nodes.\r
- * @param left Node before the desired token range.\r
- * @param right Node after the desired token range.\r
- * @param options The option object. If this is a function then it's `options.filter`.\r
- * @returns Tokens between left and right.\r
- */\r
- getTokensBetween<T extends SourceCode.CursorWithCountOptions>(left: TSESTree.Node | TSESTree.Token | TSESTree.Comment, right: TSESTree.Node | TSESTree.Token | TSESTree.Comment, padding?: T): SourceCode.ReturnTypeFromOptions<T>[];\r
- /**\r
- * Gets all of the tokens between two non-overlapping nodes.\r
- * @param left Node before the desired token range.\r
- * @param right Node after the desired token range.\r
- * @param padding Number of extra tokens on either side of center.\r
- * @returns Tokens between left and right.\r
- */\r
- getTokensBetween<T extends SourceCode.CursorWithCountOptions>(left: TSESTree.Node | TSESTree.Token | TSESTree.Comment, right: TSESTree.Node | TSESTree.Token | TSESTree.Comment, padding?: number): SourceCode.ReturnTypeFromOptions<T>[];\r
-}\r
-declare class SourceCodeBase extends TokenStore {\r
- /**\r
- * Represents parsed source code.\r
- * @param text The source code text.\r
- * @param ast The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.\r
- */\r
- constructor(text: string, ast: SourceCode.Program);\r
- /**\r
- * Represents parsed source code.\r
- * @param config The config object.\r
- */\r
- constructor(config: SourceCode.SourceCodeConfig);\r
- /**\r
- * The parsed AST for the source code.\r
- */\r
- ast: SourceCode.Program;\r
- /**\r
- * Retrieves an array containing all comments in the source code.\r
- * @returns An array of comment nodes.\r
- */\r
- getAllComments(): TSESTree.Comment[];\r
- /**\r
- * Gets all comments for the given node.\r
- * @param node The AST node to get the comments for.\r
- * @returns An object containing a leading and trailing array of comments indexed by their position.\r
- */\r
- getComments(node: TSESTree.Node): {\r
- leading: TSESTree.Comment[];\r
- trailing: TSESTree.Comment[];\r
- };\r
- /**\r
- * Converts a (line, column) pair into a range index.\r
- * @param loc A line/column location\r
- * @returns The range index of the location in the file.\r
- */\r
- getIndexFromLoc(location: TSESTree.LineAndColumnData): number;\r
- /**\r
- * Gets the entire source text split into an array of lines.\r
- * @returns The source text as an array of lines.\r
- */\r
- getLines(): string[];\r
- /**\r
- * Converts a source text index into a (line, column) pair.\r
- * @param index The index of a character in a file\r
- * @returns A {line, column} location object with a 0-indexed column\r
- */\r
- getLocFromIndex(index: number): TSESTree.LineAndColumnData;\r
- /**\r
- * Gets the deepest node containing a range index.\r
- * @param index Range index of the desired node.\r
- * @returns The node if found or `null` if not found.\r
- */\r
- getNodeByRangeIndex(index: number): TSESTree.Node | null;\r
- /**\r
- * Gets the source code for the given node.\r
- * @param node The AST node to get the text for.\r
- * @param beforeCount The number of characters before the node to retrieve.\r
- * @param afterCount The number of characters after the node to retrieve.\r
- * @returns The text representing the AST node.\r
- */\r
- getText(node?: TSESTree.Node, beforeCount?: number, afterCount?: number): string;\r
- /**\r
- * The flag to indicate that the source code has Unicode BOM.\r
- */\r
- hasBOM: boolean;\r
- /**\r
- * Determines if two nodes or tokens have at least one whitespace character\r
- * between them. Order does not matter. Returns false if the given nodes or\r
- * tokens overlap.\r
- * This was added in v6.7.0.\r
- * @since 6.7.0\r
- * @param first The first node or token to check between.\r
- * @param second The second node or token to check between.\r
- * @returns True if there is a whitespace character between any of the tokens found between the two given nodes or tokens.\r
- */\r
- isSpaceBetween?(first: TSESTree.Token | TSESTree.Comment | TSESTree.Node, second: TSESTree.Token | TSESTree.Comment | TSESTree.Node): boolean;\r
- /**\r
- * Determines if two nodes or tokens have at least one whitespace character\r
- * between them. Order does not matter. Returns false if the given nodes or\r
- * tokens overlap.\r
- * For backward compatibility, this method returns true if there are\r
- * `JSXText` tokens that contain whitespace between the two.\r
- * @param first The first node or token to check between.\r
- * @param second The second node or token to check between.\r
- * @returns {boolean} True if there is a whitespace character between\r
- * any of the tokens found between the two given nodes or tokens.\r
- * @deprecated in favor of isSpaceBetween\r
- */\r
- isSpaceBetweenTokens(first: TSESTree.Token, second: TSESTree.Token): boolean;\r
- /**\r
- * The source code split into lines according to ECMA-262 specification.\r
- * This is done to avoid each rule needing to do so separately.\r
- */\r
- lines: string[];\r
- /**\r
- * The indexes in `text` that each line starts\r
- */\r
- lineStartIndices: number[];\r
- /**\r
- * The parser services of this source code.\r
- */\r
- parserServices: ParserServices;\r
- /**\r
- * The scope of this source code.\r
- */\r
- scopeManager: Scope.ScopeManager | null;\r
- /**\r
- * The original text source code. BOM was stripped from this text.\r
- */\r
- text: string;\r
- /**\r
- * All of the tokens and comments in the AST.\r
- */\r
- tokensAndComments: (TSESTree.Comment | TSESTree.Token)[];\r
- /**\r
- * The visitor keys to traverse AST.\r
- */\r
- visitorKeys: SourceCode.VisitorKeys;\r
- /**\r
- * Split the source code into multiple lines based on the line delimiters.\r
- * @param text Source code as a string.\r
- * @returns Array of source code lines.\r
- */\r
- static splitLines(text: string): string[];\r
-}\r
-declare namespace SourceCode {\r
- interface Program extends TSESTree.Program {\r
- comments: TSESTree.Comment[];\r
- tokens: TSESTree.Token[];\r
- }\r
- interface SourceCodeConfig {\r
- /**\r
- * The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.\r
- */\r
- ast: Program;\r
- /**\r
- * The parser services.\r
- */\r
- parserServices: ParserServices | null;\r
- /**\r
- * The scope of this source code.\r
- */\r
- scopeManager: Scope.ScopeManager | null;\r
- /**\r
- * The source code text.\r
- */\r
- text: string;\r
- /**\r
- * The visitor keys to traverse AST.\r
- */\r
- visitorKeys: VisitorKeys | null;\r
- }\r
- interface VisitorKeys {\r
- [nodeType: string]: string[];\r
- }\r
- type FilterPredicate = (tokenOrComment: TSESTree.Token | TSESTree.Comment) => boolean;\r
- type ReturnTypeFromOptions<T> = T extends {\r
- includeComments: true;\r
- } ? TSESTree.Token : Exclude<TSESTree.Token, TSESTree.Comment>;\r
- type CursorWithSkipOptions = number | FilterPredicate | {\r
- /**\r
- * The predicate function to choose tokens.\r
- */\r
- filter?: FilterPredicate;\r
- /**\r
- * The flag to iterate comments as well.\r
- */\r
- includeComments?: boolean;\r
- /**\r
- * The count of tokens the cursor skips.\r
- */\r
- skip?: number;\r
- };\r
- type CursorWithCountOptions = number | FilterPredicate | {\r
- /**\r
- * The predicate function to choose tokens.\r
- */\r
- filter?: FilterPredicate;\r
- /**\r
- * The flag to iterate comments as well.\r
- */\r
- includeComments?: boolean;\r
- /**\r
- * The maximum count of tokens the cursor iterates.\r
- */\r
- count?: number;\r
- };\r
-}\r
-declare const SourceCode_base: typeof SourceCodeBase;\r
-declare class SourceCode extends SourceCode_base {\r
-}\r
-export { SourceCode };\r
-//# sourceMappingURL=SourceCode.d.ts.map\r