diff --git a/src/index.js b/src/index.js index d98db26a..793eb89e 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ /** - * @fileoverview Enables the processor for Markdown file extensions. + * @fileoverview Markdown plugin. * @author Brandon Mills */ @@ -17,16 +17,19 @@ import rules from "./build/rules.js"; // Type Definitions //----------------------------------------------------------------------------- -/** @typedef {import("eslint").Linter.RulesRecord} RulesRecord*/ -/** @typedef {import("eslint").Linter.Config} Config*/ -/** @typedef {import("eslint").ESLint.Plugin} Plugin */ /** - * @typedef {import("./types.ts").MarkdownRuleDefinition} MarkdownRuleDefinition - * @template {Partial} [Options={}] + * @import { Linter } from "eslint"; + * @import * as Types from "./types.js"; + * @typedef {Linter.RulesRecord} RulesRecord + * @typedef {Types.MarkdownRuleDefinition} RuleModule + * @typedef {Types.MarkdownRuleVisitor} MarkdownRuleVisitor + * @typedef {Types.MarkdownRuleDefinitionTypeOptions} MarkdownRuleDefinitionTypeOptions + */ + +/** + * @typedef {Types.MarkdownRuleDefinition} MarkdownRuleDefinition + * @template {Partial} [Options={}] */ -/** @typedef {MarkdownRuleDefinition} RuleModule */ -/** @typedef {import("./types.ts").MarkdownRuleVisitor} MarkdownRuleVisitor */ -/** @typedef {import("@eslint/core").Language} Language */ //----------------------------------------------------------------------------- // Exports diff --git a/src/language/markdown-language.js b/src/language/markdown-language.js index 0f75e0b3..f9941632 100644 --- a/src/language/markdown-language.js +++ b/src/language/markdown-language.js @@ -20,16 +20,15 @@ import { gfm } from "micromark-extension-gfm"; // Types //----------------------------------------------------------------------------- -/** @typedef {import("mdast").Root} RootNode */ -/** @typedef {import("mdast-util-from-markdown").Options['extensions']} Extensions */ -/** @typedef {import("mdast-util-from-markdown").Options['mdastExtensions']} MdastExtensions */ -/** @typedef {import("@eslint/core").Language} Language */ -/** @typedef {import("@eslint/core").File} File */ -/** @typedef {import("@eslint/core").ParseResult} ParseResult */ -/** @typedef {import("@eslint/core").OkParseResult} OkParseResult */ -/** @typedef {import("../types.ts").MarkdownLanguageOptions} MarkdownLanguageOptions */ -/** @typedef {import("../types.ts").MarkdownLanguageContext} MarkdownLanguageContext */ -/** @typedef {"commonmark"|"gfm"} ParserMode */ +/** + * @import { Language, File, ParseResult, OkParseResult } from "@eslint/core"; + * @import { Root } from "mdast"; + * @import { Options } from "mdast-util-from-markdown"; + * @import { MarkdownLanguageOptions, MarkdownLanguageContext } from "../types.js"; + * @typedef {Options['extensions']} Extensions + * @typedef {Options['mdastExtensions']} MdastExtensions + * @typedef {"commonmark"|"gfm"} ParserMode + */ //----------------------------------------------------------------------------- // Helpers @@ -182,7 +181,7 @@ export class MarkdownLanguage { * Parses the given file into an AST. * @param {File} file The virtual file to parse. * @param {MarkdownLanguageContext} context The options to use for parsing. - * @returns {ParseResult} The result of parsing. + * @returns {ParseResult} The result of parsing. */ parse(file, context) { // Note: BOM already removed @@ -216,7 +215,7 @@ export class MarkdownLanguage { /** * Creates a new `MarkdownSourceCode` object from the given information. * @param {File} file The virtual file to create a `MarkdownSourceCode` object from. - * @param {OkParseResult} parseResult The result returned from `parse()`. + * @param {OkParseResult} parseResult The result returned from `parse()`. * @returns {MarkdownSourceCode} The new `MarkdownSourceCode` object. */ createSourceCode(file, parseResult) { diff --git a/src/language/markdown-source-code.js b/src/language/markdown-source-code.js index c15ef3db..9ae62c5f 100644 --- a/src/language/markdown-source-code.js +++ b/src/language/markdown-source-code.js @@ -19,20 +19,11 @@ import { findOffsets } from "../util.js"; // Types //----------------------------------------------------------------------------- -/** @typedef {import("mdast").Root} RootNode */ -/** @typedef {import("mdast").Node} MarkdownNode */ -/** @typedef {import("mdast").Html} HTMLNode */ -/** @typedef {import("@eslint/core").Language} Language */ -/** @typedef {import("@eslint/core").File} File */ -/** @typedef {import("@eslint/core").TraversalStep} TraversalStep */ -/** @typedef {import("@eslint/core").VisitTraversalStep} VisitTraversalStep */ -/** @typedef {import("@eslint/core").ParseResult} ParseResult */ -/** @typedef {import("@eslint/core").SourceLocation} SourceLocation */ -/** @typedef {import("@eslint/core").SourceRange} SourceRange */ -/** @typedef {import("@eslint/core").FileProblem} FileProblem */ -/** @typedef {import("@eslint/core").DirectiveType} DirectiveType */ -/** @typedef {import("@eslint/core").RulesConfig} RulesConfig */ -/** @typedef {import("../types.ts").MarkdownLanguageOptions} MarkdownLanguageOptions */ +/** + * @import { Root, Node, Html } from "mdast"; + * @import { TraversalStep, SourceLocation, FileProblem, DirectiveType, RulesConfig } from "@eslint/core"; + * @import { MarkdownLanguageOptions } from "../types.js"; + */ //----------------------------------------------------------------------------- // Helpers @@ -73,7 +64,7 @@ class InlineConfigComment { /** * Extracts inline configuration comments from an HTML node. - * @param {HTMLNode} node The HTML node to extract comments from. + * @param {Html} node The HTML node to extract comments from. * @returns {Array} The inline configuration comments found in the node. */ function extractInlineConfigCommentsFromHTML(node) { @@ -136,7 +127,7 @@ function extractInlineConfigCommentsFromHTML(node) { /** * Markdown Source Code Object - * @extends {TextSourceCodeBase<{LangOptions: MarkdownLanguageOptions, RootNode: RootNode, SyntaxElementWithLoc: MarkdownNode, ConfigNode: { value: string; position: SourceLocation }}>} + * @extends {TextSourceCodeBase<{LangOptions: MarkdownLanguageOptions, RootNode: Root, SyntaxElementWithLoc: Node, ConfigNode: { value: string; position: SourceLocation }}>} */ export class MarkdownSourceCode extends TextSourceCodeBase { /** @@ -147,13 +138,13 @@ export class MarkdownSourceCode extends TextSourceCodeBase { /** * Cache of parent nodes. - * @type {WeakMap} + * @type {WeakMap} */ #parents = new WeakMap(); /** * Collection of HTML nodes. Used to find directive comments. - * @type {Array} + * @type {Array} */ #htmlNodes = []; @@ -165,7 +156,7 @@ export class MarkdownSourceCode extends TextSourceCodeBase { /** * The AST of the source code. - * @type {RootNode} + * @type {Root} */ ast = undefined; @@ -173,7 +164,7 @@ export class MarkdownSourceCode extends TextSourceCodeBase { * Creates a new instance. * @param {Object} options The options for the instance. * @param {string} options.text The source code text. - * @param {RootNode} options.ast The root AST node. + * @param {Root} options.ast The root AST node. */ constructor({ text, ast }) { super({ ast, text }); @@ -185,8 +176,8 @@ export class MarkdownSourceCode extends TextSourceCodeBase { /** * Returns the parent of the given node. - * @param {MarkdownNode} node The node to get the parent of. - * @returns {MarkdownNode|undefined} The parent of the node. + * @param {Node} node The node to get the parent of. + * @returns {Node|undefined} The parent of the node. */ getParent(node) { return this.#parents.get(node); diff --git a/src/processor.js b/src/processor.js index d9078a83..61903fb3 100644 --- a/src/processor.js +++ b/src/processor.js @@ -13,15 +13,14 @@ import { fromMarkdown } from "mdast-util-from-markdown"; // Type Definitions //----------------------------------------------------------------------------- -/** @typedef {import("./types.ts").Block} Block */ -/** @typedef {import("./types.ts").RangeMap} RangeMap */ -/** @typedef {import("mdast").Node} Node */ -/** @typedef {import("mdast").Parent} ParentNode */ -/** @typedef {import("mdast").Code} CodeNode */ -/** @typedef {import("mdast").Html} HtmlNode */ -/** @typedef {import("eslint").Linter.LintMessage} Message */ -/** @typedef {import("eslint").Rule.Fix} Fix */ -/** @typedef {import("eslint").AST.Range} Range */ +/** + * @import { Node, Parent, Code, Html } from "mdast"; + * @import { Linter, Rule, AST } from "eslint"; + * @import { Block, RangeMap } from "./types.js"; + * @typedef {Linter.LintMessage} Message + * @typedef {Rule.Fix} Fix + * @typedef {AST.Range} Range + */ //----------------------------------------------------------------------------- // Helpers @@ -53,7 +52,7 @@ function traverse(node, callbacks) { callbacks["*"](); } - const parent = /** @type {ParentNode} */ (node); + const parent = /** @type {Parent} */ (node); if (typeof parent.children !== "undefined") { for (let i = 0; i < parent.children.length; i++) { @@ -291,7 +290,7 @@ function preprocess(sourceText, filename) { /** * Visit a code node. - * @param {CodeNode} node The visited node. + * @param {Code} node The visited node. * @returns {void} */ code(node) { @@ -320,7 +319,7 @@ function preprocess(sourceText, filename) { /** * Visit an HTML node. - * @param {HtmlNode} node The visited node. + * @param {Html} node The visited node. * @returns {void} */ html(node) { diff --git a/src/rules/fenced-code-language.js b/src/rules/fenced-code-language.js index ff4a6e7e..ff0a0256 100644 --- a/src/rules/fenced-code-language.js +++ b/src/rules/fenced-code-language.js @@ -8,8 +8,10 @@ //----------------------------------------------------------------------------- /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: [{ required?: string[]; }]; }>} - * FencedCodeLanguageRuleDefinition + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"missingLanguage" | "disallowedLanguage"} FencedCodeLanguageMessageIds + * @typedef {[{ required?: string[] }]} FencedCodeLanguageOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: FencedCodeLanguageOptions, MessageIds: FencedCodeLanguageMessageIds }>} FencedCodeLanguageRuleDefinition */ //----------------------------------------------------------------------------- diff --git a/src/rules/heading-increment.js b/src/rules/heading-increment.js index 63475d7e..fb50d33f 100644 --- a/src/rules/heading-increment.js +++ b/src/rules/heading-increment.js @@ -8,8 +8,10 @@ //----------------------------------------------------------------------------- /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} - * HeadingIncrementRuleDefinition + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"skippedHeading"} HeadingIncrementMessageIds + * @typedef {[]} HeadingIncrementOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: HeadingIncrementOptions, MessageIds: HeadingIncrementMessageIds }>} HeadingIncrementRuleDefinition */ //----------------------------------------------------------------------------- diff --git a/src/rules/no-bare-urls.js b/src/rules/no-bare-urls.js index 3bdba88a..e8c33cfb 100644 --- a/src/rules/no-bare-urls.js +++ b/src/rules/no-bare-urls.js @@ -7,14 +7,12 @@ // Type Definitions //----------------------------------------------------------------------------- -/** @typedef {import("mdast").Node} Node */ -/** @typedef {import("mdast").Paragraph} ParagraphNode */ -/** @typedef {import("mdast").Heading} HeadingNode */ -/** @typedef {import("mdast").TableCell} TableCellNode */ -/** @typedef {import("mdast").Link} LinkNode */ /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} - * NoBareUrlsRuleDefinition + * @import { Node, Heading, Paragraph, TableCell, Link } from "mdast"; + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"bareUrl"} NoBareUrlsMessageIds + * @typedef {[]} NoBareUrlsOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: NoBareUrlsOptions, MessageIds: NoBareUrlsMessageIds }>} NoBareUrlsRuleDefinition */ //----------------------------------------------------------------------------- @@ -67,14 +65,14 @@ export default { create(context) { const { sourceCode } = context; - /** @type {Array} */ + /** @type {Array} */ const bareUrls = []; /** * Finds bare URLs in markdown nodes while handling HTML tags. * When an HTML tag is found, it looks for its closing tag and skips all nodes * between them to prevent checking for bare URLs inside HTML content. - * @param {ParagraphNode|HeadingNode|TableCellNode} node The node to process + * @param {Paragraph|Heading|TableCell} node The node to process * @returns {void} */ function findBareUrls(node) { diff --git a/src/rules/no-duplicate-definitions.js b/src/rules/no-duplicate-definitions.js index b4be6964..3ec59620 100644 --- a/src/rules/no-duplicate-definitions.js +++ b/src/rules/no-duplicate-definitions.js @@ -8,8 +8,10 @@ //----------------------------------------------------------------------------- /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: [{ allowDefinitions: string[], allowFootnoteDefinitions: string[]; }]; }>} - * NoDuplicateDefinitionsRuleDefinition + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"duplicateDefinition" | "duplicateFootnoteDefinition"} NoDuplicateDefinitionsMessageIds + * @typedef {[{ allowDefinitions?: string[], allowFootnoteDefinitions?: string[] }]} NoDuplicateDefinitionsOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: NoDuplicateDefinitionsOptions, MessageIds: NoDuplicateDefinitionsMessageIds }>} NoDuplicateDefinitionsRuleDefinition */ //----------------------------------------------------------------------------- @@ -70,7 +72,10 @@ export default { context.options[0]?.allowFootnoteDefinitions, ); + /** @type {Set} */ const definitions = new Set(); + + /** @type {Set} */ const footnoteDefinitions = new Set(); return { diff --git a/src/rules/no-duplicate-headings.js b/src/rules/no-duplicate-headings.js index 8f2d1954..d4aabffe 100644 --- a/src/rules/no-duplicate-headings.js +++ b/src/rules/no-duplicate-headings.js @@ -7,10 +7,12 @@ // Type Definitions //----------------------------------------------------------------------------- -/** @typedef {import("mdast").Heading} HeadingNode */ /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: [{ checkSiblingsOnly?: boolean; }]; }>} - * NoDuplicateHeadingsRuleDefinition + * @import { Heading } from "mdast"; + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"duplicateHeading"} NoDuplicateHeadingsMessageIds + * @typedef {[{ checkSiblingsOnly?: boolean }]} NoDuplicateHeadingsOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: NoDuplicateHeadingsOptions, MessageIds: NoDuplicateHeadingsMessageIds }>} NoDuplicateHeadingsRuleDefinition */ //----------------------------------------------------------------------------- @@ -90,7 +92,7 @@ export default { /** * Gets the text of a heading node - * @param {HeadingNode} node The heading node + * @param {Heading} node The heading node * @returns {string} The heading text */ function getHeadingText(node) { diff --git a/src/rules/no-empty-images.js b/src/rules/no-empty-images.js index 7ee62cfa..fd7006e9 100644 --- a/src/rules/no-empty-images.js +++ b/src/rules/no-empty-images.js @@ -8,8 +8,10 @@ //----------------------------------------------------------------------------- /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} - * NoEmptyImagesRuleDefinition + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"emptyImage"} NoEmptyImagesMessageIds + * @typedef {[]} NoEmptyImagesOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: NoEmptyImagesOptions, MessageIds: NoEmptyImagesMessageIds }>} NoEmptyImagesRuleDefinition */ //----------------------------------------------------------------------------- diff --git a/src/rules/no-empty-links.js b/src/rules/no-empty-links.js index 2c41e59b..6ad5587f 100644 --- a/src/rules/no-empty-links.js +++ b/src/rules/no-empty-links.js @@ -7,8 +7,10 @@ //----------------------------------------------------------------------------- /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} - * NoEmptyLinksRuleDefinition + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"emptyLink"} NoEmptyLinksMessageIds + * @typedef {[]} NoEmptyLinksOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: NoEmptyLinksOptions, MessageIds: NoEmptyLinksMessageIds }>} NoEmptyLinksRuleDefinition */ //----------------------------------------------------------------------------- diff --git a/src/rules/no-html.js b/src/rules/no-html.js index 99718c8f..0c463b18 100644 --- a/src/rules/no-html.js +++ b/src/rules/no-html.js @@ -14,8 +14,10 @@ import { findOffsets } from "../util.js"; //----------------------------------------------------------------------------- /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: [{ allowed?: string[]; }]; }>} - * NoHtmlRuleDefinition + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"disallowedElement"} NoHtmlMessageIds + * @typedef {[{ allowed?: string[] }]} NoHtmlOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: NoHtmlOptions, MessageIds: NoHtmlMessageIds }>} NoHtmlRuleDefinition */ //----------------------------------------------------------------------------- diff --git a/src/rules/no-invalid-label-refs.js b/src/rules/no-invalid-label-refs.js index 14b3c041..52b7fe23 100644 --- a/src/rules/no-invalid-label-refs.js +++ b/src/rules/no-invalid-label-refs.js @@ -13,12 +13,14 @@ import { findOffsets, illegalShorthandTailPattern } from "../util.js"; // Type Definitions //----------------------------------------------------------------------------- -/** @typedef {import("unist").Position} Position */ -/** @typedef {import("mdast").Text} TextNode */ -/** @typedef {Parameters[0]['sourceCode']} sourceCode */ /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} - * NoInvalidLabelRuleDefinition + * @import { Position } from "unist"; + * @import { Text } from "mdast"; + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"invalidLabelRef"} NoInvalidLabelRefsMessageIds + * @typedef {[]} NoInvalidLabelRefsOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: NoInvalidLabelRefsOptions, MessageIds: NoInvalidLabelRefsMessageIds }>} NoInvalidLabelRefsRuleDefinition + * @typedef {Parameters[0]['sourceCode']} SourceCode */ //----------------------------------------------------------------------------- @@ -30,8 +32,8 @@ const labelPattern = /\]\[([^\]]+)\]/u; /** * Finds missing references in a node. - * @param {TextNode} node The node to check. - * @param {sourceCode} sourceCode The Markdown source code object. + * @param {Text} node The node to check. + * @param {SourceCode} sourceCode The Markdown source code object. * @returns {Array<{label:string,position:Position}>} The missing references. */ function findInvalidLabelReferences(node, sourceCode) { @@ -126,7 +128,7 @@ function findInvalidLabelReferences(node, sourceCode) { // Rule Definition //----------------------------------------------------------------------------- -/** @type {NoInvalidLabelRuleDefinition} */ +/** @type {NoInvalidLabelRefsRuleDefinition} */ export default { meta: { type: "problem", diff --git a/src/rules/no-missing-atx-heading-space.js b/src/rules/no-missing-atx-heading-space.js index eb74e78b..bf63555d 100644 --- a/src/rules/no-missing-atx-heading-space.js +++ b/src/rules/no-missing-atx-heading-space.js @@ -8,8 +8,10 @@ //----------------------------------------------------------------------------- /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} - * NoMissingAtxHeadingSpaceRuleDefinition + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"missingSpace"} NoMissingAtxHeadingSpaceMessageIds + * @typedef {[]} NoMissingAtxHeadingSpaceOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: NoMissingAtxHeadingSpaceOptions, MessageIds: NoMissingAtxHeadingSpaceMessageIds }>} NoMissingAtxHeadingSpaceRuleDefinition */ //----------------------------------------------------------------------------- diff --git a/src/rules/no-missing-label-refs.js b/src/rules/no-missing-label-refs.js index 06115a7a..fa92871e 100644 --- a/src/rules/no-missing-label-refs.js +++ b/src/rules/no-missing-label-refs.js @@ -13,11 +13,13 @@ import { findOffsets, illegalShorthandTailPattern } from "../util.js"; // Type Definitions //----------------------------------------------------------------------------- -/** @typedef {import("unist").Position} Position */ -/** @typedef {import("mdast").Text} TextNode */ /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} - * NoMissingLabelRuleDefinition + * @import { Position } from "unist"; + * @import { Text } from "mdast"; + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"notFound"} NoMissingLabelRefsMessageIds + * @typedef {[]} NoMissingLabelRefsOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: NoMissingLabelRefsOptions, MessageIds: NoMissingLabelRefsMessageIds }>} NoMissingLabelRefsRuleDefinition */ //----------------------------------------------------------------------------- @@ -26,7 +28,7 @@ import { findOffsets, illegalShorthandTailPattern } from "../util.js"; /** * Finds missing references in a node. - * @param {TextNode} node The node to check. + * @param {Text} node The node to check. * @param {string} nodeText The text of the node. * @returns {Array<{label:string,position:Position}>} The missing references. */ @@ -105,7 +107,7 @@ function findMissingReferences(node, nodeText) { // Rule Definition //----------------------------------------------------------------------------- -/** @type {NoMissingLabelRuleDefinition} */ +/** @type {NoMissingLabelRefsRuleDefinition} */ export default { meta: { type: "problem", diff --git a/src/rules/no-missing-link-fragments.js b/src/rules/no-missing-link-fragments.js index bf401438..361dd8e3 100644 --- a/src/rules/no-missing-link-fragments.js +++ b/src/rules/no-missing-link-fragments.js @@ -13,14 +13,12 @@ import GithubSlugger from "github-slugger"; // Type Definitions //----------------------------------------------------------------------------- -/** @typedef {import("mdast").Node} Node */ /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ - * RuleOptions: [{ - * ignoreCase?: boolean; - * allowPattern?: string; - * }]; - * }>} NoMissingLinkFragmentsRuleDefinition + * @import { Node } from "mdast"; + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"invalidFragment"} NoMissingLinkFragmentsMessageIds + * @typedef {[{ ignoreCase?: boolean; allowPattern?: string }]} NoMissingLinkFragmentsOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: NoMissingLinkFragmentsOptions, MessageIds: NoMissingLinkFragmentsMessageIds }>} NoMissingLinkFragmentsRuleDefinition */ //----------------------------------------------------------------------------- diff --git a/src/rules/no-multiple-h1.js b/src/rules/no-multiple-h1.js index 1e58b2ad..2747bdcb 100644 --- a/src/rules/no-multiple-h1.js +++ b/src/rules/no-multiple-h1.js @@ -14,8 +14,10 @@ import { findOffsets } from "../util.js"; //----------------------------------------------------------------------------- /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: [{ frontmatterTitle?: string; }]; }>} - * NoMultipleH1RuleDefinition + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"multipleH1"} NoMultipleH1MessageIds + * @typedef {[{ frontmatterTitle?: string }]} NoMultipleH1Options + * @typedef {MarkdownRuleDefinition<{ RuleOptions: NoMultipleH1Options, MessageIds: NoMultipleH1MessageIds }>} NoMultipleH1RuleDefinition */ //----------------------------------------------------------------------------- diff --git a/src/rules/no-reversed-media-syntax.js b/src/rules/no-reversed-media-syntax.js index df93162d..874676e6 100644 --- a/src/rules/no-reversed-media-syntax.js +++ b/src/rules/no-reversed-media-syntax.js @@ -13,11 +13,12 @@ import { findOffsets } from "../util.js"; // Type Definitions //----------------------------------------------------------------------------- -/** @typedef {import("mdast").Node} Node */ -/** @typedef {import("mdast").Paragraph} ParagraphNode */ /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} - * NoReversedMediaSyntaxRuleDefinition + * @import { Node, Paragraph } from "mdast"; + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"reversedSyntax"} NoReversedMediaSyntaxMessageIds + * @typedef {[]} NoReversedMediaSyntaxOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: NoReversedMediaSyntaxOptions, MessageIds: NoReversedMediaSyntaxMessageIds }>} NoReversedMediaSyntaxRuleDefinition */ //----------------------------------------------------------------------------- @@ -42,7 +43,7 @@ function isInCodeSpan(matchIndex, codeSpans) { /** * Finds all code spans in the paragraph node by traversing its children - * @param {ParagraphNode} node The paragraph node to search + * @param {Paragraph} node The paragraph node to search * @returns {Array<{startOffset: number, endOffset: number}>} Array of code span positions */ function findCodeSpans(node) { diff --git a/src/rules/require-alt-text.js b/src/rules/require-alt-text.js index 1043cb74..1f3af7bc 100644 --- a/src/rules/require-alt-text.js +++ b/src/rules/require-alt-text.js @@ -14,8 +14,10 @@ import { findOffsets } from "../util.js"; //----------------------------------------------------------------------------- /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} - * RequireAltTextRuleDefinition + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"altTextRequired"} RequireAltTextMessageIds + * @typedef {[]} RequireAltTextOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: RequireAltTextOptions, MessageIds: RequireAltTextMessageIds }>} RequireAltTextRuleDefinition */ //----------------------------------------------------------------------------- diff --git a/src/rules/table-column-count.js b/src/rules/table-column-count.js index e21e0cb5..24176f3a 100644 --- a/src/rules/table-column-count.js +++ b/src/rules/table-column-count.js @@ -8,7 +8,10 @@ //----------------------------------------------------------------------------- /** - * @typedef {import("../types.ts").MarkdownRuleDefinition<{ RuleOptions: []; }>} TableColumnCountRuleDefinition + * @import { MarkdownRuleDefinition } from "../types.js"; + * @typedef {"inconsistentColumnCount"} TableColumnCountMessageIds + * @typedef {[]} TableColumnCountOptions + * @typedef {MarkdownRuleDefinition<{ RuleOptions: TableColumnCountOptions, MessageIds: TableColumnCountMessageIds }>} TableColumnCountRuleDefinition */ //-----------------------------------------------------------------------------