![hi]() ![hi] \`[hi]\` [hi]() [hi]
+
+| hi |
+| ----------------------------------------------------------------- |
+| [^hi]
![hi]() ![hi] \`[hi]\` [hi]() [hi] |
+
+[hi]: https://www.hi.com
+[^hi]: hi
+`, // Please do not use `dedent` here, as it removes intentional whitespaces.
+ language: "markdown/gfm",
+ },
{
code: "[foo][bar]",
options: [{ allowLabels: ["bar"] }],
},
+ {
+ code: "[foo][*bar*]",
+ options: [{ allowLabels: ["*bar*"] }],
+ },
{
code: "![foo][bar]",
options: [{ allowLabels: ["bar"] }],
},
{
- code: "[foo][]",
- options: [{ allowLabels: ["foo"] }],
+ code: "![foo][*bar*]",
+ options: [{ allowLabels: ["*bar*"] }],
+ },
+ {
+ code: "[foo][]",
+ options: [{ allowLabels: ["foo"] }],
+ },
+ {
+ code: "[*foo*][]",
+ options: [{ allowLabels: ["*foo*"] }],
+ },
+ {
+ code: "![foo][]",
+ options: [{ allowLabels: ["foo"] }],
+ },
+ {
+ code: "![*foo*][]",
+ options: [{ allowLabels: ["*foo*"] }],
+ },
+ {
+ code: "[foo]",
+ options: [{ allowLabels: ["foo"] }],
+ },
+ {
+ code: "[*foo*]",
+ options: [{ allowLabels: ["*foo*"] }],
+ },
+ {
+ code: "![foo]",
+ options: [{ allowLabels: ["foo"] }],
+ },
+ {
+ code: "![*foo*]",
+ options: [{ allowLabels: ["*foo*"] }],
+ },
+ {
+ code: "[foo]\n[bar]",
+ options: [{ allowLabels: ["foo", "bar"] }],
+ },
+ {
+ code: "[Foo][]\n[Bar][]",
+ options: [{ allowLabels: ["Foo", "Bar"] }],
+ },
+ {
+ code: dedent`
+ - [x] Checked
+ - [-] In progress
+ `,
+ language: "markdown/gfm",
+ options: [{ allowLabels: ["-"] }],
+ },
+ ],
+ invalid: [
+ {
+ code: "[foo][bar]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "bar" },
+ line: 1,
+ column: 7,
+ endLine: 1,
+ endColumn: 10,
+ },
+ ],
+ },
+ {
+ code: "[foo][*bar*]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "*bar*" },
+ line: 1,
+ column: 7,
+ endLine: 1,
+ endColumn: 12,
+ },
+ ],
+ },
+ {
+ code: "[foo][_bar_]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "_bar_" },
+ line: 1,
+ column: 7,
+ endLine: 1,
+ endColumn: 12,
+ },
+ ],
+ },
+ {
+ code: "[foo][~bar~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~bar~" },
+ line: 1,
+ column: 7,
+ endLine: 1,
+ endColumn: 12,
+ },
+ ],
+ },
+ {
+ code: "[foo][**bar**]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "**bar**" },
+ line: 1,
+ column: 7,
+ endLine: 1,
+ endColumn: 14,
+ },
+ ],
+ },
+ {
+ code: "[foo][__bar__]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "__bar__" },
+ line: 1,
+ column: 7,
+ endLine: 1,
+ endColumn: 14,
+ },
+ ],
+ },
+ {
+ code: "[foo][~~bar~~]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~bar~~" },
+ line: 1,
+ column: 7,
+ endLine: 1,
+ endColumn: 14,
+ },
+ ],
+ },
+ {
+ code: "[foo][~~bar~~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~bar~~" },
+ line: 1,
+ column: 7,
+ endLine: 1,
+ endColumn: 14,
+ },
+ ],
+ },
+ {
+ code: "[foo][~~**bar**~~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~**bar**~~" },
+ line: 1,
+ column: 7,
+ endLine: 1,
+ endColumn: 18,
+ },
+ ],
+ },
+ {
+ code: "[foo][~~***bar***~~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~***bar***~~" },
+ line: 1,
+ column: 7,
+ endLine: 1,
+ endColumn: 20,
+ },
+ ],
+ },
+ {
+ code: "![foo][bar]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "bar" },
+ line: 1,
+ column: 8,
+ endLine: 1,
+ endColumn: 11,
+ },
+ ],
+ },
+ {
+ code: "![foo][*bar*]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "*bar*" },
+ line: 1,
+ column: 8,
+ endLine: 1,
+ endColumn: 13,
+ },
+ ],
+ },
+ {
+ code: "![foo][_bar_]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "_bar_" },
+ line: 1,
+ column: 8,
+ endLine: 1,
+ endColumn: 13,
+ },
+ ],
+ },
+ {
+ code: "![foo][~bar~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~bar~" },
+ line: 1,
+ column: 8,
+ endLine: 1,
+ endColumn: 13,
+ },
+ ],
+ },
+ {
+ code: "![foo][**bar**]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "**bar**" },
+ line: 1,
+ column: 8,
+ endLine: 1,
+ endColumn: 15,
+ },
+ ],
+ },
+ {
+ code: "![foo][__bar__]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "__bar__" },
+ line: 1,
+ column: 8,
+ endLine: 1,
+ endColumn: 15,
+ },
+ ],
+ },
+ {
+ code: "![foo][~~bar~~]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~bar~~" },
+ line: 1,
+ column: 8,
+ endLine: 1,
+ endColumn: 15,
+ },
+ ],
+ },
+ {
+ code: "![foo][~~bar~~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~bar~~" },
+ line: 1,
+ column: 8,
+ endLine: 1,
+ endColumn: 15,
+ },
+ ],
+ },
+ {
+ code: "![foo][~~**bar**~~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~**bar**~~" },
+ line: 1,
+ column: 8,
+ endLine: 1,
+ endColumn: 19,
+ },
+ ],
+ },
+ {
+ code: "![foo][~~***bar***~~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~***bar***~~" },
+ line: 1,
+ column: 8,
+ endLine: 1,
+ endColumn: 21,
+ },
+ ],
+ },
+ {
+ code: "[foo][]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "foo" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 5,
+ },
+ ],
+ },
+ {
+ code: "[*foo*][]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "*foo*" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 7,
+ },
+ ],
+ },
+ {
+ code: "[_foo_][]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "_foo_" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 7,
+ },
+ ],
+ },
+ {
+ code: "[~foo~][]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~foo~" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 7,
+ },
+ ],
+ },
+ {
+ code: "[**foo**][]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "**foo**" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 9,
+ },
+ ],
+ },
+ {
+ code: "[__foo__][]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "__foo__" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 9,
+ },
+ ],
+ },
+ {
+ code: "[~~foo~~][]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~foo~~" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 9,
+ },
+ ],
+ },
+ {
+ code: "[~~foo~~][]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~foo~~" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 9,
+ },
+ ],
+ },
+ {
+ code: "[~~**foo**~~][]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~**foo**~~" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 13,
+ },
+ ],
+ },
+ {
+ code: "[~~***foo***~~][]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~***foo***~~" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 15,
+ },
+ ],
+ },
+ {
+ code: "![foo][]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "foo" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 6,
+ },
+ ],
+ },
+ {
+ code: "![*foo*][]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "*foo*" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 8,
+ },
+ ],
+ },
+ {
+ code: "![_foo_][]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "_foo_" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 8,
+ },
+ ],
+ },
+ {
+ code: "![~foo~][]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~foo~" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 8,
+ },
+ ],
+ },
+ {
+ code: "![**foo**][]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "**foo**" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 10,
+ },
+ ],
+ },
+ {
+ code: "![__foo__][]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "__foo__" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 10,
+ },
+ ],
+ },
+ {
+ code: "![~~foo~~][]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~foo~~" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 10,
+ },
+ ],
+ },
+ {
+ code: "![~~foo~~][]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~foo~~" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 10,
+ },
+ ],
+ },
+ {
+ code: "![~~**foo**~~][]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~**foo**~~" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 14,
+ },
+ ],
},
{
- code: "![foo][]",
- options: [{ allowLabels: ["foo"] }],
+ code: "![~~***foo***~~][]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~***foo***~~" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 16,
+ },
+ ],
},
{
code: "[foo]",
- options: [{ allowLabels: ["foo"] }],
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "foo" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 5,
+ },
+ ],
},
{
- code: "![foo]",
- options: [{ allowLabels: ["foo"] }],
+ code: "[*foo*]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "*foo*" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 7,
+ },
+ ],
},
{
- code: "[foo]\n[bar]",
- options: [{ allowLabels: ["foo", "bar"] }],
+ code: "[_foo_]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "_foo_" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 7,
+ },
+ ],
},
{
- code: "[Foo][]\n[Bar][]",
- options: [{ allowLabels: ["Foo", "Bar"] }],
+ code: "[~foo~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~foo~" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 7,
+ },
+ ],
},
{
- code: dedent`
- - [x] Checked
- - [-] In progress
- `,
- language: "markdown/gfm",
- options: [{ allowLabels: ["-"] }],
+ code: "[**foo**]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "**foo**" },
+ line: 1,
+ column: 2,
+ endLine: 1,
+ endColumn: 9,
+ },
+ ],
},
- ],
- invalid: [
{
- code: "[foo][bar]",
+ code: "[__foo__]",
errors: [
{
messageId: "notFound",
- data: { label: "bar" },
+ data: { label: "__foo__" },
line: 1,
- column: 7,
+ column: 2,
endLine: 1,
- endColumn: 10,
+ endColumn: 9,
},
],
},
{
- code: "![foo][bar]",
+ code: "[~~foo~~]",
errors: [
{
messageId: "notFound",
- data: { label: "bar" },
+ data: { label: "~~foo~~" },
line: 1,
- column: 8,
+ column: 2,
endLine: 1,
- endColumn: 11,
+ endColumn: 9,
},
],
},
{
- code: "[foo][]",
+ code: "[~~foo~~]",
+ language: "markdown/gfm",
errors: [
{
messageId: "notFound",
- data: { label: "foo" },
+ data: { label: "~~foo~~" },
line: 1,
column: 2,
endLine: 1,
- endColumn: 5,
+ endColumn: 9,
},
],
},
{
- code: "![foo][]",
+ code: "[~~**foo**~~]",
+ language: "markdown/gfm",
errors: [
{
messageId: "notFound",
- data: { label: "foo" },
+ data: { label: "~~**foo**~~" },
line: 1,
- column: 3,
+ column: 2,
endLine: 1,
- endColumn: 6,
+ endColumn: 13,
},
],
},
{
- code: "[foo]",
+ code: "[~~***foo***~~]",
+ language: "markdown/gfm",
errors: [
{
messageId: "notFound",
- data: { label: "foo" },
+ data: { label: "~~***foo***~~" },
line: 1,
column: 2,
endLine: 1,
- endColumn: 5,
+ endColumn: 15,
},
],
},
@@ -210,6 +853,127 @@ ruleTester.run("no-missing-label-refs", rule, {
},
],
},
+ {
+ code: "![*foo*]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "*foo*" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 8,
+ },
+ ],
+ },
+ {
+ code: "![_foo_]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "_foo_" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 8,
+ },
+ ],
+ },
+ {
+ code: "![~foo~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~foo~" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 8,
+ },
+ ],
+ },
+ {
+ code: "![**foo**]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "**foo**" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 10,
+ },
+ ],
+ },
+ {
+ code: "![__foo__]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "__foo__" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 10,
+ },
+ ],
+ },
+ {
+ code: "![~~foo~~]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~foo~~" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 10,
+ },
+ ],
+ },
+ {
+ code: "![~~foo~~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~foo~~" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 10,
+ },
+ ],
+ },
+ {
+ code: "![~~**foo**~~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~**foo**~~" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 14,
+ },
+ ],
+ },
+ {
+ code: "![~~***foo***~~]",
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "~~***foo***~~" },
+ line: 1,
+ column: 3,
+ endLine: 1,
+ endColumn: 16,
+ },
+ ],
+ },
{
code: "[foo]\n[bar]",
errors: [
@@ -671,6 +1435,60 @@ ruleTester.run("no-missing-label-refs", rule, {
},
],
},
+ // Heading
+ {
+ code: "# [foo]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "foo" },
+ line: 1,
+ column: 4,
+ endLine: 1,
+ endColumn: 7,
+ },
+ ],
+ },
+ {
+ code: "# ![foo]",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "foo" },
+ line: 1,
+ column: 5,
+ endLine: 1,
+ endColumn: 8,
+ },
+ ],
+ },
+ // TabelCell
+ {
+ code: `
+| foo | bar |
+| ----- | ------ |
+| [foo] | ![bar] |
+`,
+ language: "markdown/gfm",
+ errors: [
+ {
+ messageId: "notFound",
+ data: { label: "foo" },
+ line: 4,
+ column: 4,
+ endLine: 4,
+ endColumn: 7,
+ },
+ {
+ messageId: "notFound",
+ data: { label: "bar" },
+ line: 4,
+ column: 13,
+ endLine: 4,
+ endColumn: 16,
+ },
+ ],
+ },
],
});