Enable unicorn/prefer-string-repeat rule (#19306)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
fisker Cheungandautofix-ci[bot] authored and GitHub committed 2026-06-08 18:16:28 +08:00
1 parent a5ba6d426e
commit 3149f353d7
7 files changed
+16 -15

No files matched your search

-1
View File
@@ -297,7 +297,6 @@ const configs = [
"unicorn/prefer-https": "off",
"unicorn/prefer-includes-over-repeated-comparisons": "off",
"unicorn/prefer-query-selector": "off",
"unicorn/prefer-string-repeat": "off",
"unicorn/prefer-ternary": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/relative-url-style": "off",
+1 -1
View File
@@ -7,7 +7,7 @@ runFormatTest(
"",
// empty lines
"\n",
"\n\n\n\n",
"\n".repeat(4),
// semicolons
";",
";;;;",
+3 -3
View File
@@ -13,19 +13,19 @@ runFormatTest(
"",
// space
" ",
" ",
" ".repeat(5),
// `\n`
"\n",
" \n",
" \n ",
"\n\n\n\n",
"\n".repeat(4),
" \n \n \n\n",
" \n \n \n\n ",
// `\r`
"\r",
" \r",
" \r ",
"\r\r\r\r",
"\r".repeat(4),
" \r \r \r\r",
" \r \r \r\r ",
// `\r\n`
+2 -2
View File
@@ -1,6 +1,6 @@
const blockStyles = ["|", ">", "|+", "|-", ">+", ">-"];
const trailingSpace = ["", " ", " \t"];
const newlines = ["", "\n", "\n\n", "\n\n\n"];
const trailingSpace = ["", " ".repeat(3), " \t"];
const newlines = ["", "\n", "\n\n", "\n".repeat(3)];
const snippets = blockStyles.flatMap((blockStyle) =>
trailingSpace.flatMap((space) =>
@@ -94,8 +94,10 @@ test("sharedUtil.getStringWidth", () => {
test("sharedUtil.getAlignmentSize", () => {
const { getAlignmentSize } = utilities;
expect(getAlignmentSize(" ")).toBe(3);
expect(getAlignmentSize(" ", /* tabWidth */ 2, /* startIndex */ 2)).toBe(1);
expect(getAlignmentSize(" ".repeat(3))).toBe(3);
expect(
getAlignmentSize(" ".repeat(3), /* tabWidth */ 2, /* startIndex */ 2),
).toBe(1);
expect(getAlignmentSize("\t\t", /* tabWidth */ 2)).toBe(4);
expect(getAlignmentSize("\t\t", /* tabWidth */ 3)).toBe(6);
expect(getAlignmentSize("\t\t", /* tabWidth */ 3, /* startIndex */ 1)).toBe(
+1 -1
View File
@@ -11,7 +11,7 @@ test("Should reject if too many cursor in doc", () => {
test("Should trim blank first line", () => {
expect(
printDocToString([" ", hardline, "Prettier", hardline], options)
printDocToString([" ".repeat(3), hardline, "Prettier", hardline], options)
.formatted,
).toBe("\nPrettier\n");
});
+5 -5
View File
@@ -258,22 +258,22 @@ export default function getCodeSamples(parser) {
"ship-to: *id001",
"product:",
" - ",
" ",
" ".repeat(4),
" sku : BL394D",
" ? quantity ",
" : 4",
" description : Basketball",
" ? price ",
" : 450.00",
" ",
" ",
" ".repeat(6),
" ".repeat(6),
" - ",
" sku : BL4438H",
" quantity : 1",
" description: Super Hoop",
" price : 2392.00",
" ",
" ",
" ".repeat(6),
" ".repeat(6),
"tax : 251.42",
"total : 4443.52",
"comments: >",