From bfa29a3108c73d6e6bc046e5dd0b460e261d23c6 Mon Sep 17 00:00:00 2001 From: WillForan Date: Mon, 1 Jan 2024 20:58:24 -0500 Subject: [PATCH] validate link children separately: used for link and linkref --- rules/list-item.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/rules/list-item.js b/rules/list-item.js index a709d61..3c91b5c 100644 --- a/rules/list-item.js +++ b/rules/list-item.js @@ -119,15 +119,28 @@ function validateList(list, file) { continue; } + if (!validateListItemLinkChildren(link, file)) { + continue; + } + validateListItemDescription(description, file); } } +function validateListItemLinkChildren(link, file) { + for (const node of link.children) { + if (!listItemLinkNodeAllowList.has(node.type)) { + file.message('Invalid list item link', node); + return false; + } + } + return true; +} + function validateListItemLink(link, file) { // NB. We need remark-lint-no-undefined-references separately // to catch if this is a valid reference. Here we only care that it exists. if (link.type === 'linkReference') { - // TODO: need to test link children against listItemLinkNodeAllowList? return true; } @@ -147,13 +160,6 @@ function validateListItemLink(link, file) { return false; } - for (const node of link.children) { - if (!listItemLinkNodeAllowList.has(node.type)) { - file.message('Invalid list item link', node); - return false; - } - } - return true; }