Add regex eslint plugin, fix lints (#59371)

This commit is contained in:
Jake Bailey
2024-08-13 14:16:53 -07:00
committed by GitHub
parent a5e0385edf
commit 195203e971
47 changed files with 236 additions and 92 deletions

View File

@@ -105,7 +105,7 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
}
if (failed) {
const grep = fs.readFileSync(".failed-tests", "utf8")
.split(/\r?\n/g)
.split(/\r?\n/)
.map(test => test.trim())
.filter(test => test.length > 0)
.map(regExpEscape)

View File

@@ -112,7 +112,7 @@ function getPrereleasePatch(tag, plainPatch) {
// but we'd prefer to just remove separators and limit ourselves to YYYYMMDD.
// UTC time will always be implicit here.
const now = new Date();
const timeStr = now.toISOString().replace(/:|T|\.|-/g, "").slice(0, 8);
const timeStr = now.toISOString().replace(/[:T.-]/g, "").slice(0, 8);
return `${plainPatch}-${tag}.${timeStr}`;
}

View File

@@ -124,7 +124,7 @@ class FailedTestsReporter extends Mocha.reporters.Base {
function readTests() {
return fs.readFileSync(file, "utf8")
.split(/\r?\n/g)
.split(/\r?\n/)
.map(line => line.trim())
.filter(line => line.length > 0);
}

View File

@@ -113,7 +113,7 @@ async function main() {
ItemId = ItemId.slice(1); // remove leading semicolon
}
val = val.replace(/]5D;/, "]"); // unescape `]`
val = val.replace(/\]5D;/, "]"); // unescape `]`
out[ItemId] = val;
}
return JSON.stringify(out, undefined, 2);
@@ -146,7 +146,7 @@ async function main() {
*/
function getItemXML(key, value) {
// escape entrt value
value = value.replace(/]/g, "]5D;");
value = value.replace(/\]/g, "]5D;");
return `
<Item ItemId=";${key}" ItemType="0" PsrId="306" Leaf="true">

View File

@@ -150,7 +150,7 @@ function convertPropertyName(origName) {
result = result.replace(/_+/g, "_");
// remove any leading underscore, unless it is followed by a number.
result = result.replace(/^_([^\d])/, "$1");
result = result.replace(/^_(\D)/, "$1");
// get rid of all trailing underscores.
result = result.replace(/_$/, "");

View File

@@ -1,8 +1,8 @@
const MAX_UNICODE_CODEPOINT = 0x10FFFF;
/** @type {(c: string) => boolean} */
const isStart = c => /[\p{ID_Start}\u{2118}\u{212E}\u{309B}\u{309C}]/u.test(c); // Other_ID_Start explicitly included for back compat - see http://www.unicode.org/reports/tr31/#Introduction
const isStart = c => /\p{ID_Start}/u.test(c); // Other_ID_Start explicitly included for back compat - see http://www.unicode.org/reports/tr31/#Introduction
/** @type {(c: string) => boolean} */
const isPart = c => /[\p{ID_Continue}\u{00B7}\u{0387}\u{19DA}\u{1369}\u{136A}\u{136B}\u{136C}\u{136D}\u{136E}\u{136F}\u{1370}\u{1371}]/u.test(c) || isStart(c); // Likewise for Other_ID_Continue
const isPart = c => /\p{ID_Continue}/u.test(c) || isStart(c); // Likewise for Other_ID_Continue
const parts = [];
let partsActive = false;
let startsActive = false;