add eslint rule to disallow look behind regex feature, ignore in git and markdown fyi @lszomoru, @mjbvz

This commit is contained in:
Johannes
2022-03-22 16:02:11 +01:00
parent 8e35e11e0e
commit 0f648cd7db
7 changed files with 99 additions and 0 deletions

View File

@@ -104,6 +104,7 @@ export function stripAngleBrackets(link: string) {
}
const linkPattern = /(\[((!\[[^\]]*?\]\(\s*)([^\s\(\)]+?)\s*\)\]|(?:\\\]|[^\]])*\])\(\s*)(([^\s\(\)]|\([^\s\(\)]*?\))+)\s*(".*?")?\)/g;
// eslint-disable-next-line code-no-look-behind-regex
const referenceLinkPattern = /((?<=^|[^\]])\[((?:\\\]|[^\]])+)\])(?!:)(?:[^\[]|$|\[\s*?([^\s\]]*?)\])/g;
const definitionPattern = /^([\t ]*\[(?!\^)((?:\\\]|[^\]])+)\]:\s*)([^<]\S*|<[^>]+>)/gm;
const inlineCodePattern = /(?:^|[^`])(`+)(?:.+?|.*?(?:(?:\r?\n).+?)*?)(?:\r?\n)?\1(?:$|[^`])/gm;

View File

@@ -48,6 +48,7 @@ export class InMemoryDocument implements vscode.TextDocument {
const before = this._contents.slice(0, offset);
const newLines = before.match(/\r\n|\n/g);
const line = newLines ? newLines.length : 0;
// eslint-disable-next-line code-no-look-behind-regex
const preCharacters = before.match(/(?<=\r\n|\n|^).*$/g);
return new vscode.Position(line, preCharacters ? preCharacters[0].length : 0);
}