import type { Node, Data, Literal, Parent, Blockquote, Break, Code, Definition, Emphasis, Heading, Html, Image, ImageReference, InlineCode, Link, LinkReference, List, ListItem, Paragraph, Root, Strong, Text, ThematicBreak, Delete, FootnoteDefinition, FootnoteReference, Table, TableCell, TableRow, Yaml } from "mdast"; import type { InlineMath, Math } from "mdast-util-math"; import type { LanguageContext, LanguageOptions, RuleVisitor } from "@eslint/core"; import type { CustomRuleDefinitionType, CustomRuleTypeDefinitions, CustomRuleVisitorWithExit } from "@eslint/plugin-kit"; import type { MarkdownSourceCode } from "./index.js"; export interface RangeMap { indent: number; js: number; md: number; } export interface BlockBase { baseIndentText: string; comments: string[]; rangeMap: RangeMap[]; } export type Block = Code & BlockBase; /** * Markdown TOML. */ export interface Toml extends Literal { /** * Node type of mdast TOML. */ type: "toml"; /** * Data associated with the mdast TOML. */ data?: TomlData | undefined; } /** * Info associated with mdast TOML nodes by the ecosystem. */ export interface TomlData extends Data { } /** * Markdown JSON. */ export interface Json extends Literal { /** * Node type of mdast JSON. */ type: "json"; /** * Data associated with the mdast JSON. */ data?: JsonData | undefined; } /** * Info associated with mdast JSON nodes by the ecosystem. */ export interface JsonData extends Data { } /** * Language options provided for Markdown files. */ export interface MarkdownLanguageOptions extends LanguageOptions { /** * The options for parsing frontmatter. */ frontmatter?: false | "yaml" | "toml" | "json"; /** * The options for parsing math. */ math?: boolean; } /** * The context object that is passed to the Markdown language plugin methods. */ export type MarkdownLanguageContext = LanguageContext; export interface MarkdownRuleVisitor extends RuleVisitor, CustomRuleVisitorWithExit<{ root?(node: Root): void; } & { [NodeType in Blockquote | Break | Code | Definition | Emphasis | Heading | Html | Image | ImageReference | InlineCode | Link | LinkReference | List | ListItem | Paragraph | Strong | Text | ThematicBreak | Delete | FootnoteDefinition | FootnoteReference | Table | TableCell | TableRow | Yaml | Toml | Json | InlineMath | Math as NodeType["type"]]?: (node: NodeType, parent?: Parent) => void; }> { } export type MarkdownRuleDefinitionTypeOptions = CustomRuleTypeDefinitions; export type MarkdownRuleDefinition = {}> = CustomRuleDefinitionType<{ LangOptions: MarkdownLanguageOptions; Code: MarkdownSourceCode; Visitor: MarkdownRuleVisitor; Node: Node; }, Options>;