Add ESLint plugin eslint-plugin-regexp, enable recommended rules, apply all automated fixes (refs #657).

This commit is contained in:
David Anson 2022-12-19 21:36:24 -08:00
parent c346e0dbac
commit 6b01a98363
15 changed files with 41 additions and 34 deletions

View file

@ -6,7 +6,7 @@ const { addError, forEachLine, withinAnyRange } = require("../helpers");
const { codeBlockAndSpanRanges, lineMetadata } = require("./cache");
const reversedLinkRe =
/(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)](?!\()/g;
/(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
module.exports = {
"names": [ "MD011", "no-reversed-links" ],

View file

@ -13,7 +13,7 @@ module.exports = {
filterTokens(params, "heading_open", (token) => {
if (headingStyleFor(token) === "atx") {
const { line, lineNumber } = token;
const match = /^(#+)([ \t]{2,})(?:\S)/.exec(line);
const match = /^(#+)([ \t]{2,})\S/.exec(line);
if (match) {
const [
,

View file

@ -4,7 +4,7 @@
const { addErrorContext, filterTokens } = require("../helpers");
const spaceBeforeHeadingRe = /^((?:\s+)|(?:[>\s]+\s\s))[^>\s]/;
const spaceBeforeHeadingRe = /^(\s+|[>\s]+\s\s)[^>\s]/;
module.exports = {
"names": [ "MD023", "heading-start-left", "header-start-left" ],

View file

@ -5,7 +5,7 @@
const { addError, allPunctuationNoQuestion, escapeForRegExp, forEachHeading } =
require("../helpers");
const endOfLineHtmlEntityRe = /&#?[0-9a-zA-Z]+;$/;
const endOfLineHtmlEntityRe = /&#?[\da-zA-Z]+;$/;
module.exports = {
"names": [ "MD026", "no-trailing-punctuation" ],

View file

@ -8,11 +8,11 @@ const {
const { codeBlockAndSpanRanges, lineMetadata, referenceLinkImageData } =
require("./cache");
const linkDestinationRe = /]\(\s*$/;
const linkDestinationRe = /\]\(\s*$/;
// See https://spec.commonmark.org/0.29/#autolinks
const emailAddressRe =
// eslint-disable-next-line max-len
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
/^[\w.!#$%&'*+/=?^`{|}~-]+@[a-zA-Z\d](?:[a-zA-Z\d-]{0,61}[a-zA-Z\d])?(?:\.[a-zA-Z\d](?:[a-zA-Z\d-]{0,61}[a-zA-Z\d])?)*$/;
module.exports = {
"names": [ "MD033", "no-inline-html" ],

View file

@ -7,7 +7,7 @@ const { addErrorContext, filterTokens, funcExpExec, urlFe, withinAnyRange } =
const { codeBlockAndSpanRanges, htmlElementRanges, referenceLinkImageData } =
require("./cache");
const htmlLinkRe = /<a(?:|\s[^>]+)>[^<>]*<\/a\s*>/ig;
const htmlLinkRe = /<a(?:|\s[^>]+)>[^<>]*<\/a\s*>/gi;
module.exports = {
"names": [ "MD034", "no-bare-urls" ],

View file

@ -13,7 +13,7 @@ module.exports = {
filterTokens(params, "hr", (token) => {
const { line, lineNumber } = token;
let { markup } = token;
const match = line.match(/[_*\-\s\t]+$/);
const match = line.match(/[_*\-\s]+$/);
if (match) {
markup = match[0].trim();
}

View file

@ -6,8 +6,8 @@ const { addErrorContext, emphasisMarkersInContent, forEachLine, isBlankLine,
withinAnyRange } = require("../helpers");
const { htmlElementRanges, lineMetadata } = require("./cache");
const emphasisRe = /(^|[^\\]|\\\\)(?:(\*\*?\*?)|(__?_?))/g;
const embeddedUnderscoreRe = /([A-Za-z0-9])_([A-Za-z0-9])/g;
const emphasisRe = /(^|[^\\]|\\\\)(?:(\*{1,3})|(_{1,3}))/g;
const embeddedUnderscoreRe = /([A-Za-z\d])_([A-Za-z\d])/g;
const asteriskListItemMarkerRe = /^([\s>]*)\*(\s+)/;
const leftSpaceRe = /^\s+/;
const rightSpaceRe = /\s+$/;

View file

@ -5,7 +5,7 @@
const { addErrorContext, filterTokens } = require("../helpers");
const spaceInLinkRe =
/\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](?=((?:\([^)]*\))|(?:\[[^\]]*\])))/;
/\[(?:\s[^\]]*|[^\]]*?\s)\](?=(\([^)]*\)|\[[^\]]*\]))/;
module.exports = {
"names": [ "MD039", "no-space-in-links" ],