diff --git a/eslint.config.js b/eslint.config.js index b8fd23098..a3dc38994 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -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", diff --git a/tests/format/js/empty/format.test.js b/tests/format/js/empty/format.test.js index 8c1fb22cf..f3cd4fa15 100644 --- a/tests/format/js/empty/format.test.js +++ b/tests/format/js/empty/format.test.js @@ -7,7 +7,7 @@ runFormatTest( "", // empty lines "\n", - "\n\n\n\n", + "\n".repeat(4), // semicolons ";", ";;;;", diff --git a/tests/format/misc/empty/format.test.js b/tests/format/misc/empty/format.test.js index 877be3dcf..256fe7414 100644 --- a/tests/format/misc/empty/format.test.js +++ b/tests/format/misc/empty/format.test.js @@ -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` diff --git a/tests/format/yaml/block-value/format.test.js b/tests/format/yaml/block-value/format.test.js index 4253534ff..2282ccafd 100644 --- a/tests/format/yaml/block-value/format.test.js +++ b/tests/format/yaml/block-value/format.test.js @@ -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) => diff --git a/tests/integration/__tests__/public-utilities.js b/tests/integration/__tests__/public-utilities.js index 62095c11d..8a5c06fe1 100644 --- a/tests/integration/__tests__/public-utilities.js +++ b/tests/integration/__tests__/public-utilities.js @@ -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( diff --git a/tests/unit/print-doc-to-string.js b/tests/unit/print-doc-to-string.js index 14c969332..d1cc2d004 100644 --- a/tests/unit/print-doc-to-string.js +++ b/tests/unit/print-doc-to-string.js @@ -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"); }); diff --git a/website/playground/codeSamples.mjs b/website/playground/codeSamples.mjs index 3767486d7..0387c7401 100644 --- a/website/playground/codeSamples.mjs +++ b/website/playground/codeSamples.mjs @@ -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: >",