Skip to content
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
22 changes: 21 additions & 1 deletion packages/remark-lint-no-undefined-references/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
* [*Uranus*][] is the seventh planet from the Sun.
*
* [Neptune][neptune][more] is the eighth and farthest planet from the Sun.
*
* @example
* {"label": "output", "name": "not-ok.md"}
*
Expand Down Expand Up @@ -148,6 +149,21 @@
* 1:8-1:18: Unexpected reference to undefined definition, expected corresponding definition (`mercury`) for a footnote or escaped opening bracket (`\[`) for regular text
*
* @example
* {"gfm": true, "label": "input", "name": "gfm-table.md"}
*
* | [Planet] | [Radius] |
* | ----------------- | --------- |
* | [Mercury] | 2439.7 km |
*
* [planet]: https://example.com/planet/
*
* @example
* {"gfm": true, "label": "output", "name": "gfm-table.md"}
*
* 1:23-1:31: Unexpected reference to undefined definition, expected corresponding definition (`radius`) for a link or escaped opening bracket (`\[`) for regular text
* 3:3-3:12: Unexpected reference to undefined definition, expected corresponding definition (`mercury`) for a link or escaped opening bracket (`\[`) for regular text
*
* @example
* {"config": {"allowShortcutLink": true}, "label": "input", "name": "allow-shortcut-link.md"}
*
* [Mercury] is the first planet from the Sun and the smallest in the Solar
Expand Down Expand Up @@ -244,7 +260,11 @@ const remarkLintNoUndefinedReferences = lintRule(
footnoteDefinitionIdentifiers.add(normalizeIdentifier(node.identifier))
}

if (node.type === 'heading' || node.type === 'paragraph') {
if (
node.type === 'heading' ||
node.type === 'paragraph' ||
node.type === 'tableCell'
) {
phrasingStacks.push([...parents, node])
}
})
Expand Down
1 change: 1 addition & 0 deletions packages/remark-lint-no-undefined-references/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"author": "Titus Wormer <[email protected]> (https://wooorm.com)",
"bugs": "https://github.com/remarkjs/remark-lint/issues",
"contributors": [
"Aaron Moat <[email protected]>",
"Merlijn Vos <[email protected]>",
"Murderlon <[email protected]>",
"Titus Wormer <[email protected]>"
Expand Down
22 changes: 22 additions & 0 deletions packages/remark-lint-no-undefined-references/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,28 @@ Solar System.
1:8-1:18: Unexpected reference to undefined definition, expected corresponding definition (`mercury`) for a footnote or escaped opening bracket (`\[`) for regular text
```

##### `gfm-table.md`

###### In

> 👉 **Note**: this example uses
> GFM ([`remark-gfm`][github-remark-gfm]).

```markdown
| [Planet] | [Radius] |
| ----------------- | --------- |
| [Mercury] | 2439.7 km |

[planet]: https://example.com/planet/
```

###### Out

```text
1:23-1:31: Unexpected reference to undefined definition, expected corresponding definition (`radius`) for a link or escaped opening bracket (`\[`) for regular text
3:3-3:12: Unexpected reference to undefined definition, expected corresponding definition (`mercury`) for a link or escaped opening bracket (`\[`) for regular text
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs and tests are generated from the code.
The docs you wrote will be automatically changed.
You can remove the manual test.
And turn this, what you added manually in the docs, into an actual test, see the code: at the top of the index.js file, there are examples.

Please then run the npm scripts provided by this package. Thank you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, didn't realise this. I did think the coverage of the rule was low, makes sense that the examples (docs) are the tests! Fixed in 5fa9f25.


##### `allow-shortcut-link.md`

When configured with `{ allowShortcutLink: true }`.
Expand Down