diff --git a/changelog_unreleased/api/10122.md b/changelog_unreleased/api/10122.md deleted file mode 100644 index 5d228bbb6..000000000 --- a/changelog_unreleased/api/10122.md +++ /dev/null @@ -1,34 +0,0 @@ -#### Fix `lineSuffixBoundary` IR command (#10122 by @thorn0) - -There was a bug in the implementation of the [`lineSuffixBoundary`][lsb] command that significantly limited its usefulness: the printer algorithm didn't correctly consider it a potential line break. Now that the bug has been fixed, we urge plugin authors to give this command another try and see if it can help them simplify printing of trailing comments. - -[lsb]: https://github.com/prettier/prettier/blob/main/commands.md#linesuffixboundary - - -```jsx -// Input -group([ - "let foo = [", - indent([ - softline, - [lineSuffixBoundary, "item1,"], - line, - [lineSuffixBoundary, "item2,", lineSuffix(" // comment")], - line, - [lineSuffixBoundary, "item3"], - ]), - softline, - "];", -]) - -// Prettier stable -let foo = [item1, item2, // comment - item3]; - -// Prettier main -let foo = [ - item1, - item2, // comment - item3 -]; -``` diff --git a/changelog_unreleased/api/10221.md b/changelog_unreleased/api/10221.md deleted file mode 100644 index 5e4fecb18..000000000 --- a/changelog_unreleased/api/10221.md +++ /dev/null @@ -1,3 +0,0 @@ -#### Add `indentIfBreak` IR command (#10221 by @thorn) - -`indentIfBreak(doc, { groupId })` is an optimized version of `ifBreak(indent(doc), doc, { groupId })`. diff --git a/changelog_unreleased/api/10557.md b/changelog_unreleased/api/10557.md deleted file mode 100644 index 2716b3e9f..000000000 --- a/changelog_unreleased/api/10557.md +++ /dev/null @@ -1,37 +0,0 @@ -#### Simplified `print` callback (#10557 by @fisker) - -The third argument of the `print` method of plugin printers (the `print` callback) has been updated. Its first argument can be a string or an array of strings now. - -To print the current node, call `print` without arguments: - -```diff - function print(path, options, print) { - const parts = []; - path.each((childPath) => { -- parts.push(print(childPath)); -+ parts.push(print()); - }, "children"); - return parts; - } -``` - -To print a property of the current node, use `"property"` or `["property"]`: - -```diff - function print(path, options, print) { -- return path.call(print, "property"); -+ return print("property"); - } -``` - -To print a sub-property of the current node, use `["property1", "property2"]`: - -```diff - function print(path, options, print) { - // print `node.child.child` -- return path.call(print, "child", "child"); -+ return print(["child", "child"]); - } -``` - -See also an example in the [docs](https://prettier.io/docs/en/plugins.html#print). diff --git a/changelog_unreleased/api/8105.md b/changelog_unreleased/api/8105.md deleted file mode 100644 index 6cb237df7..000000000 --- a/changelog_unreleased/api/8105.md +++ /dev/null @@ -1,3 +0,0 @@ -#### Treat `.prettierrc` as YAML when formatting it (#8105 by @fisker) - -The `.prettierrc` file can be written in either JSON or YAML. Previously, when Prettier formatted it, the parser was inferred to be `json`, which lead to a `SyntaxError` thrown if the content was YAML. Now it’s treated as a YAML file. However, if it's JSON, it will be formatted as JSON (not as JSON-like YAML). diff --git a/changelog_unreleased/api/9733.md b/changelog_unreleased/api/9733.md deleted file mode 100644 index 4def4af71..000000000 --- a/changelog_unreleased/api/9733.md +++ /dev/null @@ -1,15 +0,0 @@ -#### Use arrays instead of `concat` (#9733 by @fisker, @thorn0) - -To simplify the code of AST printers, the data structure for the concatenation command has been changed from `{ type: 'concat', parts: Doc[] }` to `Doc[]`. The old format is deprecated, but for compatibility, the doc printer still supports it, and `doc.builders.concat` (as well as some other builder functions) will keep using it until the next major version of Prettier. - -If you're a plugin author, this change should only concern you if your plugin introspects or modifies composed docs. If it happens to be the case, please make your plugin compatible with future versions of Prettier by tweaking the introspecting code to support the new format. There also is an off-chance where this change can break things, namely if a plugin calls another plugin to [print an embedded language](https://prettier.io/docs/en/plugins.html#optional-embed) and then introspects the returned doc. There seems to be no reason for plugins to do that though. - -To replace `concat(…)` calls in your plugins, you can try auto-fix by this ESLint rule [`prettier-doc/no-concat`](https://github.com/fisker/eslint-plugin-prettier-doc#no-concat). - -```jsx -// Prettier stable -myDoc = group(concat(["foo", line, "bar"])); - -// Prettier main -myDoc = group(["foo", line, "bar"]); -``` diff --git a/changelog_unreleased/blog-post-intro.md b/changelog_unreleased/blog-post-intro.md deleted file mode 100644 index 9e05defa8..000000000 --- a/changelog_unreleased/blog-post-intro.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -author: "Georgii Dolzhykov (@thorn0)" -authorURL: "https://github.com/thorn0" -title: "Prettier 2.3. In which assignments are consistent, short keys non-breaking, and Handlebars official" ---- - -This release focuses on fixing long-standing issues in the JavaScript printer. Be warned that, unfortunately, reformatting a project with the new version might result in quite a big diff. If you don’t use [`ignoreRevsFile`](https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revltrevgt) to hide such wholesale changes from `git blame`, it might be about time. - -A remarkable milestone is the long-awaited release of the Ember / Handlebars formatter. It’s supposed to be the last formatter included directly in the core library. In the future, for sustainability, languages should be added only by plugins. - -We are grateful to our financial contributors: [Salesforce](https://engineering.salesforce.com/foss-fund-brings-more-than-just-financial-contributions-7b0664067b1e), [Indeed](https://engineering.indeedblog.com/blog/2019/07/foss-fund-six-months-in/), [Frontend Masters](https://blog.opencollective.com/frontend-masters/), Airbnb, Shogun Labs, Skyscanner, Konstantin Pschera, and [many others](https://opencollective.com/prettier#section-contributors) who help us keep going. If you enjoy Prettier and would like to support our work, head to our [OpenCollective](https://opencollective.com/prettier). Please consider also supporting the projects Prettier depends on, such as [typescript-eslint](https://opencollective.com/typescript-eslint), [remark](https://opencollective.com/unified), and [Babel](https://opencollective.com/babel). - -Most of the changes in this release are thanks to the hard work of [Fisker Cheung](https://github.com/fisker), [Georgii Dolzhykov](https://github.com/thorn0), and [Sosuke Suzuki](https://github.com/sosukesuzuki), along with many other contributors. - -And just a reminder, when Prettier is installed or updated, it’s [strongly recommended](https://prettier.io/docs/en/install.html#summary) to specify the exact version in `package.json`: `"2.3.0"`, not `"^2.3.0"`. diff --git a/changelog_unreleased/cli/10058.md b/changelog_unreleased/cli/10058.md deleted file mode 100644 index 05dd3b6a1..000000000 --- a/changelog_unreleased/cli/10058.md +++ /dev/null @@ -1,16 +0,0 @@ -#### Add CLI option to prevent errors on unmatched pattern (#10058 by @daronmcintosh) - -The Prettier CLI will no longer display an error when no files match the glob pattern passed as input. - -```sh -# Prettier stable -$ npx prettier --check "prettier/docs/*.yaml" -Checking formatting... -[error] No files matching the pattern were found: "prettier/docs/*.yaml". -All matched files use Prettier code style! - -# Prettier main -$ npx prettier --check --no-error-on-unmatched-pattern "prettier/docs/*.yaml" -Checking formatting... -All matched files use Prettier code style! -``` diff --git a/changelog_unreleased/cli/10124.md b/changelog_unreleased/cli/10124.md deleted file mode 100644 index 0c3f204e6..000000000 --- a/changelog_unreleased/cli/10124.md +++ /dev/null @@ -1,3 +0,0 @@ -#### Add CLI flag for debugging comment attachment issues (#10124 by @thorn0) - -A new `--debug-print-comments` CLI flag and corresponding functionality for the Playground. diff --git a/changelog_unreleased/cli/10169.md b/changelog_unreleased/cli/10169.md deleted file mode 100644 index 7a0b6249a..000000000 --- a/changelog_unreleased/cli/10169.md +++ /dev/null @@ -1,3 +0,0 @@ -#### Round-trippable `--debug-print-doc` (#10169, #10177 by @thorn0) - -The idea is to make the output of `--debug-print-doc` closer to actual code for generating docs (Prettier's intermediate representation). Ideally, it should be possible for it to work without modification after copy-pasting into a JS file. That ideal hasn't probably been reached by this PR, but it's pretty close. This is going to make `--debug-print-doc` and the corresponding part of the Playground a bit more useful. diff --git a/changelog_unreleased/cli/10208.md b/changelog_unreleased/cli/10208.md deleted file mode 100644 index c8dac1692..000000000 --- a/changelog_unreleased/cli/10208.md +++ /dev/null @@ -1,11 +0,0 @@ -#### Print an error message when `--find-config-path` can't find config file (#10208 by @fisker) - -```console -# Prettier stable -$ prettier --find-config-path /prettier.js -# Silently failed - -# Prettier main -$ prettier --find-config-path /prettier.js -[error] Can not find configure file for "/prettier.js" -``` diff --git a/changelog_unreleased/cli/10217.md b/changelog_unreleased/cli/10217.md deleted file mode 100644 index e260bfc72..000000000 --- a/changelog_unreleased/cli/10217.md +++ /dev/null @@ -1,17 +0,0 @@ -#### Clear printed long filenames of formatting file (#10217 by @fisker) - - -```console -# Prettier stable -$ prettier tests/flow-repo/config_module_system_node_resolve_dirname --check -Checking formatting... -tests\flow-repo\config_module_system_node_resolve_dirname\custom_resolve_dir\tes -tests\flow-repo\config_module_system_node_resolve_dirname\custom_resolve_dir\tes -tests\flow-repo\config_module_system_node_resolve_dirname\subdir\custom_resolve_ -All matched files use Prettier code style! - -# Prettier main -$ prettier tests/flow-repo/config_module_system_node_resolve_dirname --check -Checking formatting... -All matched files use Prettier code style! -``` diff --git a/changelog_unreleased/cli/10256.md b/changelog_unreleased/cli/10256.md deleted file mode 100644 index 1ac6e1126..000000000 --- a/changelog_unreleased/cli/10256.md +++ /dev/null @@ -1,14 +0,0 @@ -#### Don't skip file paths containing special words like `constructor` (#10256 by @ashlkv) - -Directories whose names happened to coincide with the properties of `Object.prototype` were ignored by Prettier CLI because of a classic bug (introduced in Prettier 2.0.0) with object properties not being checked for being own. - - -```sh -# Prettier stable -$ prettier 'js/constructor/*.js' --write -[error] No matching files. Patterns: js/constructor/*.js - -# Prettier main -prettier 'js/constructor/*.js' --write -js/constructor/test.js 42ms -``` diff --git a/changelog_unreleased/css/10773.md b/changelog_unreleased/css/10773.md deleted file mode 100644 index f08ed1ed7..000000000 --- a/changelog_unreleased/css/10773.md +++ /dev/null @@ -1,34 +0,0 @@ -#### Exclude `@keyframes` params from being parsed as a Less variable (#10773 by @tmazeika) - - -```css -/* Input */ -@keyframes :global(spin) { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -/* Prettier stable */ -@keyframes: global(spin){ - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -}; - -/* Prettier main */ -@keyframes :global(spin) { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} -``` diff --git a/changelog_unreleased/css/9966.md b/changelog_unreleased/css/9966.md deleted file mode 100644 index 9fc31c4ec..000000000 --- a/changelog_unreleased/css/9966.md +++ /dev/null @@ -1,15 +0,0 @@ -#### Fix absolute path in custom CSS `-custom-url()` calls (#9966 by @vjeux) - -The CSS parser is parsing this as `["division", "absolute/path"]` instead of a single `"/absolute/path"` token unless you are in a `url()` call. Because we put space after division, it results in an incorrect path. The fix was to avoid printing a space if a division is the first token of a call, which hopefully should be safe. - - -```css -/* Input */ --custom-url(/absolute/path) - -/* Prettier stable */ --custom-url(/ absolute/path) - -/* Prettier main */ --custom-url(/absolute/path) -``` diff --git a/changelog_unreleased/flow/10397.md b/changelog_unreleased/flow/10397.md deleted file mode 100644 index 3df2ddcc3..000000000 --- a/changelog_unreleased/flow/10397.md +++ /dev/null @@ -1,15 +0,0 @@ -#### Support `this` type annotation in functions via `babel-flow` (#10397 by @sosukesuzuki) - -`this` type annotation is supported since [Babel 7.13](https://babeljs.io/blog/2021/02/22/7.13.0#new-flow-features-12193httpsgithubcombabelbabelpull12193-12234httpsgithubcombabelbabelpull12234). - -```js -// Input -var foo: (this: boolean) => void; - -// Prettier stable -SyntaxError: Unexpected token, expected ")" (1:15) - -// Prettier main -var foo: (this: boolean) => void; - -``` diff --git a/changelog_unreleased/flow/10505.md b/changelog_unreleased/flow/10505.md deleted file mode 100644 index 3e1bd25d6..000000000 --- a/changelog_unreleased/flow/10505.md +++ /dev/null @@ -1,15 +0,0 @@ -#### Fix range formatting issues (#10505 by @thorn0) - -Prettier had trouble formatting some ranges in function declarations. `SyntaxError` was thrown. Prettier main formats these cases without errors. Examples of problematic ranges are shown below: - - -```jsx -declare export function graphql> - // ^^^^^ range 1 - (query: GQLDocument, config?: Config>): - (Component: Component) => React$ComponentType<$Diff, { - data: Object|void, - // ^^^^ range 2 - mutate: Function|void - }>> -``` diff --git a/changelog_unreleased/flow/10594.md b/changelog_unreleased/flow/10594.md deleted file mode 100644 index 83620ee1f..000000000 --- a/changelog_unreleased/flow/10594.md +++ /dev/null @@ -1,13 +0,0 @@ -#### Support for Flow's indexed access type (#10594 by @gkz) - - -```js -// Input -const x: Obj['foo'] = 1; - -// Prettier stable -// Error: unsupported node type "IndexedAccessType" - -// Prettier main -const x: Obj["foo"] = 1; -``` diff --git a/changelog_unreleased/flow/10788.md b/changelog_unreleased/flow/10788.md deleted file mode 100644 index 8972e86ca..000000000 --- a/changelog_unreleased/flow/10788.md +++ /dev/null @@ -1,13 +0,0 @@ -#### Support for Flow's optional indexed access type (#10788 by @gkz) - - -```js -// Input -type T = Obj?.['foo']; - -// Prettier stable -// Error: unsupported node type "OptionalIndexedAccessType" - -// Prettier main -type T = Obj?.['foo']; -``` diff --git a/changelog_unreleased/flow/9767.md b/changelog_unreleased/flow/9767.md deleted file mode 100644 index 72dcbc0ac..000000000 --- a/changelog_unreleased/flow/9767.md +++ /dev/null @@ -1,15 +0,0 @@ -#### Fix missing semicolon in `declare export * from …` (#9767 by @fisker) - - - - -```jsx -// Input -declare export * from "ES6_ExportAllFrom_Source2"; - -// Prettier stable -declare export * from "ES6_ExportAllFrom_Source2" - -// Prettier main -declare export * from "ES6_ExportAllFrom_Source2"; -``` diff --git a/changelog_unreleased/graphql/10689.md b/changelog_unreleased/graphql/10689.md deleted file mode 100644 index 3e0d7f7e9..000000000 --- a/changelog_unreleased/graphql/10689.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Fix missing space after keyword in anonymous operations (#10689 by @patriscus) - - -```graphql -# Input -query ($unnamed: String) { - id -} - -# Prettier stable -query($unnamed: String) { - id -} - -# Prettier main -query ($unnamed: String) { - id -} -``` diff --git a/changelog_unreleased/handlebars/10145.md b/changelog_unreleased/handlebars/10145.md deleted file mode 100644 index 851eaaaae..000000000 --- a/changelog_unreleased/handlebars/10145.md +++ /dev/null @@ -1,25 +0,0 @@ -#### Fix formatting of attributes (#10145 by @thorn0) - -- fix escaping of `{{` in attributes and text -- fix the choice between `'` and `"` for attributes with interpolations -- fix the bug with `[object Object]` printed in the `class` attribute -- implement simple formatting for the `class` attribute, like Prettier formatted it in HTML before v2.3.0 - - -```hbs -{{!-- Input --}} -
-
-
- -{{!-- Prettier stable --}} -
-
-
- -{{!-- Prettier main --}} -
-
-
-``` diff --git a/changelog_unreleased/handlebars/10179.md b/changelog_unreleased/handlebars/10179.md deleted file mode 100644 index ad2fb046b..000000000 --- a/changelog_unreleased/handlebars/10179.md +++ /dev/null @@ -1,20 +0,0 @@ -#### Split text content on multiple lines (#10179 by @dcyriller) - - -```handlebars -{{!-- Input --}} -
- A long enough string to trigger a line break that would prevent wrapping more and more. -
- -{{!-- Prettier stable --}} -
- A long enough string to trigger a line break that would prevent wrapping more and more. -
- -{{!-- Prettier main --}} -
- A long enough string to trigger a line break that would prevent wrapping more - and more. -
-``` diff --git a/changelog_unreleased/handlebars/10290.md b/changelog_unreleased/handlebars/10290.md deleted file mode 100644 index cf7ea6442..000000000 --- a/changelog_unreleased/handlebars/10290.md +++ /dev/null @@ -1,23 +0,0 @@ -#### [HIGHLIGHT] Move Handlebars support out of alpha to release (#10290 by @dcyriller & @thorn0) - -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 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. 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/handlebars/10550.md b/changelog_unreleased/handlebars/10550.md deleted file mode 100644 index 1d334f225..000000000 --- a/changelog_unreleased/handlebars/10550.md +++ /dev/null @@ -1,13 +0,0 @@ -#### Preserve numeric character references (#10550 by @rwjblue and @thorn0) - - -```hbs -{{! Input }} - - -{{! Prettier stable }} - - -{{! Prettier main }} - -``` diff --git a/changelog_unreleased/handlebars/10586.md b/changelog_unreleased/handlebars/10586.md deleted file mode 100644 index 90ecd1c18..000000000 --- a/changelog_unreleased/handlebars/10586.md +++ /dev/null @@ -1,40 +0,0 @@ -#### Do not break opening mustache and path (#10586 by @dcyriller) - - -```handlebars -{{!-- Input --}} - - - -{{!-- Prettier stable --}} - - - -{{!-- Prettier main --}} - - -``` diff --git a/changelog_unreleased/handlebars/9082.md b/changelog_unreleased/handlebars/9082.md deleted file mode 100644 index 00adb39d9..000000000 --- a/changelog_unreleased/handlebars/9082.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Preserve tilde comments (#9082 by @kangax, @fisker) - - -```hbs -{{!-- Input --}} -{{~! Comment }} -{{! Comment ~}} -{{~! Comment ~}} - -{{!-- Prettier stable --}} -{{! Comment }} -{{! Comment }} -{{! Comment }} - -{{!-- Prettier main --}} -{{~! Comment }} -{{! Comment ~}} -{{~! Comment ~}} -``` diff --git a/changelog_unreleased/handlebars/9885.md b/changelog_unreleased/handlebars/9885.md deleted file mode 100644 index 2fe1c4e9b..000000000 --- a/changelog_unreleased/handlebars/9885.md +++ /dev/null @@ -1,45 +0,0 @@ -#### Add a whitespace sensitive mode (#9885 by @dcyriller) - -```sh ---html-whitespace-sensitivity strict -``` - - -```hbs -{{!-- Input --}} -123 {{mustache}} - -123 {{mustache}} -123 {{mustache}} - - -123 {{mustache}} - - -{{!-- Prettier stable --}} - - 123 {{mustache}} - - - 123 {{mustache}} - - - 123 {{mustache}} - - - 123 {{mustache}} - - -{{!-- Prettier main --}} -123 {{mustache}} - - 123 - {{mustache}} -123 - {{mustache}} - - - 123 - {{mustache}} - -``` diff --git a/changelog_unreleased/handlebars/9978.md b/changelog_unreleased/handlebars/9978.md deleted file mode 100644 index 74b108394..000000000 --- a/changelog_unreleased/handlebars/9978.md +++ /dev/null @@ -1,44 +0,0 @@ -#### Print final `blockParam` on its own line (#9978 by @dcyriller) - - -```hbs -{{!-- Input --}} - -{{#block param hashKey=hashValue hashKey=hashValue hashKey=hashValue as |blockParam|}} - Hello -{{/block}} - -{{!-- Prettier stable --}} - -{{#block - param - hashKey=hashValue - hashKey=hashValue - hashKey=hashValue as |blockParam| -}} - Hello -{{/block}} - -{{!-- Prettier main --}} - -{{#block - param - hashKey=hashValue - hashKey=hashValue - hashKey=hashValue - as |blockParam| -}} - Hello -{{/block}} -``` diff --git a/changelog_unreleased/html/7865.md b/changelog_unreleased/html/7865.md deleted file mode 100644 index 9587027eb..000000000 --- a/changelog_unreleased/html/7865.md +++ /dev/null @@ -1,22 +0,0 @@ -#### [IMPROVEMENT] Prefix-based multiline formatting for the `class` attribute (#7865 by @thorn0) - -Formatting of HTML class names will now keep classes on one line until the line length limit is reached; at that point, consecutive classes with the same prefix will be grouped together on each line. For layout frameworks such as Bootstrap and Tailwind CSS, which add many classes to an element, this is important for readability and maintainability vs. the previous behavior (keeping all classes on one line) or e.g. putting each class on its own line. - - -```html - -
- - -
-``` diff --git a/changelog_unreleased/javascript/10085.md b/changelog_unreleased/javascript/10085.md deleted file mode 100644 index 187c15a34..000000000 --- a/changelog_unreleased/javascript/10085.md +++ /dev/null @@ -1,19 +0,0 @@ -#### [IMPROVEMENT:2] Improve visual separation between header and body in classes with multiline headers (#10085 by @sosukesuzuki) - - -```ts -// Prettier stable -class loooooooooooooooooooong - extends looooooooooooooooooong - implements loooooooooooooooooooong { - property: string; -} - -// Prettier main -class loooooooooooooooooooong - extends looooooooooooooooooong - implements loooooooooooooooooooong -{ - property: string; -} -``` diff --git a/changelog_unreleased/javascript/10106.md b/changelog_unreleased/javascript/10106.md deleted file mode 100644 index c3510be6f..000000000 --- a/changelog_unreleased/javascript/10106.md +++ /dev/null @@ -1,43 +0,0 @@ -#### [IMPROVEMENT:3] Concise formatting of number-only arrays (#10106, #10160 by @thorn0) - -While in general, Prettier avoids this kind of formatting because it's not diff-friendly, in this special case we decided that the benefits outweigh the risks. - -If at least one element has a trailing single-line (`// ...`) comment on the same line, the concise formatting isn't applied. On the other hand, single-line comments placed on separate lines don't have such an effect and – as well as empty lines – can be used for logical grouping. - - -```jsx -// Input -const lazyCatererNumbers = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46, - -// n > 10 -56, 67, 79, 92, 106, 121, 137, 154, 172, 191, 211, 232, 254, 277, 301, 326, 352, 379, 407, 436, 466, -497, 529, 562, 596, 631, 667, 704, 742, 781, -// n > 40 -821, 862, 904, 947, 991, 1036, 1082, 1129, 1177, 1226, 1276, 1327, 1379]; - -// Prettier stable -const lazyCatererNumbers = [ - 1, - 2, - 4, - 7, - 11, - 16, - 22, - 29, - 37, - // ... ✂ 46 lines ✂ ... - 1379, -]; - -// Prettier main -const lazyCatererNumbers = [ - 1, 2, 4, 7, 11, 16, 22, 29, 37, 46, - - // n > 10 - 56, 67, 79, 92, 106, 121, 137, 154, 172, 191, 211, 232, 254, 277, 301, 326, - 352, 379, 407, 436, 466, 497, 529, 562, 596, 631, 667, 704, 742, 781, - // n > 40 - 821, 862, 904, 947, 991, 1036, 1082, 1129, 1177, 1226, 1276, 1327, 1379, -]; -``` diff --git a/changelog_unreleased/javascript/10187.md b/changelog_unreleased/javascript/10187.md deleted file mode 100644 index ba043e458..000000000 --- a/changelog_unreleased/javascript/10187.md +++ /dev/null @@ -1,51 +0,0 @@ -#### [IMPROVEMENT:6] Consistent indentation for conditional operators (#10187, #10266 by @sosukesuzuki) - - -```ts -// Prettier stable -const dotNotationMemberExpression = (callNode.parent?.type === -AST_NODE_TYPES.ChainExpression - ? callNode.parent.parent - : callNode.parent -).TSESTree.BinaryExpression; - -const computedMemberExpression = (callNode.parent?.type === -AST_NODE_TYPES.ChainExpression - ? callNode.parent.parent - : callNode.parent)[TSESTree.BinaryExpression]; - -const callExpressionCallee = (callNode.parent?.type === - AST_NODE_TYPES.ChainExpression - ? callNode.parent.parent - : callNode.parent)(TSESTree.BinaryExpression); - -const typeScriptAsExpression = (callNode.parent?.type === -AST_NODE_TYPES.ChainExpression - ? callNode.parent.parent - : callNode.parent) as TSESTree.BinaryExpression; - -// Prettier main -const dotNotationMemberExpression = ( - callNode.parent?.type === AST_NODE_TYPES.ChainExpression - ? callNode.parent.parent - : callNode.parent -).TSESTree.BinaryExpression; - -const computedMemberExpression = ( - callNode.parent?.type === AST_NODE_TYPES.ChainExpression - ? callNode.parent.parent - : callNode.parent -)[TSESTree.BinaryExpression]; - -const callExpressionCallee = ( - callNode.parent?.type === AST_NODE_TYPES.ChainExpression - ? callNode.parent.parent - : callNode.parent -)(TSESTree.BinaryExpression); - -const typeScriptAsExpression = ( - callNode.parent?.type === AST_NODE_TYPES.ChainExpression - ? callNode.parent.parent - : callNode.parent -) as TSESTree.BinaryExpression; -``` diff --git a/changelog_unreleased/javascript/10222.md b/changelog_unreleased/javascript/10222.md deleted file mode 100644 index ba79129be..000000000 --- a/changelog_unreleased/javascript/10222.md +++ /dev/null @@ -1,41 +0,0 @@ -#### [HIGHLIGHT] Format assignments more consistently (#10222, #10643, #10672 by @thorn0; #10158 by @sosukesuzuki) - -Previously, Prettier had a lot of trouble with figuring out how to break lines in assignments. E.g., long right-hand sides often stayed unbroken. Not anymore. - - -```ts -// Prettier stable -aParticularlyLongAndObnoxiousNameForIllustrativePurposes = anotherVeryLongNameForIllustrativePurposes; - -aParticularlyLongAndObnoxiousNameForIllustrativePurposes = "a very long string for illustrative purposes" - .length; - -someReallyLongThingStoredInAMapWithAReallyBigName[ - pageletID -] = _someVariableThatWeAreCheckingForFalsiness - ? Date.now() - _someVariableThatWeAreCheckingForFalsiness - : 0; - -class x { - private readonly rawConfigFromFile$: BehaviorSubject = new BehaviorSubject( - notRead - ); -} - -// Prettier main -aParticularlyLongAndObnoxiousNameForIllustrativePurposes = - anotherVeryLongNameForIllustrativePurposes; - -aParticularlyLongAndObnoxiousNameForIllustrativePurposes = - "a very long string for illustrative purposes".length; - -someReallyLongThingStoredInAMapWithAReallyBigName[pageletID] = - _someVariableThatWeAreCheckingForFalsiness - ? Date.now() - _someVariableThatWeAreCheckingForFalsiness - : 0; - -class x { - private readonly rawConfigFromFile$: BehaviorSubject = - new BehaviorSubject(notRead); -} -``` diff --git a/changelog_unreleased/javascript/10238.md b/changelog_unreleased/javascript/10238.md deleted file mode 100644 index c229c97b4..000000000 --- a/changelog_unreleased/javascript/10238.md +++ /dev/null @@ -1,15 +0,0 @@ -#### [IMPROVEMENT:1] Improve formatting for React Hooks calls (#10238 by @sosukesuzuki) - - -```js -// Prettier stable -const { firstName, lastName } = useMemo(() => parseFullName(fullName), [ - fullName, -]); - -// Prettier main -const { firstName, lastName } = useMemo( - () => parseFullName(fullName), - [fullName] -); -``` diff --git a/changelog_unreleased/javascript/10278.md b/changelog_unreleased/javascript/10278.md deleted file mode 100644 index c6e3505c6..000000000 --- a/changelog_unreleased/javascript/10278.md +++ /dev/null @@ -1,15 +0,0 @@ -#### Fix error thrown on expressions like `a(b => c => function (){})` (#10278 by @thorn0) - -Regression from v2.2.0. - - -```jsx -// Input -a(b => c => function (){}) - -// Prettier stable -TypeError: Cannot read property 'length' of undefined - -// Prettier main -a((b) => (c) => function () {}); -``` diff --git a/changelog_unreleased/javascript/10296.md b/changelog_unreleased/javascript/10296.md deleted file mode 100644 index d3405b77c..000000000 --- a/changelog_unreleased/javascript/10296.md +++ /dev/null @@ -1,25 +0,0 @@ -#### Improve formatting for inline decorators (#10296 by @fisker) - - -```jsx -// Input -class Foo { - @decorator([]) bar() {} - @decorator( - [] - ) baz() {} -} - -// Prettier stable -class Foo { - @decorator([]) bar() {} - @decorator([]) - baz() {} -} - -// Prettier main -class Foo { - @decorator([]) bar() {} - @decorator([]) baz() {} -} -``` diff --git a/changelog_unreleased/javascript/10334.md b/changelog_unreleased/javascript/10334.md deleted file mode 100644 index 8d41c6fe8..000000000 --- a/changelog_unreleased/javascript/10334.md +++ /dev/null @@ -1,22 +0,0 @@ -#### Fix ASI protection for private fields (#10334 by @thorn0) - - -```jsx -// Input -class C { - #field = 'value'; - ["method"]() {} -} - -// Prettier stable (with --no-semi) -class C { - #field = "value" - ["method"]() {} -} - -// Prettier main (with --no-semi) -class C { - #field = "value"; - ["method"]() {} -} -``` diff --git a/changelog_unreleased/javascript/10335.md b/changelog_unreleased/javascript/10335.md deleted file mode 100644 index 0a0a09c11..000000000 --- a/changelog_unreleased/javascript/10335.md +++ /dev/null @@ -1,21 +0,0 @@ -#### [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` – 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", - 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", - gitHubUrl: - "https://github.com/prettier/prettier/blob/main/docs/rationale.md#what-prettier-is-concerned-about", -}; -``` diff --git a/changelog_unreleased/javascript/10342.md b/changelog_unreleased/javascript/10342.md deleted file mode 100644 index 572d65651..000000000 --- a/changelog_unreleased/javascript/10342.md +++ /dev/null @@ -1,34 +0,0 @@ -#### [IMPROVEMENT:4] Improve formatting for nested await expressions in heads of member and call expressions (#10342 by @thorn0) - -Even though Prettier tries to be helpful here, please don't write code like this. Have mercy upon your teammates and use intermediate variables. - - -```jsx -// Input -const getAccountCount = async () => - (await - (await ( - await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) - ).findItem("My bookmarks")).getChildren() - ).length - -// Prettier stable -const getAccountCount = async () => - ( - await ( - await (await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME)).findItem( - "My bookmarks" - ) - ).getChildren() - ).length; - -// Prettier main -const getAccountCount = async () => - ( - await ( - await ( - await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) - ).findItem("My bookmarks") - ).getChildren() - ).length; -``` diff --git a/changelog_unreleased/javascript/10417.md b/changelog_unreleased/javascript/10417.md deleted file mode 100644 index ec0625f11..000000000 --- a/changelog_unreleased/javascript/10417.md +++ /dev/null @@ -1,17 +0,0 @@ -#### Support Module Blocks proposal (#10417 by @sosukesuzuki, @thorn0) - -Support formatting for [Module Blocks Stage 2 proposal](https://github.com/tc39/proposal-js-module-blocks). - - -```js -// Input -module { export let foo = "foo"; }; - -// Prettier stable -SyntaxError: Unexpected token, expected ";" - -// Prettier main -module { - export let foo = "foo"; -}; -``` diff --git a/changelog_unreleased/javascript/10446.md b/changelog_unreleased/javascript/10446.md deleted file mode 100644 index bbd5a8806..000000000 --- a/changelog_unreleased/javascript/10446.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Fix missing parentheses for `yield` in a pipeline (#10446 by @fisker) - - -```jsx -// Input -function* f() { - return x |> (yield #); -} - -// Prettier stable -function* f() { - return x |> yield #; -} - -// Prettier main -function* f() { - return x |> (yield #); -} -``` diff --git a/changelog_unreleased/javascript/10495.md b/changelog_unreleased/javascript/10495.md deleted file mode 100644 index 2cb8ec828..000000000 --- a/changelog_unreleased/javascript/10495.md +++ /dev/null @@ -1,31 +0,0 @@ -#### Make Babel’s error recovery more selective (#10495 by @fisker, #9787 by @sosukesuzuki, #10065, #10322 by @thorn0) - -Previously, because of the [error recovery](https://babeljs.io/blog/2019/11/05/7.7.0#parser-error-recovery-10363httpsgithubcombabelbabelpull10363), the Babel parser was too permissive, which lead to all kinds of AST shapes that Prettier couldn’t print. Prettier main lets Babel recover only from a few harmless types of errors – for example, multiple `const` declarations with the same name. Anything else is reported as syntax errors. - - -```js -// Input -foo("a", , "b"); - -// Prettier stable -TypeError: Cannot read property 'type' of null - -// Prettier main -[error] stdin: SyntaxError: Argument expression expected. (1:10) -[error] > 1 | foo("a", , "b"); -[error] | ^ -``` - - -```js -// Input -const \u{20} = 1 - -// Prettier stable -const = 1; - -// Prettier main -[error] stdin: SyntaxError: Invalid Unicode escape (1:7) -[error] > 1 | const \u{20} = 1 -[error] | ^ ^ -``` diff --git a/changelog_unreleased/javascript/10517.md b/changelog_unreleased/javascript/10517.md deleted file mode 100644 index abfdcf5ea..000000000 --- a/changelog_unreleased/javascript/10517.md +++ /dev/null @@ -1,33 +0,0 @@ -#### Avoid last-argument hugging for number-only arrays (#10517 by @thorn0) - -Another special case for number-only arrays. - - -```jsx -// Input -instantiate(game, [ - transform([-0.7, 0.5, 0]), - render_colored_diffuse(game.MaterialDiffuse, game.Meshes["monkey_flat"], [1, 1, 0.3, 1]), -]); - -// Prettier stable -instantiate(game, [ - transform([-0.7, 0.5, 0]), - render_colored_diffuse(game.MaterialDiffuse, game.Meshes["monkey_flat"], [ - 1, - 1, - 0.3, - 1, - ]), -]); - -// Prettier main -instantiate(game, [ - transform([-0.7, 0.5, 0]), - render_colored_diffuse( - game.MaterialDiffuse, - game.Meshes["monkey_flat"], - [1, 1, 0.3, 1] - ), -]); -``` diff --git a/changelog_unreleased/javascript/10528.md b/changelog_unreleased/javascript/10528.md deleted file mode 100644 index 07cbccec3..000000000 --- a/changelog_unreleased/javascript/10528.md +++ /dev/null @@ -1,16 +0,0 @@ -#### Improve detection of AMD `define` (#10528 by @thorn0) - -Prettier special-cases AMD `define` calls to avoid unexpected line breaks in them. We now only format `define` calls if they are at the top level of a function or program and are passed arguments in the way AMD expects. - - -```jsx -// Prettier stable -const someVariable = define("some string literal", anotherVariable, yetAnotherVariable); - -// Prettier main -const someVariable = define( - "some string literal", - anotherVariable, - yetAnotherVariable -); -``` diff --git a/changelog_unreleased/javascript/10666.md b/changelog_unreleased/javascript/10666.md deleted file mode 100644 index d35e2fdf1..000000000 --- a/changelog_unreleased/javascript/10666.md +++ /dev/null @@ -1,21 +0,0 @@ -#### Fix duplicated `prettier-ignore` comments (#10666 by @fisker) - - -```jsx -// Input -foo = a. - // prettier-ignore - b; - -// Prettier stable -foo = - // prettier-ignore - a. - // prettier-ignore - b; - -// Prettier main -foo = a. - // prettier-ignore - b; -``` diff --git a/changelog_unreleased/javascript/10693.md b/changelog_unreleased/javascript/10693.md deleted file mode 100644 index bebf23919..000000000 --- a/changelog_unreleased/javascript/10693.md +++ /dev/null @@ -1,20 +0,0 @@ -#### [IMPROVEMENT:5] Improve formatting for `do` expressions in function calls (#10693 by @sosukesuzuki) - -“`do` expressions” are a [stage 1 ECMAScript proposal](https://github.com/tc39/proposal-do-expressions). - - -```js -// Prettier stable -expect( - do { - var bar = "foo"; - bar; - } -).toBe("foo"); - -// Prettier main -expect(do { - var bar = "foo"; - bar; -}).toBe("foo"); -``` diff --git a/changelog_unreleased/javascript/10695.md b/changelog_unreleased/javascript/10695.md deleted file mode 100644 index 8d64d832a..000000000 --- a/changelog_unreleased/javascript/10695.md +++ /dev/null @@ -1,40 +0,0 @@ -#### Process conditional groups in `mapDoc` (#10695 by @thorn0) - -In particular, this fixes broken substitutions in HTML-in-JS. - - -```jsx -// Input -export default function include_photoswipe( - gallery_selector = ".my-gallery" -): string { - return /* HTML */ ` - `; -} - -// Prettier stable -export default function include_photoswipe( - gallery_selector = ".my-gallery" -): string { - return /* HTML */ ` `; -} - -// Prettier main -export default function include_photoswipe( - gallery_selector = ".my-gallery" -): string { - return /* HTML */ ` `; -} -``` diff --git a/changelog_unreleased/javascript/10712.md b/changelog_unreleased/javascript/10712.md deleted file mode 100644 index ee220b228..000000000 --- a/changelog_unreleased/javascript/10712.md +++ /dev/null @@ -1,24 +0,0 @@ -#### Avoid arg expansion that leads to broken code (#10712 by @thorn0) - - -```jsx -// Input -glimseGlyphsHazardNoopsTieTie(({ a, b = () => { - console.log(); -}}) => averredBathersBoxroomBuggyNurl()); - -// Prettier stable -glimseGlyphsHazardNoopsTieTie(({ a, b = () => { - console.log(); - } }) => averredBathersBoxroomBuggyNurl()); - -// Prettier main -glimseGlyphsHazardNoopsTieTie( - ({ - a, - b = () => { - console.log(); - }, - }) => averredBathersBoxroomBuggyNurl() -); -``` diff --git a/changelog_unreleased/javascript/10781.md b/changelog_unreleased/javascript/10781.md deleted file mode 100644 index 2da400aa3..000000000 --- a/changelog_unreleased/javascript/10781.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Fix missing parentheses around `async` in `for-of` (#10781 by @fisker) - -See https://github.com/tc39/ecma262/issues/2034 - - -```jsx -// Input -for ((async) of []); - -// Prettier stable -for (async of []); - -// Prettier stable (second format) -SyntaxError: Unexpected token, expected "=>" (1:15) -> 1 | for (async of []); - -// Prettier main -for ((async) of []); -``` diff --git a/changelog_unreleased/javascript/10813.md b/changelog_unreleased/javascript/10813.md deleted file mode 100644 index b25125c41..000000000 --- a/changelog_unreleased/javascript/10813.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Support `async do` expressions proposal (#10813 by @sosukesuzuki) - -See https://github.com/tc39/proposal-async-do-expressions - - -```js -// Input -const x = async do { - await requestAPI().json(); -}; - -// Prettier stable -SyntaxError: Unexpected token, expected ";" (1:17) - -// Prettier main -const x = async do { - await requestAPI().json(); -}; -``` diff --git a/changelog_unreleased/javascript/9672.md b/changelog_unreleased/javascript/9672.md deleted file mode 100644 index e23d509eb..000000000 --- a/changelog_unreleased/javascript/9672.md +++ /dev/null @@ -1,25 +0,0 @@ -#### Fix unstable multiple comments on the same line (#9672 by @fisker) - - -```js -// Input -a; -/*1*//*2*/ -/*3*/ -b; - -// Prettier stable -a; /*2*/ -/*1*/ /*3*/ -b; - -// Prettier stable (second format) -a; /*2*/ /*3*/ -/*1*/ b; - -// Prettier main -a; -/*1*/ /*2*/ -/*3*/ -b; -``` diff --git a/changelog_unreleased/javascript/9704.md b/changelog_unreleased/javascript/9704.md deleted file mode 100644 index e6963df2a..000000000 --- a/changelog_unreleased/javascript/9704.md +++ /dev/null @@ -1,17 +0,0 @@ -#### Don’t format nodes that end just before `rangeStart` (#9704 by @fisker) - -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 -// Input -foo = 1.0000;bar = 1.0000;baz=1.0000; - ^^^^^^^^^^^^^ Range - -// Prettier stable -foo = 1.0; -bar = 1.0;baz=1.0000; - -// Prettier main -foo = 1.0000;bar = 1.0;baz=1.0000; -``` diff --git a/changelog_unreleased/javascript/9711.md b/changelog_unreleased/javascript/9711.md deleted file mode 100644 index bd6788a34..000000000 --- a/changelog_unreleased/javascript/9711.md +++ /dev/null @@ -1,18 +0,0 @@ -#### Fix comments inside JSX end tag (#9711 by @fisker) - - -```jsx -// Input -; - -// Prettier stable -; - -// Prettier main -; -``` diff --git a/changelog_unreleased/javascript/9743.md b/changelog_unreleased/javascript/9743.md deleted file mode 100644 index 00bee1081..000000000 --- a/changelog_unreleased/javascript/9743.md +++ /dev/null @@ -1,21 +0,0 @@ -#### Fix inconsistent language comment detection (#9743 by @fisker) - -An `/* HTML */` comment should directly precede a template literal for the latter to be recognized as HTML-in-JS. Previously, the comment was erroneously recognized is some other locations. - - -```jsx -// Input -foo /* HTML */ = `
-
`; - -// Prettier stable (--parser=babel) -foo /* HTML */ = `
`; - -// Prettier stable (--parser=meriyah) -foo /* HTML */ = `
-
`; - -// Prettier main (All JavaScript parsers) -foo /* HTML */ = `
-
`; -``` diff --git a/changelog_unreleased/javascript/9850.md b/changelog_unreleased/javascript/9850.md deleted file mode 100644 index 7a0476f1d..000000000 --- a/changelog_unreleased/javascript/9850.md +++ /dev/null @@ -1,31 +0,0 @@ -#### Fix extra semicolon added to ignored directives (#9850 by @fisker) - - -```js -// Input -// prettier-ignore -'use strict'; - -function foo() { -// prettier-ignore -"use strict";; -} - -// Prettier stable -// prettier-ignore -'use strict';; - -function foo() { - // prettier-ignore - "use strict";; -} - -// Prettier main -// prettier-ignore -'use strict'; - -function foo() { - // prettier-ignore - "use strict"; -} -``` diff --git a/changelog_unreleased/javascript/9866.md b/changelog_unreleased/javascript/9866.md deleted file mode 100644 index 21b837a62..000000000 --- a/changelog_unreleased/javascript/9866.md +++ /dev/null @@ -1,29 +0,0 @@ -#### Fix unstable JSX formatting with U+3000 (#9866 by @fisker) - - -```js -// Input -

-  {this.props.data.title}  - //----- ^ U+3000 --------------- ^ U+3000 -

- -// Prettier stable -

- -  {this.props.data.title}  - //----- ^ U+3000 --------------- ^ U+3000 -

; - -// Prettier stable (second format) -

-  {this.props.data.title}  - //----- ^ U+3000 --------------- ^ U+3000 -

; - -// Prettier main -

-  {this.props.data.title}  - //----- ^ U+3000 --------------- ^ U+3000 -

; -``` diff --git a/changelog_unreleased/javascript/9992.md b/changelog_unreleased/javascript/9992.md deleted file mode 100644 index fad44c939..000000000 --- a/changelog_unreleased/javascript/9992.md +++ /dev/null @@ -1,19 +0,0 @@ -#### [IMPROVEMENT:0] Refine formatting of curried arrow functions (#9992, #10543 by @sosukesuzuki & @thorn0) - - -```js -// Prettier stable -const currying = (argument1) => (argument2) => (argument3) => (argument4) => ( - argument5 -) => (argument6) => foo; - -// Prettier main -const currying = - (argument1) => - (argument2) => - (argument3) => - (argument4) => - (argument5) => - (argument6) => - foo; -``` diff --git a/changelog_unreleased/json/10323.md b/changelog_unreleased/json/10323.md deleted file mode 100644 index eab0505f6..000000000 --- a/changelog_unreleased/json/10323.md +++ /dev/null @@ -1,21 +0,0 @@ -#### Don't use smart quotes for JSON5 with `--quote-props=preserve` (#10323 by @thorn0) - -With the `quoteProps` option set to `preserve` and `singleQuotes` to `false` (default), double quotes are always used for printing strings, including situations like `"bla\"bla"`. This effectively allows using `--parser json5` for "JSON with comments and trailing commas". - - -```js -// Input -{ - "char": "\"", -} - -// Prettier stable -{ - "char": '"', -} - -// Prettier main -{ - "char": "\"", -} -``` diff --git a/changelog_unreleased/json/10346.md b/changelog_unreleased/json/10346.md deleted file mode 100644 index cfa51d489..000000000 --- a/changelog_unreleased/json/10346.md +++ /dev/null @@ -1,17 +0,0 @@ -#### Stricter JSON parser (#10346, #10443, #10456, #10434 by @fisker) - -Prettier internally uses a JavaScript expression parser to parse JSON. That's why the `json` and `json5` parsers used to be very forgiving and allowed all kinds of JavaScript expressions. Now they are much stricter, although some simple non-standard syntax is still allowed (e.g., [JSON6](https://github.com/d3x0r/JSON6) is supported, except for multiple minus signs: `----123`). - - -```js -// Input -[1, 2, 1 + 2] - -// Prettier stable -[1, 2, 1 + 2] - -// Prettier main -SyntaxError: BinaryExpression is not allowed in JSON. (1:8) -> 1 | [1, 2, 1 + 2] - | ^ -``` diff --git a/changelog_unreleased/json/10433.md b/changelog_unreleased/json/10433.md deleted file mode 100644 index 91a49bf26..000000000 --- a/changelog_unreleased/json/10433.md +++ /dev/null @@ -1,17 +0,0 @@ -#### Improve error message (#10433 by @fisker) - - -```js -// Input -{key: "foo" + "bar"} - -// Prettier stable (--parser=json-stringify) -SyntaxError: BinaryExpression is not allowed in JSON. (1:7) -> 1 | {key: "foo" + "bar"} - | ^ - -// Prettier main -SyntaxError: BinaryExpression is not allowed in JSON. (1:7) -> 1 | {key: "foo" + "bar"} - | ^^^^^^^^^^^^^ -``` diff --git a/changelog_unreleased/json/10497.md b/changelog_unreleased/json/10497.md deleted file mode 100644 index 10e7b5dc7..000000000 --- a/changelog_unreleased/json/10497.md +++ /dev/null @@ -1,16 +0,0 @@ -#### Fix syntax error on JSON range formatting (#10497 by @fisker) - - -```js -// Input -[{ a: 1.0000}, {"b": 2.0000 }] -// ^^^^^^^^^^^ range - -// Prettier stable -SyntaxError: Unexpected token (1:4) -> 1 | "b": 2.0000 - | ^ - -// Prettier main -[{ a: 1.0000}, { "b": 2.0 }] -``` diff --git a/changelog_unreleased/markdown/9736.md b/changelog_unreleased/markdown/9736.md deleted file mode 100644 index a96744438..000000000 --- a/changelog_unreleased/markdown/9736.md +++ /dev/null @@ -1,26 +0,0 @@ -#### Fix extra newline at the end of JavaScript fenced code block with string literal (#9736 by @fisker) - - -````markdown - -Markdown - -```js -"· " -``` - - -Markdown - -```js -"· "; - -``` - - -Markdown - -```js -"· "; -``` -```` diff --git a/changelog_unreleased/markdown/9791.md b/changelog_unreleased/markdown/9791.md deleted file mode 100644 index b23ad3027..000000000 --- a/changelog_unreleased/markdown/9791.md +++ /dev/null @@ -1,44 +0,0 @@ -#### Fix empty front matter formatting (#9791 by @fisker) - - -```markdown - ---- ---- - -# Title - -a|b|c| -|:--|:-:|--:| -|d|e|f| - ---- - -text - - ---- ---- -# Title - -a|b|c| -|:--|:-:|--:| -|d|e|f| ---- - -text - - ---- ---- - -# Title - -| a | b | c | -| :-- | :-: | --: | -| d | e | f | - ---- - -text -``` diff --git a/changelog_unreleased/markdown/9878.md b/changelog_unreleased/markdown/9878.md deleted file mode 100644 index 409d2c4bb..000000000 --- a/changelog_unreleased/markdown/9878.md +++ /dev/null @@ -1,31 +0,0 @@ -#### Support YAML document end marker in front matter (#9878 by @michaelbeaumont) - -Add the ability to delimit the end of front matter with `...`. - - -```markdown - ---- -title: Hello -slug: home -... - -Markdown - - ---- - -title: Hello -slug: home -... - -Markdown - - ---- -title: Hello -slug: home -... - -Markdown -``` diff --git a/changelog_unreleased/scss/10005.md b/changelog_unreleased/scss/10005.md deleted file mode 100644 index 17b441df8..000000000 --- a/changelog_unreleased/scss/10005.md +++ /dev/null @@ -1,17 +0,0 @@ -#### Fix maps with keys that are lists or maps (#10005 by @fisker) - - -```scss -// Input -$map: ( - ('my list'): 'hello world', -); - -// Prettier stable -TypeError: Cannot read property 'length' of undefined - -// Prettier main -$map: ( - ("my list"): "hello world", -); -``` diff --git a/changelog_unreleased/scss/9710.md b/changelog_unreleased/scss/9710.md deleted file mode 100644 index a729dddf0..000000000 --- a/changelog_unreleased/scss/9710.md +++ /dev/null @@ -1,23 +0,0 @@ -#### Fix broken comment inside parens (#9710 by @fisker) - - -```scss -// Input -.simplification { - foo: ( - calc() // not a comment anymore - ); -} - -// Prettier stable -.simplification { - foo: (calc() // not a comment anymore); -} - -// Prettier main -.simplification { - foo: ( - calc() // not a comment anymore - ); -} -``` diff --git a/changelog_unreleased/typescript/10024.md b/changelog_unreleased/typescript/10024.md deleted file mode 100644 index eca023a3c..000000000 --- a/changelog_unreleased/typescript/10024.md +++ /dev/null @@ -1,25 +0,0 @@ -#### Fix unnecessary line breaks in method type declaration parameters (#10024 by @sosukesuzuki, #10357 by @thorn0) - - -```js -// Input -type Foo = { - method(foo: "foo"): ` - ` -}; - -// Prettier stable -type Foo = { - method( - foo: "foo" - ): ` - `; -}; - -// Prettier main -type Foo = { - method(foo: "foo"): ` - `; -}; - -``` diff --git a/changelog_unreleased/typescript/10109.md b/changelog_unreleased/typescript/10109.md deleted file mode 100644 index e1bbb5aa5..000000000 --- a/changelog_unreleased/typescript/10109.md +++ /dev/null @@ -1,29 +0,0 @@ -#### Print trailing commas in type parameters (#10109 by @sosukesuzuki, #10353 by @thorn0) - -TypeScript has been supporting trailing commas in type parameters since TypeScript 2.7 released in January 2018. Prettier main prints them if the `trailingComma` option is set to `all`. Keep this option at the more conservative default value `es5` if compatibility with TypeScript 2.7 or older is needed. Note that TypeScript [still doesn't support][ts-issue-21984] trailing commas in type arguments (type parameter instantiations). - -[ts-issue-21984]: https://github.com/microsoft/TypeScript/issues/21984 - - -```ts -// Input -export class BaseSingleLevelProfileTargeting< - T extends ValidSingleLevelProfileNode, -> { - // ... -} - -// Prettier stable -export class BaseSingleLevelProfileTargeting< - T extends ValidSingleLevelProfileNode -> { - // ... -} - -// Prettier main with --trailling-comma=all -export class BaseSingleLevelProfileTargeting< - T extends ValidSingleLevelProfileNode, -> { - // ... -} -``` diff --git a/changelog_unreleased/typescript/10316.md b/changelog_unreleased/typescript/10316.md deleted file mode 100644 index 69629b742..000000000 --- a/changelog_unreleased/typescript/10316.md +++ /dev/null @@ -1,16 +0,0 @@ -#### Allow hugging arguments that are non-concise arrow functions with return type annotations (#10316 by @thorn0) - - -```ts -// Prettier stable -users.map( - (user: User): User => { - return user; - } -); - -// Prettier main -users.map((user: User): User => { - return user; -}) -``` diff --git a/changelog_unreleased/typescript/10337.md b/changelog_unreleased/typescript/10337.md deleted file mode 100644 index defd35cd3..000000000 --- a/changelog_unreleased/typescript/10337.md +++ /dev/null @@ -1,27 +0,0 @@ -#### Correct parentheses for non-null assertions (#10337 by @thorn0) - -Necessary parentheses sometimes weren't printed in expressions containing non-null assertions. This has been fixed. - - -```ts -// Input -const myFunction2 = (key: string): number => - ({ - a: 42, - b: 42, - }[key]!) - -// Prettier stable (invalid syntax) -const myFunction2 = (key: string): number => - { - a: 42, - b: 42, - }[key]!; - -// Prettier main -const myFunction2 = (key: string): number => - ({ - a: 42, - b: 42, - }[key]!); -``` diff --git a/changelog_unreleased/typescript/10341.md b/changelog_unreleased/typescript/10341.md deleted file mode 100644 index 77c838c55..000000000 --- a/changelog_unreleased/typescript/10341.md +++ /dev/null @@ -1,22 +0,0 @@ -#### Indent type assertions in heads of member and call expressions (#10341 by @thorn0) - - -```ts -// Input -const accountCount = (findItemInSection(BOOKMARKED_PROJECTS_SECTION_NAME, - "My bookmarks") as TreeItem).getChildren().length; - -// Prettier stable -const accountCount = (findItemInSection( - BOOKMARKED_PROJECTS_SECTION_NAME, - "My bookmarks" -) as TreeItem).getChildren().length; - -// Prettier main -const accountCount = ( - findItemInSection( - BOOKMARKED_PROJECTS_SECTION_NAME, - "My bookmarks" - ) as TreeItem -).getChildren().length; -``` diff --git a/changelog_unreleased/typescript/10390.md b/changelog_unreleased/typescript/10390.md deleted file mode 100644 index 0c4671a3e..000000000 --- a/changelog_unreleased/typescript/10390.md +++ /dev/null @@ -1,14 +0,0 @@ -#### Support intrinsic keyword (#10390 by @sosukesuzuki) - - -```ts -// Input -type Uppercase = intrinsic; - -// Prettier stable -Error: unknown type: "TSIntrinsicKeyword" - -// Prettier main -type Uppercase = intrinsic; - -``` diff --git a/changelog_unreleased/typescript/10418.md b/changelog_unreleased/typescript/10418.md deleted file mode 100644 index b33afe6f8..000000000 --- a/changelog_unreleased/typescript/10418.md +++ /dev/null @@ -1,31 +0,0 @@ -#### Support TypeScript 4.2 (#10418, #10466, #10546, #10589 by @sosukesuzuki) - -##### [`abstract` Construct Signatures](https://devblogs.microsoft.com/typescript/announcing-typescript-4-2/#abstract-construct-signatures) - - -```ts -// Input -type T = abstract new () => void; - -// Prettier stable -SyntaxError: Unexpected token, expected ";" (1:19) - -// Prettier main -type T = abstract new () => void; - -``` - -##### [Type imports in import require declaration](https://github.com/microsoft/TypeScript/pull/41573) - - -```ts -// Input -import type A = require("A"); - -// Prettier stable -SyntaxError: Only ECMAScript imports may use 'import type'. - -// Prettier main -import type A = require("A"); - -``` diff --git a/changelog_unreleased/typescript/10457.md b/changelog_unreleased/typescript/10457.md deleted file mode 100644 index 8587da5a2..000000000 --- a/changelog_unreleased/typescript/10457.md +++ /dev/null @@ -1,13 +0,0 @@ -#### Fix misplaced comments in unions and intersections (#10457 by @thorn0) - - -```ts -// Input -type Foo = "1" | "2" /* two */ | "3"; - -// Prettier stable -type Foo = "1" | "2" | /* two */ "3"; - -// Prettier main -type Foo = "1" | "2" /* two */ | "3"; -``` diff --git a/changelog_unreleased/typescript/10702.md b/changelog_unreleased/typescript/10702.md deleted file mode 100644 index 8982855f7..000000000 --- a/changelog_unreleased/typescript/10702.md +++ /dev/null @@ -1,13 +0,0 @@ -#### Don’t print parens around nested type assertions (#10702 by @thorn0) - - -```ts -// Input -foo as unknown as Bar - -// Prettier stable -(foo as unknown) as Bar; - -// Prettier main -foo as unknown as Bar; -``` diff --git a/changelog_unreleased/typescript/10811.md b/changelog_unreleased/typescript/10811.md deleted file mode 100644 index 5f2a6c99e..000000000 --- a/changelog_unreleased/typescript/10811.md +++ /dev/null @@ -1,26 +0,0 @@ -#### Support TypeScript 4.3 via `babel-ts` (#10811 by @sosukesuzuki) - -##### [`override` modifiers in class elements](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3-beta/#override-and-the-noimplicitoverride-flag) - -```ts -class Foo extends { - override method() {} -} -``` - -##### [static index signatures (`[key: KeyType]: ValueType`) in classes](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3-beta/#static-index-signatures) - -```ts -class Foo { - static [key: string]: Bar; -} -``` - -##### [`get` / `set` in type declarations](https://devblogs.microsoft.com/typescript/announcing-typescript-4-3-beta/#separate-write-types-on-properties) - -```ts -interface Foo { - set foo(value); - get foo(): string; -} -``` diff --git a/changelog_unreleased/typescript/9872.md b/changelog_unreleased/typescript/9872.md deleted file mode 100644 index fd8c2911d..000000000 --- a/changelog_unreleased/typescript/9872.md +++ /dev/null @@ -1,19 +0,0 @@ -#### Fix missing comments in `MethodDefinition` (#9872 by @fisker) - -`typescript` parser only, `babel-ts` doesn't have this issue. - - -```typescript -// Input -class Foo { - bar() /* bat */; -} - -// Prettier stable -Error: Comment "bat" was not printed. Please report this error! - -// Prettier main -class Foo { - bar /* bat */(); -} -``` diff --git a/changelog_unreleased/yaml/10516.md b/changelog_unreleased/yaml/10516.md deleted file mode 100644 index 3094ae3e3..000000000 --- a/changelog_unreleased/yaml/10516.md +++ /dev/null @@ -1,24 +0,0 @@ -#### Fix SyntaxError incorrectly thrown on anchors followed by empty lines (#10516 by @eemeli & @thorn0) - -Prettier couldn't parse this valid YAML. Thanks to Eemeli Aro for fixing this bug in the underlying parser. - - -```yaml -# Input -key1: &default - - subkey1: value1 - -key2: - <<: *default - -# Prettier stable -SyntaxError: Nested mappings are not allowed in compact mappings (1:7) - -# Prettier main -key1: &default - subkey1: value1 - -key2: - <<: *default -```