From 33cc92daadc089731fae7ab5dab756359e1d62ca Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Wed, 21 Apr 2021 02:05:22 +0300 Subject: [PATCH] Address more feedback in changelog entries --- changelog_unreleased/handlebars/10290.md | 11 +++++++++-- changelog_unreleased/javascript/10335.md | 10 +++++++--- changelog_unreleased/javascript/9704.md | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/changelog_unreleased/handlebars/10290.md b/changelog_unreleased/handlebars/10290.md index 2d99316ef..cf7ea6442 100644 --- a/changelog_unreleased/handlebars/10290.md +++ b/changelog_unreleased/handlebars/10290.md @@ -2,15 +2,22 @@ This started in 2017. Handlebars support has been in Prettier for a while, but it wasn’t released officially as it wasn’t really ready. Its status went from “alpha” to “experimental” to “beta” and then, if you checked older release notes, you can see that after “beta” somehow it was “alpha” again… -Well, anyway, it finally is happening: Prettier can now officially format Handlebars files! 🎉 +Well, anyway, it finally is happening: Prettier can now officially format HTML templates with Handlebars! 🎉 It uses [Glimmer], [Ember]’s Handlebars parser, so it should be compliant with the HTML spec thanks to the Ember team. The [`--html-whitespace-sensitivity`][hws-option] option is supported and defaults to `strict`, which means that Prettier will always respect the presence or absence of whitespace around tags and consider it unsafe to add whitespace where there were none and vice versa as this can affect how the document is rendered in the browser. The `css` value is not yet supported (treated as `strict` for now). -The feature is called “Ember / Handlebars” and not just “Handlebars” because Glimmer doesn’t support some syntax and use cases of Handlebars. This is mostly due to the fact that [Handlebars], being a template engine (a preprocessor), doesn’t care about the underlying syntax of the content it processes whereas Glimmer parses two syntaxes – HTML and Handlebars – at the same time and combines the result into a single tree, which Prettier can print. This means Prettier won’t format Handlebars files that can’t be parsed into such a tree, either because the underlying syntax isn’t HTML or because template directives and tags overlap in a way that can’t be represented in a tree (e.g., `{{#if foo}}
{{/if}`). Even with these restrictions, the formatter still seems to be useful enough to non-Ember Handlebars users. +The feature is called “Ember / Handlebars” and not just “Handlebars” because Glimmer doesn’t support some syntax and use cases of Handlebars. This is mostly due to the fact that [Handlebars], being a template engine (a preprocessor), doesn’t care about the underlying syntax of the content it processes whereas Glimmer parses two syntaxes – HTML and Handlebars – at the same time and combines the result into a single tree, which Prettier can print. This means Prettier won’t format Handlebars files that can’t be parsed into such a tree, either because the underlying syntax isn’t HTML or because template directives and tags overlap in a way that can’t be represented in a tree (e.g., `{{#if foo}}
{{/if}`). Even with these restrictions, the formatter still seems to be useful enough to non-Ember Handlebars users. As for the syntax unsupported by Ember, there is a good chance to see support for it in future versions of Prettier as Glimmer uses a full-fledged Handlebars parser under the hood. + +Files with the extensions `.hbs` and `.handlebars` are recognized as Handlebars by default. For other extensions, the [`--parser`](parser-option) option with the value `glimmer` has to be specified – for example, using command line or, better yet, [configuration overrides]. + +See the formatter in action on the [playground][playground-glimmer]! [glimmer]: https://www.npmjs.com/package/@glimmer/syntax [ember]: https://emberjs.com [hws-option]: https://prettier.io/docs/en/options.html#html-whitespace-sensitivity [handlebars]: https://handlebarsjs.com/ +[parser-option]: https://prettier.io/docs/en/options.html#parser +[configuration overrides]: https://prettier.io/docs/en/configuration.html#configuration-overrides +[playground-glimmer]: https://prettier.io/playground/#N4Igxg9gdgLgprEAuEACVAeAJgSwG7qFgA2AhgM7kC8AOiAjAE4CedhqAfDVOhgBYBGDsGDoYOGMTjsAvjIwB6QVx6ZcBdCQrU6AIwhZWIFe1OERhfYbOE53Reo6YFjkABoQEAA7jo5ZKCkjIwQAO4ACkEI-iikxKGkzP4euoykYADWcDAAyl7pOFAA5shMAK5wHnAAtrpwWFj1ADKkxWWkRXAAYhCM1aQw4sXIIKRlMBDuIHww1cQA6nwScOT5YHA50RL4Eswj5Ew4YDBTheRwjDDhaUX9yABmceceAFbkAB4AQmmZ2Tmk1TgTUKcAeT0qIDe7xyhSKUgAimUIPAwcRniB8oxzowRnCcNVATiPF5GIUYPMcFgYHxkAAOAAMxJC53maS8IxJKwueFBHgAjkj4NdvDFRuQALRQOD1epTRhwAU4eXXDp3JCPNEQ87VHClRgVDzkWEIwWg9XgjwwUi6ClUmlIABMlrSOGIsIAwhACaQRisAKxTMrnAAq1piGvReAqAEkoI1YDkwKSfABBOM5GDMKSo85yIA diff --git a/changelog_unreleased/javascript/10335.md b/changelog_unreleased/javascript/10335.md index 3301e0f3b..0a0a09c11 100644 --- a/changelog_unreleased/javascript/10335.md +++ b/changelog_unreleased/javascript/10335.md @@ -1,17 +1,21 @@ #### [HIGHLIGHT] Prevent wrapping object properties with short keys (#10335 by @thorn0) -Line breaks after short property names in object literals often look unnatural. Even when such a line break yields a line length benefit of 1 or 2 characters, it rarely looks justified. Prettier main avoids line breaks after property names shorter than `tabWidth + 3`. The "+3" part has been chosen rather arbitrarily. It may be revised upward in future versions, provided there is a really good rationale. +Line breaks after short property names in object literals often look unnatural. Even when such a line break yields a line length benefit of 1 or 2 characters, it rarely looks justified. Prettier main avoids line breaks after property names shorter than `tabWidth + 3` – for example, 5 characters in the default configuration, or 7 characters with `tabWidth: 4`. This heuristic may be revised in future versions. ```js // Prettier stable const importantLink = { url: - "https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about" + "https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about", + gitHubUrl: + "https://github.com/prettier/prettier/blob/main/docs/rationale.md#what-prettier-is-concerned-about", }; // Prettier main const importantLink = { - url: "https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about" + url: "https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about", + gitHubUrl: + "https://github.com/prettier/prettier/blob/main/docs/rationale.md#what-prettier-is-concerned-about", }; ``` diff --git a/changelog_unreleased/javascript/9704.md b/changelog_unreleased/javascript/9704.md index ae4091822..e6963df2a 100644 --- a/changelog_unreleased/javascript/9704.md +++ b/changelog_unreleased/javascript/9704.md @@ -1,6 +1,6 @@ #### Don’t format nodes that end just before `rangeStart` (#9704 by @fisker) -Previously, such nodes were considered part of the range, now they're excluded. This affects other languages that the range formatting feature supports, not only JavaScript. +Previously, when [range formatting](https://prettier.io/docs/en/options.html#range) was performed, such nodes were considered part of the range, now they're excluded. This affects other languages that the range formatting feature supports, not only JavaScript. ```js