mirror of
https://github.com/theoludwig/markdownlint-rule-relative-links.git
synced 2026-02-20 03:09:05 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
f48932001a
|
|||
|
c744c4872a
|
@@ -1,4 +1,10 @@
|
|||||||
{
|
{
|
||||||
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||||
"extends": ["node_modules/eslint-config-conventions/.oxlintrc.json"]
|
"extends": ["node_modules/eslint-config-conventions/.oxlintrc.json"],
|
||||||
|
"env": {
|
||||||
|
"builtin": true,
|
||||||
|
"browser": true,
|
||||||
|
"node": true,
|
||||||
|
"shared-node-browser": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1210
package-lock.json
generated
1210
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@@ -36,18 +36,18 @@
|
|||||||
"release": "semantic-release"
|
"release": "semantic-release"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"markdown-it": "14.1.0",
|
"markdown-it": "14.1.1",
|
||||||
"mime": "4.1.0"
|
"mime": "4.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/markdown-it": "14.1.2",
|
"@types/markdown-it": "14.1.2",
|
||||||
"@types/node": "25.2.1",
|
"@types/node": "25.3.0",
|
||||||
"eslint-config-conventions": "21.2.0",
|
"eslint-config-conventions": "21.2.2",
|
||||||
"markdownlint": "0.40.0",
|
"markdownlint": "0.40.0",
|
||||||
"markdownlint-cli2": "0.20.0",
|
"markdownlint-cli2": "0.21.0",
|
||||||
"oxfmt": "0.28.0",
|
"oxfmt": "0.34.0",
|
||||||
"oxlint": "1.43.0",
|
"oxlint": "1.49.0",
|
||||||
"oxlint-tsgolint": "0.11.4",
|
"oxlint-tsgolint": "0.14.1",
|
||||||
"semantic-release": "25.0.3",
|
"semantic-release": "25.0.3",
|
||||||
"typescript": "5.9.3"
|
"typescript": "5.9.3"
|
||||||
},
|
},
|
||||||
|
|||||||
17
src/index.js
17
src/index.js
@@ -70,11 +70,24 @@ const relativeLinksRule = {
|
|||||||
url = new URL(hrefSrc, pathToFileURL(params.name))
|
url = new URL(hrefSrc, pathToFileURL(params.name))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url.protocol !== "file:" && type !== "image") {
|
const detail = `"${hrefSrc}"`
|
||||||
|
|
||||||
|
if (
|
||||||
|
type === "image" &&
|
||||||
|
url.protocol !== "file:" &&
|
||||||
|
url.protocol !== "http:" &&
|
||||||
|
url.protocol !== "https:"
|
||||||
|
) {
|
||||||
|
onError({
|
||||||
|
lineNumber,
|
||||||
|
detail: `${detail} should be an image`,
|
||||||
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const detail = `"${hrefSrc}"`
|
if (url.protocol !== "file:") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if (!fs.existsSync(url)) {
|
if (!fs.existsSync(url)) {
|
||||||
onError({
|
onError({
|
||||||
|
|||||||
3
test/fixtures/valid/ignore-external-image.md
vendored
Normal file
3
test/fixtures/valid/ignore-external-image.md
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Valid
|
||||||
|
|
||||||
|

|
||||||
@@ -152,7 +152,7 @@ test("ensure the rule validates correctly", async (t) => {
|
|||||||
fixturePath: "test/fixtures/invalid/invalid-image.md",
|
fixturePath: "test/fixtures/invalid/invalid-image.md",
|
||||||
errors: [
|
errors: [
|
||||||
'"../not-an-image.txt" should be an image',
|
'"../not-an-image.txt" should be an image',
|
||||||
'"mailto:not-an-image@pictures.com" should exist in the file system',
|
'"mailto:not-an-image@pictures.com" should be an image',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -239,6 +239,10 @@ test("ensure the rule validates correctly", async (t) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "should ignore external image links",
|
||||||
|
fixturePath: "test/fixtures/valid/ignore-external-image.md",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const { name, fixturePath, config = defaultConfig } of testCases) {
|
for (const { name, fixturePath, config = defaultConfig } of testCases) {
|
||||||
|
|||||||
Reference in New Issue
Block a user