From 3771e9c53d4f172c42b9f4452e489fc19d85067c Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Tue, 14 Jun 2022 14:21:26 +0800 Subject: [PATCH 01/14] Skip steps --- scripts/release/release.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/release/release.js b/scripts/release/release.js index eef364088d49..6b3261badf58 100644 --- a/scripts/release/release.js +++ b/scripts/release/release.js @@ -40,11 +40,11 @@ async function run() { "./steps/validate-new-version.js", "./steps/check-git-status.js", // "./steps/install-dependencies.js",s - params.manual && "./steps/run-tests.js", - "./steps/update-version.js", - params.manual && "./steps/generate-bundles.js", - "./steps/update-changelog.js", - "./steps/push-to-git.js", + // params.manual && "./steps/run-tests.js", + // "./steps/update-version.js", + // params.manual && "./steps/generate-bundles.js", + // "./steps/update-changelog.js", + // "./steps/push-to-git.js", params.manual ? "./steps/publish-to-npm.js" : "./steps/wait-for-bot-release.js", From 0fe554c2b05aa75dfdbb1cc275bc75c0315155bc Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Tue, 14 Jun 2022 14:23:34 +0800 Subject: [PATCH 02/14] Add one more step --- scripts/release/steps/wait-for-bot-release.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/release/steps/wait-for-bot-release.js b/scripts/release/steps/wait-for-bot-release.js index c17a97338bd1..dfcbd64bd74e 100644 --- a/scripts/release/steps/wait-for-bot-release.js +++ b/scripts/release/steps/wait-for-bot-release.js @@ -49,6 +49,17 @@ export default async function waitForBotRelease({ dry, version }) { await waitForEnter(); } + console.log( + outdentString(chalk/* indent */ ` + 1. Go to {green.underline https://www.npmjs.com/package/prettier/access} + 2. Make sure "{yellow Publishing access}" section is set to "{yellow Require two-factor authentication or automation tokens}". + + Press ENTER to continue. + `) + ); + + await waitForEnter(); + console.log( outdentString(chalk/* indent */ ` 1. Go to {green.underline https://github.com/prettier/release-workflow/actions/workflows/release.yml} From f64c96c6f34805139b4bc5df168f7f90aa7a47ba Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Tue, 14 Jun 2022 14:23:50 +0800 Subject: [PATCH 03/14] Skip steps --- scripts/release/release.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release/release.js b/scripts/release/release.js index 6b3261badf58..b9eb598f02b7 100644 --- a/scripts/release/release.js +++ b/scripts/release/release.js @@ -37,8 +37,8 @@ async function run() { const steps = await Promise.all( [ - "./steps/validate-new-version.js", - "./steps/check-git-status.js", + // "./steps/validate-new-version.js", + // "./steps/check-git-status.js", // "./steps/install-dependencies.js",s // params.manual && "./steps/run-tests.js", // "./steps/update-version.js", From 934068ac6a6b2f79745d829830af8b36cd7a2539 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Tue, 14 Jun 2022 15:25:40 +0900 Subject: [PATCH 04/14] Add 2.7 blog post (#12966) Co-authored-by: fisker Cheung --- changelog_unreleased/blog-post-intro.md | 11 + changelog_unreleased/cli/12603.md | 2 +- changelog_unreleased/cli/12800.md | 2 +- changelog_unreleased/html/12882.md | 2 +- changelog_unreleased/javascript/12860.md | 2 +- changelog_unreleased/typescript/12896.md | 7 +- website/blog/2022-06-14-2.7.0.md | 529 +++++++++++++++++++++++ 7 files changed, 549 insertions(+), 6 deletions(-) create mode 100644 changelog_unreleased/blog-post-intro.md create mode 100644 website/blog/2022-06-14-2.7.0.md diff --git a/changelog_unreleased/blog-post-intro.md b/changelog_unreleased/blog-post-intro.md new file mode 100644 index 000000000000..147fed673304 --- /dev/null +++ b/changelog_unreleased/blog-post-intro.md @@ -0,0 +1,11 @@ +--- +author: "Sosuke Suzuki (@sosukesuzuki)" +authorURL: "https://github.com/sosukesuzuki" +title: "Prettier 2.7: new --cache CLI option and TypeScript 4.7 syntax!" +--- + +This release includes a new `--cache` CLI option. Enabling this option will use some attributes as cache keys and format files only if they have changed. This could dramatically improve CLI performance. + +We've also added support formatting for TypeScript 4.7 syntax! + +If you enjoy Prettier and would like to support our work, consider sponsoring us directly via [our OpenCollective](https://opencollective.com/prettier) or by sponsoring the projects we depend on, including [typescript-eslint](https://opencollective.com/typescript-eslint), [remark](https://opencollective.com/unified), and [Babel](https://opencollective.com/babel). diff --git a/changelog_unreleased/cli/12603.md b/changelog_unreleased/cli/12603.md index 4316858da8c8..620bd914534e 100644 --- a/changelog_unreleased/cli/12603.md +++ b/changelog_unreleased/cli/12603.md @@ -1,3 +1,3 @@ #### Infer parser for `.importmap` files (#12603 by @fisker) -Format [`.importmap`](https://github.com/WICG/import-maps#import-map-processing) files as a JSON files. +Format [`.importmap`](https://github.com/WICG/import-maps#import-map-processing) files as JSON files. diff --git a/changelog_unreleased/cli/12800.md b/changelog_unreleased/cli/12800.md index 7a8900582ab1..7daee1b3f3f4 100644 --- a/changelog_unreleased/cli/12800.md +++ b/changelog_unreleased/cli/12800.md @@ -1,4 +1,4 @@ -#### [HIGHLIGHT]Add `--cache` and `--cache-strategy` CLI option (#12800 by @sosukesuzuki) +#### [HIGHLIGHT]Add `--cache` and `--cache-strategy` CLI options (#12800 by @sosukesuzuki) Two new CLI options have been added for a caching system similar to [ESLint's one](https://eslint.org/docs/user-guide/command-line-interface#caching). diff --git a/changelog_unreleased/html/12882.md b/changelog_unreleased/html/12882.md index 3e94364b671d..a807545c21aa 100644 --- a/changelog_unreleased/html/12882.md +++ b/changelog_unreleased/html/12882.md @@ -1,6 +1,6 @@ #### Support Speculation Rules API formatting in HTML (#12882 by @sosukesuzuki) -Please read https://web.dev/speculative-prerendering/ for about Speculation Rules API. +Please read https://web.dev/speculative-prerendering/ for more information about the Speculation Rules API. ```html diff --git a/changelog_unreleased/javascript/12860.md b/changelog_unreleased/javascript/12860.md index 22497b9e04e6..df7151a4c8eb 100644 --- a/changelog_unreleased/javascript/12860.md +++ b/changelog_unreleased/javascript/12860.md @@ -1,6 +1,6 @@ #### Fix comment formats in (#12860 by @HosokawaR) -This change fixes comments format in `exports` to algin with the comment format in `import` +This change fixes the comment format in `exports` to align with the comment format in `import`. Although this change does not affect the comments format in `import`, follows change log contains examples of comments in `import` for reference. diff --git a/changelog_unreleased/typescript/12896.md b/changelog_unreleased/typescript/12896.md index 0a3d95ee64b3..91a7986f0789 100644 --- a/changelog_unreleased/typescript/12896.md +++ b/changelog_unreleased/typescript/12896.md @@ -4,6 +4,7 @@ Support [TypeScript 4.7](https://devblogs.microsoft.com/typescript/announcing-ty ##### [Instantiation Expressions](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#instantiation-expressions) + ```ts interface Box { value: T; @@ -15,8 +16,9 @@ const makeHammerBox = makeBox; const makeWrenchBox = makeBox; ``` -##### [Optional Variance](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#optional-variance-annotations-for-type-parameters) +##### [Optional Variance Annotations](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#optional-variance-annotations-for-type-parameters) + ```ts interface Animal { animalStuff: any; @@ -30,8 +32,9 @@ type Setter = (value: T) => void; ##### [`extends` constraints for `infer`](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#extends-constraints-on-infer-type-variables) + ```ts -type FirstString = T extends [infer extends string, ...unknown[]] +type FirstString = T extends [infer S extends string, ...unknown[]] ? S : never; ``` diff --git a/website/blog/2022-06-14-2.7.0.md b/website/blog/2022-06-14-2.7.0.md new file mode 100644 index 000000000000..12b2829646f9 --- /dev/null +++ b/website/blog/2022-06-14-2.7.0.md @@ -0,0 +1,529 @@ +--- +author: "Sosuke Suzuki (@sosukesuzuki)" +authorURL: "https://github.com/sosukesuzuki" +title: "Prettier 2.7: new --cache CLI option and TypeScript 4.7 syntax!" +--- + +This release includes a new `--cache` CLI option. Enabling this option will use some attributes as cache keys and format files only if they have changed. This could dramatically improve CLI performance. + +We've also added support formatting for TypeScript 4.7 syntax! + +If you enjoy Prettier and would like to support our work, consider sponsoring us directly via [our OpenCollective](https://opencollective.com/prettier) or by sponsoring the projects we depend on, including [typescript-eslint](https://opencollective.com/typescript-eslint), [remark](https://opencollective.com/unified), and [Babel](https://opencollective.com/babel). + +## Highlights + +### TypeScript + +#### Support TypeScript 4.7 ([#12896](https://github.com/prettier/prettier/pull/12896), [#12897](https://github.com/prettier/prettier/pull/12897), [#12898](https://github.com/prettier/prettier/pull/12898), [#12900](https://github.com/prettier/prettier/pull/12900), [#12921](https://github.com/prettier/prettier/pull/12921), [#12924](https://github.com/prettier/prettier/pull/12924), [#12959](https://github.com/prettier/prettier/pull/12959) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + +Support [TypeScript 4.7](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7) new features! + +##### [Instantiation Expressions](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#instantiation-expressions) + + +```ts +interface Box { + value: T; +} +function makeBox(value: T) { + return { value }; +} +const makeHammerBox = makeBox; +const makeWrenchBox = makeBox; +``` + +##### [Optional Variance Annotations](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#optional-variance-annotations-for-type-parameters) + + +```ts +interface Animal { + animalStuff: any; +} +interface Dog extends Animal { + dogStuff: any; +} +type Getter = () => T; +type Setter = (value: T) => void; +``` + +##### [`extends` constraints for `infer`](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#extends-constraints-on-infer-type-variables) + + +```ts +type FirstString = T extends [infer S extends string, ...unknown[]] + ? S + : never; +``` + +### CLI + +#### Add `--cache` and `--cache-strategy` CLI options ([#12800](https://github.com/prettier/prettier/pull/12800) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + +Two new CLI options have been added for a caching system similar to [ESLint's one](https://eslint.org/docs/user-guide/command-line-interface#caching). + +Please see [the doc](https://prettier.io/docs/en/cli.html#--cache) for more details. + +##### `--cache` + +If this option is enabled, the following values are used as cache keys and the file is formatted only if one of them is changed. + +- Prettier version +- Options +- Node.js version +- (if `--cache-strategy` is `content`) content of the file +- (if `--cache-strategy` is `metadata`) file metadata, such as timestamps + +```bash +prettier --write --cache src +``` + +##### `--cache-strategy` + +Strategy for the cache to use for detecting changed files. Can be either `metadata` or `content`. If no strategy is specified, `content` will be used. + +```bash +prettier --write --cache --cache-strategy metadata src +``` + +## Other Changes + +### JavaScript + +#### Preserve blank line between export specifiers ([#12746](https://github.com/prettier/prettier/pull/12746) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + + +```jsx +// Input +export { + // a + foo1, + + // b + bar1, + baz1, +} from "mod"; + +// Prettier 2.6 +export { + // a + foo1, + // b + bar1, + baz1, +} from "mod"; + +// Prettier 2.7 +export { + // a + foo1, + + // b + bar1, + baz1, +} from "mod"; +``` + +#### Make more callee patterns recognized as "test call callee". ([#12779](https://github.com/prettier/prettier/pull/12779) by [@HosokawaR](https://github.com/HosokawaR)) + +Supports test calls like [Playwright `test.describe`](https://playwright.dev/docs/api/class-test#test-describe). + + +```jsx +// Input +test.step("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe.only("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe.parallel("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe.parallel.only("does something really long and complicated so I have to write a very long name for the testThis is a very", () => {}); + +test.describe.serial("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe.serial.only("does something really long and complicated so I have to write a very long name for the test", () => {}); + +// Prettier 2.6 +test.step( + "does something really long and complicated so I have to write a very long name for the test", + () => {} +); + +test.describe( + "does something really long and complicated so I have to write a very long name for the test", + () => {} +); + +test.describe.only( + "does something really long and complicated so I have to write a very long name for the test", + () => {} +); + +test.describe.parallel( + "does something really long and complicated so I have to write a very long name for the test", + () => {} +); + +test.describe.parallel.only( + "does something really long and complicated so I have to write a very long name for the testThis is a very", + () => {} +); + +test.describe.serial( + "does something really long and complicated so I have to write a very long name for the test", + () => {} +); + +test.describe.serial.only( + "does something really long and complicated so I have to write a very long name for the test", + () => {} +); + +// Prettier 2.7 +test.step("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe + .only("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe + .parallel("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe.parallel + .only("does something really long and complicated so I have to write a very long name for the testThis is a very", () => {}); + +test.describe + .serial("does something really long and complicated so I have to write a very long name for the test", () => {}); + +test.describe.serial + .only("does something really long and complicated so I have to write a very long name for the test", () => {}); +``` + +#### Fix comment formats in ([#12860](https://github.com/prettier/prettier/pull/12860) by [@HosokawaR](https://github.com/HosokawaR)) + +This change fixes the comment format in `exports` to align with the comment format in `import`. + +Although this change does not affect the comments format in `import`, follows change log contains examples of comments in `import` for reference. + + +```jsx +// Input +export { + foo, + + bar as // comment + baz, +} + +import { + foo, + + bar as // comment + baz, +} from 'foo' + +// Prettier 2.6 +export { + foo, + bar as baz, // comment +}; + +import { + foo, + // comment + bar as baz, +} from "foo"; + +// Prettier 2.7 +export { + foo, + // comment + bar as baz, +}; + +import { + foo, + // comment + bar as baz, +} from "foo"; + +``` + +### TypeScript + +#### Print `as` instead of `:` for `babel-ts` parser ([#12706](https://github.com/prettier/prettier/pull/12706) by [@HosokawaR](https://github.com/HosokawaR)) + + +```tsx +// Input +[x as any] = x; + +// Prettier 2.6 +[x: any] = x; + +// Prettier 2.7 +[x as any] = x; +``` + +#### Fix formatting for typescript Enum with computed members ([#12930](https://github.com/prettier/prettier/pull/12930) by [@HosokawaR](https://github.com/HosokawaR)) + + +```tsx +// Input +enum A { + [i++], +} + +// Prettier 2.6 +enum A { + i++, +} + +// Prettier 2.7 +enum A { + [i++], +} +``` + +#### Stop parsing invalid code ([#12982](https://github.com/prettier/prettier/pull/12982) by [@fisker](https://github.com/fisker)) + + +```tsx +// Input +const object = ({ methodName() }); + +// Prettier 2.6 +const object = { methodName(); }; + +// Prettier 2.7 +SyntaxError: Unexpected token. (1:29) +> 1 | const object = ({ methodName() }); + | ^^ +``` + +### HTML + +#### Support Speculation Rules API formatting in HTML ([#12882](https://github.com/prettier/prettier/pull/12882) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + +Please read https://web.dev/speculative-prerendering/ for more information about the Speculation Rules API. + + +```html + + + + + + + + + +``` + +### Vue + +#### Allow formatting for Vue template expression written in TypeScript ([#12584](https://github.com/prettier/prettier/pull/12584) by [@sosukesuzuki](https://github.com/sosukesuzuki)) + + +```vue + + + + + + + + + + + + + + +``` + +#### Infer Stylus parser for Vue SFC style block ([#12707](https://github.com/prettier/prettier/pull/12707) by [@lsdsjy](https://github.com/lsdsjy)) + +`