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

no-empty-url: check urls from definitions #299

Merged
merged 1 commit into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
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