diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 763ed1980..e0b349eaa 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -158,6 +158,7 @@ module.exports = { "unicorn/prefer-string-starts-ends-with": "error", "unicorn/prefer-switch": "error", "unicorn/prefer-type-error": "error", + "unicorn/template-indent": "error", }, overrides: [ { diff --git a/scripts/release/utils.js b/scripts/release/utils.js index 27910ab3a..3a47125db 100644 --- a/scripts/release/utils.js +++ b/scripts/release/utils.js @@ -103,9 +103,9 @@ function getBlogPostInfo(version) { function getChangelogContent({ version, previousVersion, body }) { return outdent` - [diff](https://github.com/prettier/prettier/compare/${previousVersion}...${version}) + [diff](https://github.com/prettier/prettier/compare/${previousVersion}...${version}) - ${body} + ${body} `; } diff --git a/tests/config/install-prettier.js b/tests/config/install-prettier.js index 48d95efac..a53427c9b 100644 --- a/tests/config/install-prettier.js +++ b/tests/config/install-prettier.js @@ -1,5 +1,6 @@ import path from "node:path"; import fs from "node:fs"; +import { outdent } from "outdent"; import { execaSync } from "execa"; import tempy from "tempy"; import chalk from "chalk"; @@ -71,12 +72,12 @@ function installPrettier(packageDir) { const installed = path.join(tmpDir, "node_modules/prettier"); console.log( chalk.green( + outdent` + Prettier installed + at ${chalk.inverse(installed)} + from ${chalk.inverse(packageDir)} + with ${chalk.inverse(client)}. ` -Prettier installed - at ${chalk.inverse(installed)} - from ${chalk.inverse(packageDir)} - with ${chalk.inverse(client)}. - `.trim() ) ); diff --git a/tests/config/utils/check-parsers.js b/tests/config/utils/check-parsers.js index a950db5d4..f2e3065b5 100644 --- a/tests/config/utils/check-parsers.js +++ b/tests/config/utils/check-parsers.js @@ -164,13 +164,13 @@ const checkParser = ({ dirname, files }, parsers = []) => { suggestCategories.length === 0 ? "" : outdent` - Suggest move your tests to: - ${suggestCategories - .map((category) => `- ${path.join(TESTS_ROOT, category)}`) - .join("\n")} + Suggest move your tests to: + ${suggestCategories + .map((category) => `- ${path.join(TESTS_ROOT, category)}`) + .join("\n")} - Or config to allow use this parser in "${__filename}". - `; + Or config to allow use this parser in "${__filename}". + `; throw new Error( `Parser "${parser}" should not used in "${dirname}".${ diff --git a/tests/format/js/cursor/jsfmt.spec.js b/tests/format/js/cursor/jsfmt.spec.js index 825c72611..87728dff7 100644 --- a/tests/format/js/cursor/jsfmt.spec.js +++ b/tests/format/js/cursor/jsfmt.spec.js @@ -1,3 +1,5 @@ + +import { outdent } from "outdent"; // TODO: Use this when we drop support for Node.js 12 // import prettier from "../../../config/prettier-entry.js"; const { prettier } = run_spec; @@ -34,17 +36,22 @@ test("keeps cursor inside formatted node", () => { }); test("doesn't insert second placeholder for nonexistent TypeAnnotation", () => { - const code = ` -foo('bar', cb => { - console.log('stuff') -})`; + const code = + "\n" + + outdent` + foo('bar', cb => { + console.log('stuff') + }) + `; expect( prettier.formatWithCursor(code, { parser: "babel", cursorOffset: 24 }) ).toMatchObject({ - formatted: `foo("bar", (cb) => { - console.log("stuff"); -}); -`, + formatted: + outdent` + foo("bar", (cb) => { + console.log("stuff"); + }); + ` + "\n", cursorOffset: 25, }); }); diff --git a/tests/integration/__tests__/__snapshots__/format.js.snap b/tests/integration/__tests__/__snapshots__/format.js.snap index b4365a670..40cafac78 100644 --- a/tests/integration/__tests__/__snapshots__/format.js.snap +++ b/tests/integration/__tests__/__snapshots__/format.js.snap @@ -12,12 +12,11 @@ exports[`html parser should handle CRLF correctly 1`] = `"\\"