Enable eslint rule 'no-useless-escape'

Enable recommended rule 'no-useless-escape' [1] and manually fix violations.

[1] https://eslint.org/docs/latest/rules/no-useless-escape

Ref: #8068
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser 2025-06-14 12:27:36 +02:00
parent f29f0b7fd1
commit 14bb7730fe
No known key found for this signature in database
5 changed files with 5 additions and 4 deletions

View file

@ -38,7 +38,7 @@ const g_ModProperties = {
/**
* Tests if the string only contains alphanumeric characters and _ -
*/
const g_RegExpName = /[a-zA-Z0-9\-\_]+/;
const g_RegExpName = /[a-zA-Z0-9\-_]+/;
/**
* Tests if the version string consists only of numbers and at most two periods.

View file

@ -67,7 +67,7 @@ function escapeText(text)
function unescapeText(text)
{
return text.replace(/\\\\/g, "\\").replace(/\\\[/g, "\[");
return text.replace(/\\\\/g, "\\").replace(/\\\[/g, "[");
}
/**

View file

@ -20,7 +20,7 @@ var g_BuddyListDelimiter = ",";
*/
function splitRatingFromNick(playerName)
{
const result = /^(\S+)\ \((\d+)\)$/g.exec(playerName);
const result = /^(\S+) \((\d+)\)$/g.exec(playerName);
return { "nick": result ? result[1] : playerName, "rating": result ? +result[2] : "" };
}

View file

@ -6,7 +6,7 @@ function init()
const hotkeys = Engine.GetHotkeyMap();
// Replace anything starting with 'hotkey.' with its hotkey.
mainText.caption = text.replace(/hotkey\.([a-z0-9_\.]+)/g, (_, k) => formatHotkeyCombinations(hotkeys[k]));
mainText.caption = text.replace(/hotkey.([a-z0-9_.]+)/g, (_, k) => formatHotkeyCombinations(hotkeys[k]));
return new Promise(closePageCallback => {
Engine.GetGUIObjectByName("closeButton").onPress = closePageCallback;

View file

@ -79,6 +79,7 @@ const configEslintRecommended = {
/* "no-unused-vars": "warn", */
"no-useless-backreference": "warn",
"no-useless-catch": "warn",
"no-useless-escape": "warn",
"no-with": "warn",
"use-isnan": "warn",
"valid-typeof": "warn",