Skip to content

Commit

Permalink
validate link children separately: used for link and linkref
Browse files Browse the repository at this point in the history
  • Loading branch information
WillForan committed Jan 2, 2024
1 parent ea4a4a8 commit bfa29a3
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions rules/list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check failure on line 137 in rules/list-item.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected indentation of 1 tab but found 3 spaces.

Check failure on line 137 in rules/list-item.js

View workflow job for this annotation

GitHub Actions / Node.js 20

Expected blank line before this statement.

Check failure on line 137 in rules/list-item.js

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected indentation of 1 tab but found 3 spaces.

Check failure on line 137 in rules/list-item.js

View workflow job for this annotation

GitHub Actions / Node.js 18

Expected blank line before this statement.
}

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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit bfa29a3

Please sign in to comment.