@cspell/eslint-plugin
Version:
58 lines • 2.42 kB
text/typescript
import type { ASTPath, Key } from './ASTPath.js' with { 'resolution-mode': 'import' };
export type ScopeScore = number;
export declare class AstScopeMatcher {
readonly scope: ScopeItem[];
constructor(scope: ScopeItem[]);
static fromScopeSelector(scopeSelector: string): AstScopeMatcher;
/**
* Score the astScope based on the given scope.
* @param astScope The scope to score.
* @returns The score of the scope. 0 = no match, higher the score the better the match.
*/
score(astScope: string[]): ScopeScore;
/**
* Score the astScope based on the given scope.
* @param astScope The scope to score.
* @returns The score of the scope. 0 = no match, higher the score the better the match.
*/
scoreItems(scopeItems: ScopeItem[]): ScopeScore;
matchPath(path: ASTPath): ScopeScore;
scopeField(): string;
scopeType(): string;
}
export interface ScopeItem {
type: string;
childKey: string | undefined;
}
export declare function scopeItem(type: string, childKey?: string): ScopeItem;
export declare function parseScope(scope: string): ScopeItem[];
export interface ASTPathNodeToScope {
/**
* Convert a path node into a scope.
* @param node - The node to convert
* @param childKey - The key to the child node.
*/
(node: ASTPath, childKey: Key | undefined): ScopeItem;
}
export declare function keyToString(key: Key): string | undefined;
export declare function mapNodeToScope(p: ASTPath, key: Key | undefined): ScopeItem;
export declare function mapNodeToScopeItem(p: ASTPath, childKey: Key | undefined): ScopeItem;
export declare function mapScopeItemToString(item: ScopeItem): string;
/**
* Convert an ASTPath to a scope.
* @param path - The path to convert to a scope.
* @returns
*/
export declare function astPathToScope(path: ASTPath | undefined, mapFn?: ASTPathNodeToScope): string[];
export declare function astScopeToString(path: ASTPath | undefined, sep?: string, mapFn?: ASTPathNodeToScope): string;
export declare function astPathToScopeItems(path: ASTPath | undefined, mapFn?: ASTPathNodeToScope): ScopeItem[];
export declare class AstPathScope {
readonly path: ASTPath;
private items;
constructor(path: ASTPath);
get scope(): string[];
get scopeItems(): ScopeItem[];
get scopeString(): string;
score(matcher: AstScopeMatcher): ScopeScore;
}
//# sourceMappingURL=scope.d.cts.map