Enable no-useless-escape ESLint rule

These fixes maintain the current functionality and do not make any
changes to the matching of the regular expressions.
This commit is contained in:
Koen Vlaswinkel
2024-01-08 16:44:41 +01:00
parent 26e619ba71
commit 188bc53761
6 changed files with 10 additions and 11 deletions

View File

@@ -47,7 +47,6 @@ const baseConfig = {
"@typescript-eslint/no-throw-literal": "error",
"@typescript-eslint/consistent-type-imports": "error",
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
"no-useless-escape": 0,
camelcase: "off",
curly: ["error", "all"],
"escompat/no-regexp-lookbehind": "off",

View File

@@ -40,13 +40,13 @@ export const asyncFilter = async function <T>(
* - `owner` is made up of alphanumeric characters, hyphens, underscores, or periods
* - `repo` is made up of alphanumeric characters, hyphens, underscores, or periods
*/
export const REPO_REGEX = /^[a-zA-Z0-9-_\.]+\/[a-zA-Z0-9-_\.]+$/;
export const REPO_REGEX = /^[a-zA-Z0-9-_.]+\/[a-zA-Z0-9-_.]+$/;
/**
* This regex matches GiHub organization and user strings. These are made up for alphanumeric
* characters, hyphens, underscores or periods.
*/
export const OWNER_REGEX = /^[a-zA-Z0-9-_\.]+$/;
export const OWNER_REGEX = /^[a-zA-Z0-9-_.]+$/;
export function getErrorMessage(e: unknown): string {
if (e instanceof RedactableError) {

View File

@@ -47,7 +47,7 @@ export function parseSarifPlainTextMessage(
// Technically we could have any uri in the target but we don't output that yet.
// The possibility of escaping outside the link is not mentioned in the sarif spec but we always output sartif this way.
const linkRegex =
/(?<=(?<!\\)(\\\\)*)\[(?<linkText>([^\\\]\[]|\\\\|\\\]|\\\[)*)\]\((?<linkTarget>[0-9]+)\)/g;
/(?<=(?<!\\)(\\\\)*)\[(?<linkText>([^\\\][]|\\\\|\\\]|\\\[)*)\]\((?<linkTarget>[0-9]+)\)/g;
let result: RegExpExecArray | null;
let curIndex = 0;
while ((result = linkRegex.exec(message)) !== null) {

View File

@@ -607,11 +607,11 @@ async function getDistributionDisplayingDistributionWarnings(
case DistributionKind.ExtensionManaged:
return 'Please update the CodeQL CLI by running the "CodeQL: Check for CLI Updates" command.';
case DistributionKind.CustomPathConfig:
return `Please update the \"CodeQL CLI Executable Path\" setting to point to a CLI in the version range ${codeQlVersionRange}.`;
return `Please update the "CodeQL CLI Executable Path" setting to point to a CLI in the version range ${codeQlVersionRange}.`;
case DistributionKind.PathEnvironmentVariable:
return (
`Please update the CodeQL CLI on your PATH to a version compatible with ${codeQlVersionRange}, or ` +
`set the \"CodeQL CLI Executable Path\" setting to the path of a CLI version compatible with ${codeQlVersionRange}.`
`set the "CodeQL CLI Executable Path" setting to the path of a CLI version compatible with ${codeQlVersionRange}.`
);
}
})();

View File

@@ -18,7 +18,7 @@ export function install() {
langConfig.wordPattern = new RegExp(langConfig.wordPattern);
langConfig.onEnterRules = onEnterRules;
langConfig.indentationRules = {
decreaseIndentPattern: /^((?!.*?\/\*).*\*\/)?\s*[\}\]].*$/,
decreaseIndentPattern: /^((?!.*?\/\*).*\*\/)?\s*[}\]].*$/,
increaseIndentPattern: /^((?!\/\/).)*(\{[^}"'`]*|\([^)"'`]*|\[[^\]"'`]*)$/,
};
delete langConfig.autoClosingPairs;
@@ -31,18 +31,18 @@ export function install() {
const onEnterRules: OnEnterRule[] = [
{
// e.g. /** | */
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
beforeText: /^\s*\/\*\*(?!\/)([^*]|\*(?!\/))*$/,
afterText: /^\s*\*\/$/,
action: { indentAction: IndentAction.IndentOutdent, appendText: " * " },
},
{
// e.g. /** ...|
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
beforeText: /^\s*\/\*\*(?!\/)([^*]|\*(?!\/))*$/,
action: { indentAction: IndentAction.None, appendText: " * " },
},
{
// e.g. * ...|
beforeText: /^(\t|[ ])*[ ]\*([ ]([^\*]|\*(?!\/))*)?$/,
beforeText: /^(\t|[ ])*[ ]\*([ ]([^*]|\*(?!\/))*)?$/,
// oneLineAboveText: /^(\s*(\/\*\*|\*)).*/,
action: { indentAction: IndentAction.None, appendText: "* " },
},

View File

@@ -356,7 +356,7 @@ async function exportToLocalMarkdown(
// This needs to use .then to ensure we aren't keeping the progress notification open. We shouldn't await the
// "Open exported results" button click.
void showInformationMessageWithAction(
`Variant analysis results exported to \"${exportedResultsPath}\".`,
`Variant analysis results exported to "${exportedResultsPath}".`,
"Open exported results",
).then(async (shouldOpenExportedResults) => {
if (!shouldOpenExportedResults) {