Enable require-unicode-regexp and regexp/strict rule (#16408)

This commit is contained in:
fisker Cheung authored and GitHub committed 2024-06-18 07:52:54 +09:00
1 parent 22dad9c1a8
commit c03a12ad2b
127 files changed
+370 -357

No files matched your search

@@ -31,7 +31,7 @@ module.exports = {
return Promise.resolve(
JSON.stringify({
...ast,
print: ast.print?.replace(/\s+/g, " ") ?? "",
print: ast.print?.replace(/\s+/gu, " ") ?? "",
}),
);
},
+2 -2
View File
@@ -422,7 +422,7 @@ async function runTest({
if (!shouldSkipEolTest(code, formatResult.options)) {
for (const eol of ["\r\n", "\r"]) {
const { eolVisualizedOutput: output } = await format(
code.replace(/\n/g, eol),
code.replace(/\n/gu, eol),
formatOptions,
);
// Only if `endOfLine: "auto"` the result will be different
@@ -430,7 +430,7 @@ async function runTest({
formatOptions.endOfLine === "auto"
? visualizeEndOfLine(
// All `code` use `LF`, so the `eol` of result is always `LF`
formatResult.outputWithCursor.replace(/\n/g, eol),
formatResult.outputWithCursor.replace(/\n/gu, eol),
)
: formatResult.eolVisualizedOutput;
expect(output).toEqual(expected);
+1 -1
View File
@@ -1,6 +1,6 @@
function consistentEndOfLine(text) {
let firstEndOfLine;
return text.replace(/\r\n?|\n/g, (endOfLine) => {
return text.replace(/\r\n?|\n/gu, (endOfLine) => {
firstEndOfLine = firstEndOfLine ?? endOfLine;
return firstEndOfLine;
});
+1 -1
View File
@@ -70,7 +70,7 @@ function createSnapshot(
}
input = visualizeRange(input, { rangeStart, rangeEnd });
codeOffset = input.match(/^>?\s+1 \|/)[0].length + 1;
codeOffset = input.match(/^>?\s+1 \|/u)[0].length + 1;
}
if ("endOfLine" in formatOptions) {
+1 -1
View File
@@ -1,5 +1,5 @@
function visualizeEndOfLine(text) {
return text.replace(/\r\n?|\n/g, (endOfLine) => {
return text.replace(/\r\n?|\n/gu, (endOfLine) => {
switch (endOfLine) {
case "\n":
return "<LF>\n";