markdownlint-rule-relative-links
Advanced tools
Comparing version 2.1.0 to 2.1.1
{ | ||
"name": "markdownlint-rule-relative-links", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"public": true, | ||
@@ -36,3 +36,3 @@ "description": "Custom rule for markdownlint to validate relative links.", | ||
"lint:markdown": "markdownlint-cli2", | ||
"lint:eslint": "eslint . --ignore-path .gitignore", | ||
"lint:eslint": "eslint . --max-warnings 0 --report-unused-disable-directives --ignore-path .gitignore", | ||
"lint:prettier": "prettier . --check --ignore-path .gitignore", | ||
@@ -47,24 +47,24 @@ "lint:staged": "lint-staged", | ||
"dependencies": { | ||
"markdown-it": "13.0.1" | ||
"markdown-it": "13.0.2" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "17.6.5", | ||
"@commitlint/config-conventional": "17.6.5", | ||
"@types/node": "20.3.1", | ||
"editorconfig-checker": "5.0.1", | ||
"eslint": "8.43.0", | ||
"eslint-config-conventions": "9.0.0", | ||
"eslint-config-prettier": "8.8.0", | ||
"eslint-plugin-import": "2.27.5", | ||
"eslint-plugin-prettier": "4.2.1", | ||
"@commitlint/cli": "18.4.3", | ||
"@commitlint/config-conventional": "18.4.3", | ||
"@types/node": "20.9.4", | ||
"editorconfig-checker": "5.1.2", | ||
"eslint": "8.54.0", | ||
"eslint-config-conventions": "13.0.0", | ||
"eslint-config-prettier": "9.0.0", | ||
"eslint-plugin-import": "2.29.0", | ||
"eslint-plugin-prettier": "5.0.1", | ||
"eslint-plugin-promise": "6.1.1", | ||
"eslint-plugin-unicorn": "47.0.0", | ||
"eslint-plugin-unicorn": "49.0.0", | ||
"husky": "8.0.3", | ||
"lint-staged": "13.2.2", | ||
"markdownlint": "0.29.0", | ||
"markdownlint-cli2": "0.8.1", | ||
"lint-staged": "15.1.0", | ||
"markdownlint": "0.32.1", | ||
"markdownlint-cli2": "0.11.0", | ||
"pinst": "3.0.0", | ||
"prettier": "2.8.8", | ||
"semantic-release": "21.0.5" | ||
"prettier": "3.1.0", | ||
"semantic-release": "22.0.8" | ||
} | ||
} |
@@ -8,8 +8,8 @@ <h1 align="center">markdownlint-rule-relative-links</h1> | ||
<p align="center"> | ||
<a href="./CONTRIBUTING.md"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" /></a> | ||
<a href="./CONTRIBUTING.md"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" alt="CONTRIBUTING" /></a> | ||
<a href="./LICENSE"><img src="https://img.shields.io/badge/licence-MIT-blue.svg" alt="Licence MIT"/></a> | ||
<a href="./CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg" alt="Contributor Covenant" /></a> | ||
<br /> | ||
<a href="https://github.com/theoludwig/markdownlint-rule-relative-links/actions/workflows/lint.yml"><img src="https://github.com/theoludwig/markdownlint-rule-relative-links/actions/workflows/lint.yml/badge.svg?branch=develop" /></a> | ||
<a href="https://github.com/theoludwig/markdownlint-rule-relative-linksactions/workflows/test.yml"><img src="https://github.com/theoludwig/markdownlint-rule-relative-links/actions/workflows/test.yml/badge.svg?branch=develop" /></a> | ||
<a href="https://github.com/theoludwig/markdownlint-rule-relative-links/actions/workflows/lint.yml"><img src="https://github.com/theoludwig/markdownlint-rule-relative-links/actions/workflows/lint.yml/badge.svg?branch=develop" alt="Lint" /></a> | ||
<a href="https://github.com/theoludwig/markdownlint-rule-relative-linksactions/workflows/test.yml"><img src="https://github.com/theoludwig/markdownlint-rule-relative-links/actions/workflows/test.yml/badge.svg?branch=develop" alt="Test" /></a> | ||
<br /> | ||
@@ -16,0 +16,0 @@ <a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="Conventional Commits" /></a> |
@@ -1,5 +0,5 @@ | ||
'use strict' | ||
"use strict" | ||
const { pathToFileURL } = require('node:url') | ||
const fs = require('node:fs') | ||
const { pathToFileURL } = require("node:url") | ||
const fs = require("node:fs") | ||
@@ -10,12 +10,12 @@ const { | ||
convertHeadingToHTMLFragment, | ||
getMarkdownHeadings | ||
} = require('./utils.js') | ||
getMarkdownHeadings, | ||
} = require("./utils.js") | ||
const customRule = { | ||
names: ['relative-links'], | ||
description: 'Relative links should be valid', | ||
tags: ['links'], | ||
names: ["relative-links"], | ||
description: "Relative links should be valid", | ||
tags: ["links"], | ||
function: (params, onError) => { | ||
filterTokens(params, 'inline', (token) => { | ||
token.children.forEach((child) => { | ||
filterTokens(params, "inline", (token) => { | ||
for (const child of token.children) { | ||
const { lineNumber, type, attrs } = child | ||
@@ -26,16 +26,18 @@ | ||
if (type === 'link_open') { | ||
attrs.forEach((attr) => { | ||
if (attr[0] === 'href') { | ||
if (type === "link_open") { | ||
for (const attr of attrs) { | ||
if (attr[0] === "href") { | ||
hrefSrc = attr[1] | ||
break | ||
} | ||
}) | ||
} | ||
} | ||
if (type === 'image') { | ||
attrs.forEach((attr) => { | ||
if (attr[0] === 'src') { | ||
if (type === "image") { | ||
for (const attr of attrs) { | ||
if (attr[0] === "src") { | ||
hrefSrc = attr[1] | ||
break | ||
} | ||
}) | ||
} | ||
} | ||
@@ -46,3 +48,3 @@ | ||
const isRelative = | ||
url.protocol === 'file:' && !hrefSrc.startsWith('/') | ||
url.protocol === "file:" && !hrefSrc.startsWith("/") | ||
if (isRelative) { | ||
@@ -55,9 +57,9 @@ const detail = `Link "${hrefSrc}"` | ||
lineNumber, | ||
`${detail} should exist in the file system` | ||
`${detail} should exist in the file system`, | ||
) | ||
return | ||
continue | ||
} | ||
if (type === 'link_open' && url.hash !== '') { | ||
const fileContent = fs.readFileSync(url, { encoding: 'utf8' }) | ||
if (type === "link_open" && url.hash !== "") { | ||
const fileContent = fs.readFileSync(url, { encoding: "utf8" }) | ||
const headings = getMarkdownHeadings(fileContent) | ||
@@ -82,3 +84,3 @@ | ||
lineNumber, | ||
`${detail} should have a valid fragment` | ||
`${detail} should have a valid fragment`, | ||
) | ||
@@ -89,7 +91,7 @@ } | ||
} | ||
}) | ||
} | ||
}) | ||
} | ||
}, | ||
} | ||
module.exports = customRule |
@@ -1,2 +0,2 @@ | ||
const MarkdownIt = require('markdown-it') | ||
const MarkdownIt = require("markdown-it") | ||
@@ -6,3 +6,3 @@ /** | ||
* | ||
* @param {Object} params RuleParams instance. | ||
* @param {object} params RuleParams instance. | ||
* @param {string} type Token type identifier. | ||
@@ -23,3 +23,3 @@ * @param {Function} handler Callback function. | ||
* | ||
* @param {Object} onError RuleOnError instance. | ||
* @param {object} onError RuleOnError instance. | ||
* @param {number} lineNumber Line number. | ||
@@ -29,3 +29,3 @@ * @param {string} [detail] Error details. | ||
* @param {number[]} [range] Column and length of error. | ||
* @param {Object} [fixInfo] RuleOnErrorFixInfo instance. | ||
* @param {object} [fixInfo] RuleOnErrorFixInfo instance. | ||
* @returns {void} | ||
@@ -39,3 +39,3 @@ */ | ||
range, | ||
fixInfo | ||
fixInfo, | ||
}) | ||
@@ -54,3 +54,3 @@ } | ||
return ( | ||
'#' + | ||
"#" + | ||
encodeURIComponent( | ||
@@ -60,3 +60,2 @@ inlineText | ||
// RegExp source with Ruby's \p{Word} expanded into its General Categories | ||
// eslint-disable-next-line max-len | ||
// https://github.com/gjtorikian/html-pipeline/blob/main/lib/html/pipeline/toc_filter.rb | ||
@@ -66,5 +65,5 @@ // https://ruby-doc.org/core-3.0.2/Regexp.html | ||
/[^\p{Letter}\p{Mark}\p{Number}\p{Connector_Punctuation}\- ]/gu, | ||
'' | ||
"", | ||
) | ||
.replace(/ /gu, '-') | ||
.replace(/ /gu, "-"), | ||
) | ||
@@ -74,4 +73,4 @@ ) | ||
const headingTags = new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']) | ||
const ignoredTokens = new Set(['heading_open', 'heading_close']) | ||
const headingTags = new Set(["h1", "h2", "h3", "h4", "h5", "h6"]) | ||
const ignoredTokens = new Set(["heading_open", "heading_close"]) | ||
@@ -95,5 +94,5 @@ /** | ||
if (headingTags.has(token.tag)) { | ||
if (token.type === 'heading_open') { | ||
if (token.type === "heading_open") { | ||
headingToken = token.markup | ||
} else if (token.type === 'heading_close') { | ||
} else if (token.type === "heading_close") { | ||
headingToken = null | ||
@@ -116,3 +115,3 @@ } | ||
}) | ||
.join('')}` | ||
.join("")}`, | ||
) | ||
@@ -128,3 +127,3 @@ } | ||
convertHeadingToHTMLFragment, | ||
getMarkdownHeadings | ||
getMarkdownHeadings, | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12584
183
+ Addedmarkdown-it@13.0.2(transitive)
- Removedmarkdown-it@13.0.1(transitive)
Updatedmarkdown-it@13.0.2