Skip to content

Commit 72f9229

Browse files
committed
address sindresorhus#161 with linkReference test; update list-item snapshots
1 parent dc58049 commit 72f9229

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

rules/list-item.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,10 @@ function validateList(list, file) {
110110

111111
// Might have children like {image} {text} {link} - {descrition}
112112
// Keep discarding elements until we find a link
113-
if (link.type !== 'link') {
113+
// or linkReference
114+
if (!/link/.test(link.type)) {
114115
for (let i = 0; i < description.length - 1; i++) {
115-
if (description[i].type === 'link') {
116+
if (/link/.test(description[i].type)) {
116117
link = description[i];
117118
description = description.slice(i + 1);
118119
}
@@ -128,6 +129,15 @@ function validateList(list, file) {
128129
}
129130

130131
function validateListItemLink(link, file) {
132+
133+
// NB. need remark-lint-no-undefined-references separately
134+
// to catch if this is a valid reference. here we only care that it exists
135+
136+
if (link.type === 'linkReference') {
137+
// TODO: need to test link children against listItemLinkNodeAllowList?
138+
return true;
139+
}
140+
131141
if (link.type !== 'link') {
132142
file.message('Invalid list item link', link);
133143
return false;

test/fixtures/list-item/0.md

+3
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ These sub-lists use mixed indentation (spaces and tabs).
136136
- [why-is-node-running](https://github.com/mafintosh/why-is-node-running) - Node.js is running but you don't know why?
137137

138138

139+
- [gtkada] - Ada graphical toolkit based on Gtk3 components (issue #161 link reference below but checked by `remark-lint-no-undefined-references` not `rules/list-item.js`).
139140
- [foo](https://foo.com) ![stars](https://img.shields.io/github/stars/foo/foo.svg) - Valid description.
140141
- ![v3](img/vapor-3.png) [API Error Middleware](https://github.com/skelpo/APIErrorMiddleware) - Vapor middleware for converting thrown errors to JSON responses.
141142
- ![v2](img/vapor-2.png) ![v3](img/vapor-3.png) [Bugsnag](https://github.com/nodes-vapor/bugsnag) - Report errors with Bugsnag.
@@ -145,3 +146,5 @@ These sub-lists use mixed indentation (spaces and tabs).
145146
- [__Compiling machine learning programs via high-level tracing__. Roy Frostig, Matthew James Johnson, Chris Leary. _MLSys 2018_.](https://mlsys.org/Conferences/doc/2018/146.pdf) - This white paper describes an early version of JAX, detailing how computation is traced and compiled (issue #136)
146147
-->
147148

149+
[gtkada]: https://github.com/AdaCore/gtkada
150+

test/fixtures/list-item/1.md

+1
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,4 @@ Test description's ending punctuation.
7070

7171
- [foo](https://foo.com) - Quote-inducing double punctuation “end…”??!
7272
- [foo](https://foo.com) - Quote-inducing double punctuation “end?…...”…...?
73+
- [gtkada] - reference link with no reference
10 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)