-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add more flexibility to hyphen separated check; explicit em-dash check #185
Conversation
fb036a6
to
72f9229
Compare
72f9229
to
ae91733
Compare
rules/list-item.js
Outdated
continue; | ||
} | ||
|
||
let [link, ...description] = paragraph.children; | ||
|
||
// Might have children like {image} {text} {link} - {descrition} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
rules/list-item.js
Outdated
// Might have children like {image} {text} {link} - {descrition} | ||
// Keep discarding elements until we find a link | ||
// or linkReference | ||
if (!/link/.test(link.type)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compare explicitly. Doesn't make sense to use regex here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
besides linkReference and link, I'm not sure if there are other link items in markdown -- figured any type matching "link" should get to pass
link.type !== 'linkReference' && link.type !== 'link'
is a mouth full :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use Array#includes
.
besides linkReference and link, I'm not sure if there are other link items in markdown
Look at the docs for the Markdown parser.
rules/list-item.js
Outdated
// Keep discarding elements until we find a link | ||
// or linkReference | ||
if (!/link/.test(link.type)) { | ||
for (let i = 0; i < description.length - 1; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a for-of
loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worse, I don't think I need to test link's type twice. while loop is probably better? (in recent commit)
rules/list-item.js
Outdated
// Keep discarding elements until we find a link | ||
// or linkReference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Keep discarding elements until we find a link | |
// or linkReference | |
// Keep discarding elements until we find a `link` or `linkReference`. |
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
rules/list-item.js
Outdated
// 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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be resolved.
6cb1d02
to
749034a
Compare
749034a
to
a526a1c
Compare
test to confirm #146 and #49 are resolved (though I think at least 146 was already making it through without getting flagged)
The big kludge in this pull request is allowing description text matching " - " to pass through instead of getting hit with "link and description must be separated with a dash."
I also un-commented the TODO list-items fixture that had want-to-be valid image-before-link entries.
They had em-dash separators instead of standard hyphens. I updated lint message to complain about that in addition to en-dashes.
Fixes #146
Fixes #49