Skip to content

Commit

Permalink
no-empty-url: add check for #
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Dec 15, 2023
1 parent e9b3f7e commit 4057f15
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
20 changes: 9 additions & 11 deletions packages/remark-lint-no-empty-url/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,25 @@
*
* ![charlie](http://delta.com/echo.png "foxtrot").
*
* [zulu][yankee].
* [golf][hotel].
*
* [yankee]: http://xray.com
* [india]: http://juliett.com
*
* @example
* {"name": "not-ok.md", "label": "input"}
*
* [golf]().
* [alpha]().
*
* ![hotel]().
* ![bravo](#).
*
* [zulu][yankee].
*
* [yankee]: <>
* [charlie]: <>
*
* @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
* 1:1-1:10: Don’t use links without URL
* 3:1-3:12: Don’t use images without URL
* 5:1-5:14: Don’t use definitions without URL
*/

/**
Expand Down Expand Up @@ -96,7 +94,7 @@ const remarkLintNoEmptyUrl = lintRule(
node.type === 'image' ||
node.type === 'link') &&
place &&
!node.url
(!node.url || node.url === '#' || node.url === '?')
) {
file.message('Don’t use ' + node.type + 's without URL', place)
}
Expand Down
18 changes: 8 additions & 10 deletions packages/remark-lint-no-empty-url/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ It’s recommended to fill them out.

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

[zulu][yankee].
[golf][hotel].

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

###### Out
Expand All @@ -161,21 +161,19 @@ No messages.
###### In

```markdown
[golf]().
[alpha]().

![hotel]().
![bravo](#).

[zulu][yankee].

[yankee]: <>
[charlie]: <>
```

###### 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
1:1-1:10: Don’t use links without URL
3:1-3:12: Don’t use images without URL
5:1-5:14: Don’t use definitions without URL
```

## Compatibility
Expand Down

0 comments on commit 4057f15

Please sign in to comment.