Skip to content

Commit

Permalink
no-empty-url: check urls from definitions
Browse files Browse the repository at this point in the history
Closes GH-299.

Reviewed-by: Titus Wormer <tituswormer@gmail.com>
  • Loading branch information
Xunnamius committed Oct 26, 2022
1 parent 6ca7eef commit 5bdc23b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/remark-lint-no-empty-url/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,27 @@
*
* ![charlie](http://delta.com/echo.png "foxtrot").
*
* [zulu][yankee].
*
* [yankee]: http://xray.com
*
* @example
* {"name": "not-ok.md", "label": "input"}
*
* [golf]().
*
* ![hotel]().
*
* [zulu][yankee].
*
* [yankee]: <>
*
* @example
* {"name": "not-ok.md", "label": "output"}
*
* 1:1-1:9: Don’t use links without URL
* 3:1-3:11: Don’t use images without URL
* 7:1-7:13: Don’t use definitions without URL
*/

/**
Expand All @@ -57,7 +66,9 @@ const remarkLintNoEmptyUrl = lintRule(
(tree, file) => {
visit(tree, (node) => {
if (
(node.type === 'link' || node.type === 'image') &&
(node.type === 'link' ||
node.type === 'image' ||
node.type === 'definition') &&
!generated(node) &&
!node.url
) {
Expand Down
9 changes: 9 additions & 0 deletions packages/remark-lint-no-empty-url/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ It’s recommended to fill them out.
[alpha](http://bravo.com).

![charlie](http://delta.com/echo.png "foxtrot").

[zulu][yankee].

[yankee]: http://xray.com
```

###### Out
Expand All @@ -150,13 +154,18 @@ No messages.
[golf]().

![hotel]().

[zulu][yankee].

[yankee]: <>
```

###### Out

```text
1:1-1:9: Don’t use links without URL
3:1-3:11: Don’t use images without URL
7:1-7:13: Don’t use definitions without URL
```

## Compatibility
Expand Down

0 comments on commit 5bdc23b

Please sign in to comment.