feat!: stricter validation of image links (check if the file is an image)

BREAKING CHANGE: links like ![Image](./not-an-image.txt) will now report
an error
This commit is contained in:
2026-02-05 17:46:14 +01:00
parent 12a22980ce
commit 211c71d75b
6 changed files with 30 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
# Invalid
![Image](../not-an-image.txt)
![Image 2](mailto:not-an-image@pictures.com)

1
test/fixtures/not-an-image.txt vendored Normal file
View File

@@ -0,0 +1 @@
not an image

View File

@@ -147,6 +147,14 @@ test("ensure the rule validates correctly", async (t) => {
},
},
},
{
name: "should be invalid with file with an image link that is not an image",
fixturePath: "test/fixtures/invalid/invalid-image.md",
errors: [
'"../not-an-image.txt" should be an image',
'"mailto:not-an-image@pictures.com" should exist in the file system',
],
},
]
for (const { name, fixturePath, errors, config = defaultConfig } of testCases) {