mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Improve type safety by strongly-typing the micromark token type property everywhere.
This commit is contained in:
parent
828ae3541a
commit
28e1b23955
7 changed files with 106 additions and 50 deletions
10
lib/md007.js
10
lib/md007.js
|
|
@ -6,12 +6,12 @@ const { addErrorDetailIf } = require("../helpers");
|
|||
const { filterByTypes, getTokenParentOfType, inHtmlFlow } =
|
||||
require("../helpers/micromark.cjs");
|
||||
|
||||
/**
|
||||
* @typedef {import("../helpers/micromark.cjs").Token} Token
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("micromark-util-types").TokenType[] */
|
||||
const unorderedListTypes =
|
||||
[ "blockQuotePrefix", "listItemPrefix", "listUnordered" ];
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("micromark-util-types").TokenType[] */
|
||||
const unorderedParentTypes =
|
||||
[ "blockQuote", "listOrdered", "listUnordered" ];
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ module.exports = {
|
|||
lastBlockQuotePrefix = token;
|
||||
} else if (type === "listUnordered") {
|
||||
let nesting = 0;
|
||||
/** @type {Token | null} */
|
||||
/** @type {import("../helpers/micromark.cjs").Token | null} */
|
||||
let current = token;
|
||||
while (
|
||||
(current = getTokenParentOfType(current, unorderedParentTypes))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue