Visitar URL original
Update eslint-plugin-unicorn to v53 (#16275) · prettier/prettier@b26f56b · GitHub
Skip to content

Commit b26f56b

Browse files
authored
Update eslint-plugin-unicorn to v53 (#16275)
1 parent 80bdbfe commit b26f56b

21 files changed

Lines changed: 91 additions & 68 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
"eslint-plugin-react": "7.34.1",
137137
"eslint-plugin-regexp": "2.6.0",
138138
"eslint-plugin-simple-import-sort": "12.1.0",
139-
"eslint-plugin-unicorn": "52.0.0",
139+
"eslint-plugin-unicorn": "53.0.0",
140140
"esm-utils": "4.3.0",
141141
"execa": "7.2.0",
142142
"jest": "30.0.0-alpha.4",

‎scripts/build/build-javascript-module.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ function getEsbuildOptions({ file, files, shouldCollectLicenses, cliOptions }) {
8484
text
8585
.replace(
8686
"const line = (0, _detectNewline().default)(docblock) ?? _os().EOL;",
87-
'const line = "\\n"',
87+
String.raw`const line = "\n"`,
8888
)
8989
.replace(
9090
"const line = (0, _detectNewline().default)(comments) ?? _os().EOL;",
91-
'const line = "\\n"',
91+
String.raw`const line = "\n"`,
9292
)
9393
.replace(/\nfunction _os\(\).*?\n}/s, "")
9494
.replace(/\nfunction _detectNewline\(\).*?\n}/s, ""),

‎scripts/build/modify-typescript-module.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ function* getModules(text) {
2121
if (/\S/.test(code)) {
2222
const esmRegExp = new RegExp(
2323
[
24-
"\\s*var (?<initFunctionName>\\w+) = __esm\\({",
24+
String.raw`\s*var (?<initFunctionName>\w+) = __esm\({`,
2525
`\\s*"${escapeStringRegexp(path)}"\\(\\) {`,
2626
".*",
27-
"\\s*}",
28-
"\\s*}\\);",
29-
].join("\\n"),
27+
String.raw`\s*}`,
28+
String.raw`\s*}\);`,
29+
].join(String.raw`\n`),
3030
"s",
3131
);
3232
const match = code.match(esmRegExp);
@@ -90,11 +90,11 @@ class TypeScriptModuleSource {
9090
const regexp = new RegExp(
9191
[
9292
"(?<=\n)",
93-
"(?<indentString>\\s*)",
93+
String.raw`(?<indentString>\s*)`,
9494
escapeStringRegexp(start),
9595
".*?",
9696
"(?<=\n)",
97-
"\\k<indentString>",
97+
String.raw`\k<indentString>`,
9898
escapeStringRegexp(end),
9999
"(?=\n)",
100100
].join(""),

‎scripts/bundle-eslint-config.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ export default [
3232
"error",
3333
// Forbid `require()` .mjs file
3434
{
35-
selector:
36-
'CallExpression[callee.name="require"][arguments.0.value=/^\\..*?\\.mjs$/]',
35+
selector: String.raw`CallExpression[callee.name="require"][arguments.0.value=/^\..*?\.mjs$/]`,
3736
message: ".mjs file can't be `require()`d",
3837
},
3938
],

‎src/cli/expand-patterns.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ function escapePathForGlob(path) {
178178
.escapePath(
179179
path.replaceAll("\\", "\0"), // Workaround for fast-glob#262 (part 1)
180180
)
181-
.replaceAll("\\!", "@(!)") // Workaround for fast-glob#261
182-
.replaceAll("\0", "@(\\\\)"); // Workaround for fast-glob#262 (part 2)
181+
.replaceAll(String.raw`\!`, "@(!)") // Workaround for fast-glob#261
182+
.replaceAll("\0", String.raw`@(\\)`); // Workaround for fast-glob#262 (part 2)
183183
}
184184

185185
/**

‎src/language-graphql/printer-graphql.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ function genericPrint(path, options, print) {
9191

9292
case "StringValue":
9393
if (node.block) {
94-
const lines = node.value.replaceAll('"""', '\\"""').split("\n");
94+
const lines = node.value
95+
.replaceAll('"""', String.raw`\"""`)
96+
.split("\n");
9597
if (lines.length === 1) {
9698
lines[0] = lines[0].trim();
9799
}
@@ -104,7 +106,9 @@ function genericPrint(path, options, print) {
104106
}
105107
return [
106108
'"',
107-
node.value.replaceAll(/["\\]/g, "\\$&").replaceAll("\n", "\\n"),
109+
node.value
110+
.replaceAll(/["\\]/g, String.raw`\$&`)
111+
.replaceAll("\n", String.raw`\n`),
108112
'"',
109113
];
110114

‎src/language-handlebars/printer-glimmer.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function print(path, options, print) {
159159
/* if `{{my-component}}` (or any text containing "{{")
160160
* makes it to the TextNode, it means it was escaped,
161161
* so let's print it escaped, ie.; `\{{my-component}}` */
162-
let text = node.chars.replaceAll("{{", "\\{{");
162+
let text = node.chars.replaceAll("{{", String.raw`\{{`);
163163

164164
const attrName = getCurrentAttributeName(path);
165165

‎src/language-js/embed/html.js‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ async function printEmbedHtmlLike(parser, textToDoc, print, path, options) {
3232

3333
const expressionDocs = printTemplateExpressions(path, print);
3434

35-
const placeholderRegex = new RegExp(composePlaceholder("(\\d+)"), "g");
35+
const placeholderRegex = new RegExp(
36+
composePlaceholder(String.raw`(\d+)`),
37+
"g",
38+
);
3639
let topLevelCount = 0;
3740
const doc = await textToDoc(text, {
3841
parser,
@@ -56,7 +59,10 @@ async function printEmbedHtmlLike(parser, textToDoc, print, path, options) {
5659
if (component) {
5760
component = uncookTemplateElementValue(component);
5861
if (options.__embeddedInHtml) {
59-
component = component.replaceAll(/<\/(?=script\b)/gi, "<\\/");
62+
component = component.replaceAll(
63+
/<\/(?=script\b)/gi,
64+
String.raw`<\/`,
65+
);
6066
}
6167
parts.push(component);
6268
}

‎src/language-js/print/template-literal.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ function escapeTemplateCharacters(doc, raw) {
250250
}
251251

252252
function uncookTemplateElementValue(cookedValue) {
253-
return cookedValue.replaceAll(/([\\`]|\${)/g, "\\$1");
253+
return cookedValue.replaceAll(/([\\`]|\${)/g, String.raw`\$1`);
254254
}
255255

256256
function isJestEachTemplateLiteral({ node, parent }) {

‎src/language-markdown/mdx.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
const IMPORT_REGEX = /^import\s/;
2626
const EXPORT_REGEX = /^export\s/;
27-
const BLOCKS_REGEX = "[a-z][a-z0-9]*(\\.[a-z][a-z0-9]*)*|";
27+
const BLOCKS_REGEX = String.raw`[a-z][a-z0-9]*(\.[a-z][a-z0-9]*)*|`;
2828
const COMMENT_REGEX = /<!---->|<!---?[^>-](?:-?[^-])*-->/;
2929
const ES_COMMENT_REGEX = /^{\s*\/\*(.*)\*\/\s*}/;
3030
const EMPTY_NEWLINE = "\n\n";

0 commit comments

Comments
 (0)