Use @type to provide typing for all instances of params.parsers.micromark.tokens.

This commit is contained in:
David Anson 2024-02-28 21:01:23 -08:00
parent aee8c2d1d3
commit 828ae3541a
23 changed files with 284 additions and 160 deletions

View file

@ -14,11 +14,14 @@ module.exports = {
"description": "Images should have alternate text (alt text)",
"tags": [ "accessibility", "images" ],
"function": function MD045(params, onError) {
// eslint-disable-next-line dot-notation
const { tokens } = params.parsers["micromark"];
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../helpers/micromark.cjs").Token[] */
const micromarkTokens =
// @ts-ignore
params.parsers.micromark.tokens;
// Process Markdown images
const images = filterByTypes(tokens, [ "image" ]);
const images = filterByTypes(micromarkTokens, [ "image" ]);
for (const image of images) {
const labelTexts = filterByTypes(image.children, [ "labelText" ]);
if (labelTexts.some((labelText) => labelText.text.length === 0)) {
@ -36,7 +39,7 @@ module.exports = {
}
// Process HTML images
const htmlTexts = filterByTypes(tokens, [ "htmlText" ]);
const htmlTexts = filterByTypes(micromarkTokens, [ "htmlText" ]);
for (const htmlText of htmlTexts) {
const { startColumn, startLine, text } = htmlText;
const htmlTagInfo = getHtmlTagInfo(htmlText);