diff --git a/.eslintrc.js b/.eslintrc.js index 45ea5747375b..3cd5adc216a7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -153,6 +153,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 27910ab3a993..3a47125db046 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 2f62f50c9402..eb6dbd45bdb8 100644 --- a/tests/config/install-prettier.js +++ b/tests/config/install-prettier.js @@ -2,6 +2,7 @@ const path = require("path"); const fs = require("fs"); +const { outdent } = require("outdent"); const { default: chalk } = require("../../vendors/chalk.js"); const { default: tempy } = require("../../vendors/tempy.js"); const { execaSync } = require("../../vendors/execa.js"); @@ -74,12 +75,12 @@ module.exports = (packageDir) => { 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 8234ebe10c4e..a0d88f02aa07 100644 --- a/tests/config/utils/check-parsers.js +++ b/tests/config/utils/check-parsers.js @@ -163,13 +163,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 8418284279de..499d7e225cc7 100644 --- a/tests/format/js/cursor/jsfmt.spec.js +++ b/tests/format/js/cursor/jsfmt.spec.js @@ -1,6 +1,7 @@ run_spec(__dirname, ["babel", "typescript", "flow"]); const prettier = require("prettier-local"); +const { outdent } = require("outdent"); test("translates cursor correctly in basic case", () => { expect( @@ -32,17 +33,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 b4365a670c3b..40cafac78aed 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`] = `"\\"