Skip to content
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 url to vfile messages #71

Merged
merged 2 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/check/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ function warn(ctx, reference) {
let index = -1

while (++index < reference.nodes.length) {
reference.file.message(reason, reference.nodes[index], origin)
const message = reference.file.message(
reason,
reference.nodes[index],
origin
)
message.url = 'https://github.com/remarkjs/remark-validate-links#readme'

if (suggestion) {
message.expected = [suggestion]
remcohaszing marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
21 changes: 21 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ test('remark-validate-links', async (t) => {
],
'should work on the API'
)
t.deepEqual(
vfile.messages.map((message) => message.url),
[
'https://github.com/remarkjs/remark-validate-links#readme',
'https://github.com/remarkjs/remark-validate-links#readme',
'https://github.com/remarkjs/remark-validate-links#readme',
'https://github.com/remarkjs/remark-validate-links#readme',
'https://github.com/remarkjs/remark-validate-links#readme'
],
'should add message urls'
)

const file = await remark()
.use(links)
Expand Down Expand Up @@ -718,6 +729,16 @@ test('remark-validate-links', async (t) => {
].join('\n'),
'should support a Bitbucket shortcode'
)

const withSuggestions = await remark()
.use(links)
.use(sort)
.process(readSync('suggestions.md'))
t.deepEqual(
withSuggestions.messages.map((message) => message.expected),
[['hello']],
'should support suggestions'
)
;({stderr} = await exec(
[
bin,
Expand Down