From a16706bf1f9ba4a64e15115ad3c85759722a4e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Tue, 3 Jun 2025 17:56:01 +0900 Subject: [PATCH 1/9] fix: false neg on shortcut type ref in no-missing-label-refs --- src/rules/no-missing-label-refs.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rules/no-missing-label-refs.js b/src/rules/no-missing-label-refs.js index 06115a7a..78f47e49 100644 --- a/src/rules/no-missing-label-refs.js +++ b/src/rules/no-missing-label-refs.js @@ -3,6 +3,8 @@ * @author Nicholas C. Zakas */ +// Placeholder + //----------------------------------------------------------------------------- // Imports //----------------------------------------------------------------------------- From bac96235e0cdbca2a19a9abedb9ba86a2229add9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Wed, 27 Aug 2025 23:00:20 +0900 Subject: [PATCH 2/9] wip: add more test cases --- tests/rules/no-missing-label-refs.test.js | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/rules/no-missing-label-refs.test.js b/tests/rules/no-missing-label-refs.test.js index f2a95ca2..4e40f2bc 100644 --- a/tests/rules/no-missing-label-refs.test.js +++ b/tests/rules/no-missing-label-refs.test.js @@ -381,6 +381,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, + }, + ], + }, ], }); From 974f9039f5bc8ed3cb437a2dab62ca1686751a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Wed, 3 Sep 2025 21:02:50 +0900 Subject: [PATCH 3/9] wip: add test cases (fails for now) --- tests/rules/no-missing-label-refs.test.js | 216 ++++++++++++++++++++++ 1 file changed, 216 insertions(+) diff --git a/tests/rules/no-missing-label-refs.test.js b/tests/rules/no-missing-label-refs.test.js index ea58aa87..68e97a95 100644 --- a/tests/rules/no-missing-label-refs.test.js +++ b/tests/rules/no-missing-label-refs.test.js @@ -104,6 +104,114 @@ ruleTester.run("no-missing-label-refs", rule, { }, ], }, + { + 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~~]", + 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: [ @@ -117,6 +225,114 @@ ruleTester.run("no-missing-label-refs", rule, { }, ], }, + { + 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~~]", + 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: [ From d24f816e33a09e61444427f201a9f8f171c27540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Wed, 3 Sep 2025 21:13:28 +0900 Subject: [PATCH 4/9] wip: add test cases (fails for now) --- tests/rules/no-missing-label-refs.test.js | 216 ++++++++++++++++++++++ 1 file changed, 216 insertions(+) diff --git a/tests/rules/no-missing-label-refs.test.js b/tests/rules/no-missing-label-refs.test.js index 68e97a95..9e59b28e 100644 --- a/tests/rules/no-missing-label-refs.test.js +++ b/tests/rules/no-missing-label-refs.test.js @@ -346,6 +346,114 @@ ruleTester.run("no-missing-label-refs", rule, { }, ], }, + { + 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~~][]", + 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: [ @@ -359,6 +467,114 @@ 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~~][]", + 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]", errors: [ From 64f2d05373388498b0bac1b77bc3744b64d7258c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Fri, 5 Sep 2025 22:58:16 +0900 Subject: [PATCH 5/9] wip: add more test cases --- tests/rules/no-missing-label-refs.test.js | 217 +++++++++++++++++++++- 1 file changed, 216 insertions(+), 1 deletion(-) diff --git a/tests/rules/no-missing-label-refs.test.js b/tests/rules/no-missing-label-refs.test.js index e323dad8..5eb194a7 100644 --- a/tests/rules/no-missing-label-refs.test.js +++ b/tests/rules/no-missing-label-refs.test.js @@ -25,7 +25,6 @@ const ruleTester = new RuleTester({ ruleTester.run("no-missing-label-refs", rule, { valid: [ - "[*foo*]", "[foo]\n\n[foo]: http://bar.com", "[foo][foo]\n\n[foo]: http://bar.com", "[foo][foo]\n\n[ foo ]: http://bar.com", @@ -629,6 +628,114 @@ ruleTester.run("no-missing-label-refs", rule, { }, ], }, + { + 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~~]", + 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: [ @@ -642,6 +749,114 @@ 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~~]", + 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: [ From cb7ac1c1cd7415824e50dfd242dacaf5606e8dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Fri, 5 Sep 2025 23:02:15 +0900 Subject: [PATCH 6/9] wip: add more test cases --- tests/rules/no-missing-label-refs.test.js | 78 +++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tests/rules/no-missing-label-refs.test.js b/tests/rules/no-missing-label-refs.test.js index 5eb194a7..cb9da0e7 100644 --- a/tests/rules/no-missing-label-refs.test.js +++ b/tests/rules/no-missing-label-refs.test.js @@ -210,6 +210,19 @@ ruleTester.run("no-missing-label-refs", rule, { }, ], }, + { + code: "[foo][~~bar~~]", + errors: [ + { + messageId: "notFound", + data: { label: "~~bar~~" }, + line: 1, + column: 7, + endLine: 1, + endColumn: 14, + }, + ], + }, { code: "[foo][~~bar~~]", language: "markdown/gfm", @@ -331,6 +344,19 @@ ruleTester.run("no-missing-label-refs", rule, { }, ], }, + { + code: "![foo][~~bar~~]", + errors: [ + { + messageId: "notFound", + data: { label: "~~bar~~" }, + line: 1, + column: 8, + endLine: 1, + endColumn: 15, + }, + ], + }, { code: "![foo][~~bar~~]", language: "markdown/gfm", @@ -452,6 +478,19 @@ ruleTester.run("no-missing-label-refs", rule, { }, ], }, + { + code: "[~~foo~~][]", + errors: [ + { + messageId: "notFound", + data: { label: "~~foo~~" }, + line: 1, + column: 2, + endLine: 1, + endColumn: 9, + }, + ], + }, { code: "[~~foo~~][]", language: "markdown/gfm", @@ -573,6 +612,19 @@ ruleTester.run("no-missing-label-refs", rule, { }, ], }, + { + code: "![~~foo~~][]", + errors: [ + { + messageId: "notFound", + data: { label: "~~foo~~" }, + line: 1, + column: 3, + endLine: 1, + endColumn: 10, + }, + ], + }, { code: "![~~foo~~][]", language: "markdown/gfm", @@ -694,6 +746,19 @@ ruleTester.run("no-missing-label-refs", rule, { }, ], }, + { + code: "[~~foo~~]", + errors: [ + { + messageId: "notFound", + data: { label: "~~foo~~" }, + line: 1, + column: 2, + endLine: 1, + endColumn: 9, + }, + ], + }, { code: "[~~foo~~]", language: "markdown/gfm", @@ -815,6 +880,19 @@ ruleTester.run("no-missing-label-refs", rule, { }, ], }, + { + code: "![~~foo~~]", + errors: [ + { + messageId: "notFound", + data: { label: "~~foo~~" }, + line: 1, + column: 3, + endLine: 1, + endColumn: 10, + }, + ], + }, { code: "![~~foo~~]", language: "markdown/gfm", From 2a17eb1fd273981391fedc74a8ccf0e4f7d8a163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Fri, 5 Sep 2025 23:06:08 +0900 Subject: [PATCH 7/9] wip: add more test cases --- tests/rules/no-missing-label-refs.test.js | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/rules/no-missing-label-refs.test.js b/tests/rules/no-missing-label-refs.test.js index cb9da0e7..7c789b51 100644 --- a/tests/rules/no-missing-label-refs.test.js +++ b/tests/rules/no-missing-label-refs.test.js @@ -93,26 +93,50 @@ ruleTester.run("no-missing-label-refs", rule, { code: "[foo][bar]", options: [{ allowLabels: ["bar"] }], }, + { + 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*][]", + 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"] }], From 3439670bc5c2464f28ad56bd963327190e8791df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Fri, 5 Sep 2025 23:30:21 +0900 Subject: [PATCH 8/9] wip: ignores --- src/rules/no-missing-label-refs.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rules/no-missing-label-refs.js b/src/rules/no-missing-label-refs.js index ae8d1e0f..526524cd 100644 --- a/src/rules/no-missing-label-refs.js +++ b/src/rules/no-missing-label-refs.js @@ -3,8 +3,6 @@ * @author Nicholas C. Zakas */ -// Placeholder - //----------------------------------------------------------------------------- // Imports //----------------------------------------------------------------------------- @@ -156,6 +154,10 @@ export default { let allMissingReferences = []; return { + ":matches(heading, paragraph, tableCell) :matches(footnoteReference, html, image, imageReference, inlineCode, link, linkReference)"() { + // TODO + }, + "root:exit"() { for (const missingReference of allMissingReferences) { context.report({ From 61ec875f8641dc0b21a664d228c1fabf7eb21590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Fri, 5 Sep 2025 23:49:09 +0900 Subject: [PATCH 9/9] wip: add more test cases --- tests/rules/no-missing-label-refs.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/rules/no-missing-label-refs.test.js b/tests/rules/no-missing-label-refs.test.js index 7c789b51..64175ba3 100644 --- a/tests/rules/no-missing-label-refs.test.js +++ b/tests/rules/no-missing-label-refs.test.js @@ -89,6 +89,21 @@ ruleTester.run("no-missing-label-refs", rule, { `[escaped${"\\".repeat(3)}][escaped${"\\".repeat(3)}]`, `[escaped${"\\".repeat(5)}][escaped${"\\".repeat(5)}]`, `[escaped${"\\".repeat(7)}][escaped${"\\".repeat(7)}]`, + { + code: ` +# [^hi]
![hi]() ![hi] \`[hi]\` [hi]() [hi] + +hi [^hi]
![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"] }],