no-empty-url: check urls from definitions

Closes GH-299.

Reviewed-by: Titus Wormer <tituswormer@gmail.com>
This commit is contained in:
Bernard 2022-10-26 02:44:48 -05:00 committed by GitHub
parent 6ca7eeff07
commit 5bdc23b1a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -26,6 +26,10 @@
*
* ![charlie](http://delta.com/echo.png "foxtrot").
*
* [zulu][yankee].
*
* [yankee]: http://xray.com
*
* @example
* {"name": "not-ok.md", "label": "input"}
*
@ -33,11 +37,16 @@
*
* ![hotel]().
*
* [zulu][yankee].
*
* [yankee]: <>
*
* @example
* {"name": "not-ok.md", "label": "output"}
*
* 1:1-1:9: Dont use links without URL
* 3:1-3:11: Dont use images without URL
* 7:1-7:13: Dont use definitions without URL
*/
/**
@ -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
) {

View File

@ -136,6 +136,10 @@ Its recommended to fill them out.
[alpha](http://bravo.com).
![charlie](http://delta.com/echo.png "foxtrot").
[zulu][yankee].
[yankee]: http://xray.com
```
###### Out
@ -150,6 +154,10 @@ No messages.
[golf]().
![hotel]().
[zulu][yankee].
[yankee]: <>
```
###### Out
@ -157,6 +165,7 @@ No messages.
```text
1:1-1:9: Dont use links without URL
3:1-3:11: Dont use images without URL
7:1-7:13: Dont use definitions without URL
```
## Compatibility