mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Update MD042/no-empty-links to improve range reporting, remove helpers.emptyLinkRe.
This commit is contained in:
parent
7c1550cbe9
commit
861443c740
4 changed files with 24 additions and 15 deletions
17
lib/md042.js
17
lib/md042.js
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, emptyLinkRe, filterTokens, rangeFromRegExp } =
|
||||
const { addErrorContext, escapeForRegExp, filterTokens } =
|
||||
require("../helpers");
|
||||
|
||||
module.exports = {
|
||||
|
|
@ -26,9 +26,18 @@ module.exports = {
|
|||
} else if (child.type === "link_close") {
|
||||
inLink = false;
|
||||
if (emptyLink) {
|
||||
addErrorContext(onError, child.lineNumber,
|
||||
"[" + linkText + "]()", null, null,
|
||||
rangeFromRegExp(child.line, emptyLinkRe));
|
||||
let context = `[${linkText}]`;
|
||||
let range = null;
|
||||
const match = child.line.match(
|
||||
new RegExp(`${escapeForRegExp(context)}\\((?:|#|<>)\\)`)
|
||||
);
|
||||
if (match) {
|
||||
context = match[0];
|
||||
range = [ match.index + 1, match[0].length ];
|
||||
}
|
||||
addErrorContext(
|
||||
onError, child.lineNumber, context, null, null, range
|
||||
);
|
||||
emptyLink = false;
|
||||
}
|
||||
} else if (inLink) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue