Clean changelog_unlreleased
This commit is contained in:
1 parent
ba1a833378
commit
171b1ee2bf
78 files changed
-1737
No files matched your search
@@ -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
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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
|
||||
];
|
||||
```
|
||||
@@ -1,3 +0,0 @@
|
||||
#### Add `indentIfBreak` IR command (#10221 by @thorn)
|
||||
|
||||
`indentIfBreak(doc, { groupId })` is an optimized version of `ifBreak(indent(doc), doc, { groupId })`.
|
||||
@@ -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).
|
||||
@@ -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).
|
||||
@@ -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"]);
|
||||
```
|
||||
@@ -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"`.
|
||||
@@ -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!
|
||||
```
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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"
|
||||
```
|
||||
@@ -1,17 +0,0 @@
|
||||
#### Clear printed long filenames of formatting file (#10217 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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!
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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
|
||||
```
|
||||
@@ -1,34 +0,0 @@
|
||||
#### Exclude `@keyframes` params from being parsed as a Less variable (#10773 by @tmazeika)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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);
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```css
|
||||
/* Input */
|
||||
-custom-url(/absolute/path)
|
||||
|
||||
/* Prettier stable */
|
||||
-custom-url(/ absolute/path)
|
||||
|
||||
/* Prettier main */
|
||||
-custom-url(/absolute/path)
|
||||
```
|
||||
@@ -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;
|
||||
|
||||
```
|
||||
@@ -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:
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
declare export function graphql<Props, Variables, Component: React$ComponentType<Props>>
|
||||
// ^^^^^ range 1
|
||||
(query: GQLDocument, config?: Config<Props, QueryConfigOptions<Variables>>):
|
||||
(Component: Component) => React$ComponentType<$Diff<React$ElementConfig<Component>, {
|
||||
data: Object|void,
|
||||
// ^^^^ range 2
|
||||
mutate: Function|void
|
||||
}>>
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
#### Support for Flow's indexed access type (#10594 by @gkz)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
const x: Obj['foo'] = 1;
|
||||
|
||||
// Prettier stable
|
||||
// Error: unsupported node type "IndexedAccessType"
|
||||
|
||||
// Prettier main
|
||||
const x: Obj["foo"] = 1;
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
#### Support for Flow's optional indexed access type (#10788 by @gkz)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
type T = Obj?.['foo'];
|
||||
|
||||
// Prettier stable
|
||||
// Error: unsupported node type "OptionalIndexedAccessType"
|
||||
|
||||
// Prettier main
|
||||
type T = Obj?.['foo'];
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
#### Fix missing semicolon in `declare export * from …` (#9767 by @fisker)
|
||||
|
||||
<!-- Optional description if it makes sense. -->
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
declare export * from "ES6_ExportAllFrom_Source2";
|
||||
|
||||
// Prettier stable
|
||||
declare export * from "ES6_ExportAllFrom_Source2"
|
||||
|
||||
// Prettier main
|
||||
declare export * from "ES6_ExportAllFrom_Source2";
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Fix missing space after keyword in anonymous operations (#10689 by @patriscus)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```graphql
|
||||
# Input
|
||||
query ($unnamed: String) {
|
||||
id
|
||||
}
|
||||
|
||||
# Prettier stable
|
||||
query($unnamed: String) {
|
||||
id
|
||||
}
|
||||
|
||||
# Prettier main
|
||||
query ($unnamed: String) {
|
||||
id
|
||||
}
|
||||
```
|
||||
@@ -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
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```hbs
|
||||
{{!-- Input --}}
|
||||
<div class="
|
||||
foo"></div>
|
||||
<div bar='"{{expr}}"'></div>
|
||||
<div baz="\{{ non-expression }}"></div>
|
||||
|
||||
{{!-- Prettier stable --}}
|
||||
<div class="[object Object],foo"></div>
|
||||
<div bar=""{{expr}}""></div>
|
||||
<div baz="{{ non-expression }}"></div>
|
||||
|
||||
{{!-- Prettier main --}}
|
||||
<div class="foo"></div>
|
||||
<div bar='"{{expr}}"'></div>
|
||||
<div baz="\{{ non-expression }}"></div>
|
||||
```
|
||||
@@ -1,20 +0,0 @@
|
||||
#### Split text content on multiple lines (#10179 by @dcyriller)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```handlebars
|
||||
{{!-- Input --}}
|
||||
<div>
|
||||
A long enough string to trigger a line break that would prevent wrapping more and more.
|
||||
</div>
|
||||
|
||||
{{!-- Prettier stable --}}
|
||||
<div>
|
||||
A long enough string to trigger a line break that would prevent wrapping more and more.
|
||||
</div>
|
||||
|
||||
{{!-- Prettier main --}}
|
||||
<div>
|
||||
A long enough string to trigger a line break that would prevent wrapping more
|
||||
and more.
|
||||
</div>
|
||||
```
|
||||
@@ -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}}<div>{{/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
|
||||
@@ -1,13 +0,0 @@
|
||||
#### Preserve numeric character references (#10550 by @rwjblue and @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```hbs
|
||||
{{! Input }}
|
||||
<span class="stampFont" style="font-family: 'stampfont'"></span>
|
||||
|
||||
{{! Prettier stable }}
|
||||
<span class="stampFont" style="font-family: 'stampfont'"></span>
|
||||
|
||||
{{! Prettier main }}
|
||||
<span class="stampFont" style="font-family: 'stampfont'"></span>
|
||||
```
|
||||
@@ -1,40 +0,0 @@
|
||||
#### Do not break opening mustache and path (#10586 by @dcyriller)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```handlebars
|
||||
{{!-- Input --}}
|
||||
<GlimmerComponent
|
||||
@errors={{or this.aVeryLongProperty (and this.aProperty (v-get bike "number" "message"))}}
|
||||
data-test-beneficiary-account-number
|
||||
/>
|
||||
<GlimmerComponent
|
||||
@progress={{aPropertyEngdingAfterEightiethColumnToHighlightAWeirdClosingParenIssue}}
|
||||
/>
|
||||
|
||||
{{!-- Prettier stable --}}
|
||||
<GlimmerComponent
|
||||
@errors={{
|
||||
or
|
||||
this.aVeryLongProperty
|
||||
(and this.aProperty (v-get bike "number" "message"))
|
||||
}}
|
||||
data-test-beneficiary-account-number
|
||||
/>
|
||||
<GlimmerComponent
|
||||
@progress={{
|
||||
aPropertyEngdingAfterEightiethColumnToHighlightAWeirdClosingParenIssue
|
||||
}}
|
||||
/>
|
||||
|
||||
{{!-- Prettier main --}}
|
||||
<GlimmerComponent
|
||||
@errors={{or
|
||||
this.aLongProperty
|
||||
(and this.aProperty (v-get bike "number" "message"))
|
||||
}}
|
||||
data-test-beneficiary-account-number
|
||||
/>
|
||||
<GlimmerComponent
|
||||
@progress={{aPropertyEngdingAfterEightiethColumnToHighlightAWeirdClosingParenIssue}}
|
||||
/>
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Preserve tilde comments (#9082 by @kangax, @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```hbs
|
||||
{{!-- Input --}}
|
||||
{{~! Comment }}
|
||||
{{! Comment ~}}
|
||||
{{~! Comment ~}}
|
||||
|
||||
{{!-- Prettier stable --}}
|
||||
{{! Comment }}
|
||||
{{! Comment }}
|
||||
{{! Comment }}
|
||||
|
||||
{{!-- Prettier main --}}
|
||||
{{~! Comment }}
|
||||
{{! Comment ~}}
|
||||
{{~! Comment ~}}
|
||||
```
|
||||
@@ -1,45 +0,0 @@
|
||||
#### Add a whitespace sensitive mode (#9885 by @dcyriller)
|
||||
|
||||
```sh
|
||||
--html-whitespace-sensitivity strict
|
||||
```
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```hbs
|
||||
{{!-- Input --}}
|
||||
<span>123 {{mustache}}</span>
|
||||
<span>
|
||||
123 {{mustache}}</span>
|
||||
<span>123 {{mustache}}
|
||||
</span>
|
||||
<span>
|
||||
123 {{mustache}}
|
||||
</span>
|
||||
|
||||
{{!-- Prettier stable --}}
|
||||
<span>
|
||||
123 {{mustache}}
|
||||
</span>
|
||||
<span>
|
||||
123 {{mustache}}
|
||||
</span>
|
||||
<span>
|
||||
123 {{mustache}}
|
||||
</span>
|
||||
<span>
|
||||
123 {{mustache}}
|
||||
</span>
|
||||
|
||||
{{!-- Prettier main --}}
|
||||
<span>123 {{mustache}}</span>
|
||||
<span>
|
||||
123
|
||||
{{mustache}}</span>
|
||||
<span>123
|
||||
{{mustache}}
|
||||
</span>
|
||||
<span>
|
||||
123
|
||||
{{mustache}}
|
||||
</span>
|
||||
```
|
||||
@@ -1,44 +0,0 @@
|
||||
#### Print final `blockParam` on its own line (#9978 by @dcyriller)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```hbs
|
||||
{{!-- Input --}}
|
||||
<MyComponent @prop={{true}} @prop2={{true}} @prop3={{true}} @prop4={{true}} as |thing|></MyComponent>
|
||||
{{#block param hashKey=hashValue hashKey=hashValue hashKey=hashValue as |blockParam|}}
|
||||
Hello
|
||||
{{/block}}
|
||||
|
||||
{{!-- Prettier stable --}}
|
||||
<MyComponent
|
||||
@prop={{true}}
|
||||
@prop2={{true}}
|
||||
@prop3={{true}}
|
||||
@prop4={{true}} as |thing|
|
||||
/>
|
||||
{{#block
|
||||
param
|
||||
hashKey=hashValue
|
||||
hashKey=hashValue
|
||||
hashKey=hashValue as |blockParam|
|
||||
}}
|
||||
Hello
|
||||
{{/block}}
|
||||
|
||||
{{!-- Prettier main --}}
|
||||
<MyComponent
|
||||
@prop={{true}}
|
||||
@prop2={{true}}
|
||||
@prop3={{true}}
|
||||
@prop4={{true}}
|
||||
as |thing|
|
||||
/>
|
||||
{{#block
|
||||
param
|
||||
hashKey=hashValue
|
||||
hashKey=hashValue
|
||||
hashKey=hashValue
|
||||
as |blockParam|
|
||||
}}
|
||||
Hello
|
||||
{{/block}}
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```html
|
||||
<!-- Prettier stable -->
|
||||
<div
|
||||
class="SomeComponent__heading-row d-flex flex-column flex-lg-row justify-content-start justify-content-lg-between align-items-start align-items-lg-center"
|
||||
></div>
|
||||
|
||||
<!-- Prettier main -->
|
||||
<div
|
||||
class="
|
||||
SomeComponent__heading-row
|
||||
d-flex
|
||||
flex-column flex-lg-row
|
||||
justify-content-start justify-content-lg-between
|
||||
align-items-start align-items-lg-center
|
||||
"
|
||||
></div>
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### [IMPROVEMENT:2] Improve visual separation between header and body in classes with multiline headers (#10085 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Prettier stable
|
||||
class loooooooooooooooooooong
|
||||
extends looooooooooooooooooong
|
||||
implements loooooooooooooooooooong {
|
||||
property: string;
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
class loooooooooooooooooooong
|
||||
extends looooooooooooooooooong
|
||||
implements loooooooooooooooooooong
|
||||
{
|
||||
property: string;
|
||||
}
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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,
|
||||
];
|
||||
```
|
||||
@@ -1,51 +0,0 @@
|
||||
#### [IMPROVEMENT:6] Consistent indentation for conditional operators (#10187, #10266 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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;
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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<any> = 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<any> =
|
||||
new BehaviorSubject(notRead);
|
||||
}
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
#### [IMPROVEMENT:1] Improve formatting for React Hooks calls (#10238 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Prettier stable
|
||||
const { firstName, lastName } = useMemo(() => parseFullName(fullName), [
|
||||
fullName,
|
||||
]);
|
||||
|
||||
// Prettier main
|
||||
const { firstName, lastName } = useMemo(
|
||||
() => parseFullName(fullName),
|
||||
[fullName]
|
||||
);
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
#### Fix error thrown on expressions like `a(b => c => function (){})` (#10278 by @thorn0)
|
||||
|
||||
Regression from v2.2.0.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
a(b => c => function (){})
|
||||
|
||||
// Prettier stable
|
||||
TypeError: Cannot read property 'length' of undefined
|
||||
|
||||
// Prettier main
|
||||
a((b) => (c) => function () {});
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
#### Improve formatting for inline decorators (#10296 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
class Foo {
|
||||
@decorator([]) bar() {}
|
||||
@decorator(
|
||||
[]
|
||||
) baz() {}
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
class Foo {
|
||||
@decorator([]) bar() {}
|
||||
@decorator([])
|
||||
baz() {}
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
class Foo {
|
||||
@decorator([]) bar() {}
|
||||
@decorator([]) baz() {}
|
||||
}
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Fix ASI protection for private fields (#10334 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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"]() {}
|
||||
}
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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",
|
||||
};
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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;
|
||||
```
|
||||
@@ -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).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
module { export let foo = "foo"; };
|
||||
|
||||
// Prettier stable
|
||||
SyntaxError: Unexpected token, expected ";"
|
||||
|
||||
// Prettier main
|
||||
module {
|
||||
export let foo = "foo";
|
||||
};
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Fix missing parentheses for `yield` in a pipeline (#10446 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
function* f() {
|
||||
return x |> (yield #);
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
function* f() {
|
||||
return x |> yield #;
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
function* f() {
|
||||
return x |> (yield #);
|
||||
}
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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] | ^
|
||||
```
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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] | ^ ^
|
||||
```
|
||||
@@ -1,33 +0,0 @@
|
||||
#### Avoid last-argument hugging for number-only arrays (#10517 by @thorn0)
|
||||
|
||||
Another special case for number-only arrays.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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]
|
||||
),
|
||||
]);
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Prettier stable
|
||||
const someVariable = define("some string literal", anotherVariable, yetAnotherVariable);
|
||||
|
||||
// Prettier main
|
||||
const someVariable = define(
|
||||
"some string literal",
|
||||
anotherVariable,
|
||||
yetAnotherVariable
|
||||
);
|
||||
```
|
||||
@@ -1,21 +0,0 @@
|
||||
#### Fix duplicated `prettier-ignore` comments (#10666 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
foo = a.
|
||||
// prettier-ignore
|
||||
b;
|
||||
|
||||
// Prettier stable
|
||||
foo =
|
||||
// prettier-ignore
|
||||
a.
|
||||
// prettier-ignore
|
||||
b;
|
||||
|
||||
// Prettier main
|
||||
foo = a.
|
||||
// prettier-ignore
|
||||
b;
|
||||
```
|
||||
@@ -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).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Prettier stable
|
||||
expect(
|
||||
do {
|
||||
var bar = "foo";
|
||||
bar;
|
||||
}
|
||||
).toBe("foo");
|
||||
|
||||
// Prettier main
|
||||
expect(do {
|
||||
var bar = "foo";
|
||||
bar;
|
||||
}).toBe("foo");
|
||||
```
|
||||
@@ -1,40 +0,0 @@
|
||||
#### Process conditional groups in `mapDoc` (#10695 by @thorn0)
|
||||
|
||||
In particular, this fixes broken substitutions in HTML-in-JS.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
export default function include_photoswipe(
|
||||
gallery_selector = ".my-gallery"
|
||||
): string {
|
||||
return /* HTML */ `
|
||||
<script>
|
||||
window.addEventListener("load", () =>
|
||||
initPhotoSwipeFromDOM("${gallery_selector}")
|
||||
);
|
||||
</script>`;
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
export default function include_photoswipe(
|
||||
gallery_selector = ".my-gallery"
|
||||
): string {
|
||||
return /* HTML */ ` <script>
|
||||
window.addEventListener("load", () =>
|
||||
initPhotoSwipeFromDOM("PRETTIER_HTML_PLACEHOLDER_0_13_IN_JS")
|
||||
);
|
||||
</script>`;
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
export default function include_photoswipe(
|
||||
gallery_selector = ".my-gallery"
|
||||
): string {
|
||||
return /* HTML */ ` <script>
|
||||
window.addEventListener("load", () =>
|
||||
initPhotoSwipeFromDOM("${gallery_selector}")
|
||||
);
|
||||
</script>`;
|
||||
}
|
||||
```
|
||||
@@ -1,24 +0,0 @@
|
||||
#### Avoid arg expansion that leads to broken code (#10712 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
glimseGlyphsHazardNoopsTieTie(({ a, b = () => {
|
||||
console.log();
|
||||
}}) => averredBathersBoxroomBuggyNurl());
|
||||
|
||||
// Prettier stable
|
||||
glimseGlyphsHazardNoopsTieTie(({ a, b = () => {
|
||||
console.log();
|
||||
} }) => averredBathersBoxroomBuggyNurl());
|
||||
|
||||
// Prettier main
|
||||
glimseGlyphsHazardNoopsTieTie(
|
||||
({
|
||||
a,
|
||||
b = () => {
|
||||
console.log();
|
||||
},
|
||||
}) => averredBathersBoxroomBuggyNurl()
|
||||
);
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Fix missing parentheses around `async` in `for-of` (#10781 by @fisker)
|
||||
|
||||
See https://github.com/tc39/ecma262/issues/2034
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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 []);
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Support `async do` expressions proposal (#10813 by @sosukesuzuki)
|
||||
|
||||
See https://github.com/tc39/proposal-async-do-expressions
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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();
|
||||
};
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
#### Fix unstable multiple comments on the same line (#9672 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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;
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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;
|
||||
```
|
||||
@@ -1,18 +0,0 @@
|
||||
#### Fix comments inside JSX end tag (#9711 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
<a><// comment
|
||||
/a>;
|
||||
|
||||
// Prettier stable
|
||||
<a></// comment
|
||||
a>;
|
||||
|
||||
// Prettier main
|
||||
<a></
|
||||
// comment
|
||||
a
|
||||
>;
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
foo /* HTML */ = `<DIV>
|
||||
</DIV>`;
|
||||
|
||||
// Prettier stable (--parser=babel)
|
||||
foo /* HTML */ = `<div></div>`;
|
||||
|
||||
// Prettier stable (--parser=meriyah)
|
||||
foo /* HTML */ = `<DIV>
|
||||
</DIV>`;
|
||||
|
||||
// Prettier main (All JavaScript parsers)
|
||||
foo /* HTML */ = `<DIV>
|
||||
</DIV>`;
|
||||
```
|
||||
@@ -1,31 +0,0 @@
|
||||
#### Fix extra semicolon added to ignored directives (#9850 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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";
|
||||
}
|
||||
```
|
||||
@@ -1,29 +0,0 @@
|
||||
#### Fix unstable JSX formatting with U+3000 (#9866 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
<p>
|
||||
<span /> {this.props.data.title} <span />
|
||||
//----- ^ U+3000 --------------- ^ U+3000
|
||||
</p>
|
||||
|
||||
// Prettier stable
|
||||
<p>
|
||||
<span />
|
||||
{this.props.data.title} <span />
|
||||
//----- ^ U+3000 --------------- ^ U+3000
|
||||
</p>;
|
||||
|
||||
// Prettier stable (second format)
|
||||
<p>
|
||||
<span /> {this.props.data.title} <span />
|
||||
//----- ^ U+3000 --------------- ^ U+3000
|
||||
</p>;
|
||||
|
||||
// Prettier main
|
||||
<p>
|
||||
<span /> {this.props.data.title} <span />
|
||||
//----- ^ U+3000 --------------- ^ U+3000
|
||||
</p>;
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### [IMPROVEMENT:0] Refine formatting of curried arrow functions (#9992, #10543 by @sosukesuzuki & @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Prettier stable
|
||||
const currying = (argument1) => (argument2) => (argument3) => (argument4) => (
|
||||
argument5
|
||||
) => (argument6) => foo;
|
||||
|
||||
// Prettier main
|
||||
const currying =
|
||||
(argument1) =>
|
||||
(argument2) =>
|
||||
(argument3) =>
|
||||
(argument4) =>
|
||||
(argument5) =>
|
||||
(argument6) =>
|
||||
foo;
|
||||
```
|
||||
@@ -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".
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
{
|
||||
"char": "\"",
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
{
|
||||
"char": '"',
|
||||
}
|
||||
|
||||
// Prettier main
|
||||
{
|
||||
"char": "\"",
|
||||
}
|
||||
```
|
||||
@@ -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`).
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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]
|
||||
| ^
|
||||
```
|
||||
@@ -1,17 +0,0 @@
|
||||
#### Improve error message (#10433 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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"}
|
||||
| ^^^^^^^^^^^^^
|
||||
```
|
||||
@@ -1,16 +0,0 @@
|
||||
#### Fix syntax error on JSON range formatting (#10497 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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 }]
|
||||
```
|
||||
@@ -1,26 +0,0 @@
|
||||
#### Fix extra newline at the end of JavaScript fenced code block with string literal (#9736 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
````markdown
|
||||
<!-- Input -->
|
||||
Markdown
|
||||
|
||||
```js
|
||||
"· "
|
||||
```
|
||||
|
||||
<!-- Prettier stable -->
|
||||
Markdown
|
||||
|
||||
```js
|
||||
"· ";
|
||||
|
||||
```
|
||||
|
||||
<!-- Prettier main -->
|
||||
Markdown
|
||||
|
||||
```js
|
||||
"· ";
|
||||
```
|
||||
````
|
||||
@@ -1,44 +0,0 @@
|
||||
#### Fix empty front matter formatting (#9791 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
---
|
||||
---
|
||||
|
||||
# Title
|
||||
|
||||
a|b|c|
|
||||
|:--|:-:|--:|
|
||||
|d|e|f|
|
||||
|
||||
---
|
||||
|
||||
text
|
||||
|
||||
<!-- Prettier stable -->
|
||||
---
|
||||
---
|
||||
# Title
|
||||
|
||||
a|b|c|
|
||||
|:--|:-:|--:|
|
||||
|d|e|f|
|
||||
---
|
||||
|
||||
text
|
||||
|
||||
<!-- Prettier main -->
|
||||
---
|
||||
---
|
||||
|
||||
# Title
|
||||
|
||||
| a | b | c |
|
||||
| :-- | :-: | --: |
|
||||
| d | e | f |
|
||||
|
||||
---
|
||||
|
||||
text
|
||||
```
|
||||
@@ -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 `...`.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
---
|
||||
title: Hello
|
||||
slug: home
|
||||
...
|
||||
|
||||
Markdown
|
||||
|
||||
<!-- Prettier stable -->
|
||||
---
|
||||
|
||||
title: Hello
|
||||
slug: home
|
||||
...
|
||||
|
||||
Markdown
|
||||
|
||||
<!-- Prettier main -->
|
||||
---
|
||||
title: Hello
|
||||
slug: home
|
||||
...
|
||||
|
||||
Markdown
|
||||
```
|
||||
@@ -1,17 +0,0 @@
|
||||
#### Fix maps with keys that are lists or maps (#10005 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```scss
|
||||
// Input
|
||||
$map: (
|
||||
('my list'): 'hello world',
|
||||
);
|
||||
|
||||
// Prettier stable
|
||||
TypeError: Cannot read property 'length' of undefined
|
||||
|
||||
// Prettier main
|
||||
$map: (
|
||||
("my list"): "hello world",
|
||||
);
|
||||
```
|
||||
@@ -1,23 +0,0 @@
|
||||
#### Fix broken comment inside parens (#9710 by @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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
|
||||
);
|
||||
}
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
#### Fix unnecessary line breaks in method type declaration parameters (#10024 by @sosukesuzuki, #10357 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
// Input
|
||||
type Foo = {
|
||||
method(foo: "foo"): `
|
||||
`
|
||||
};
|
||||
|
||||
// Prettier stable
|
||||
type Foo = {
|
||||
method(
|
||||
foo: "foo"
|
||||
): `
|
||||
`;
|
||||
};
|
||||
|
||||
// Prettier main
|
||||
type Foo = {
|
||||
method(foo: "foo"): `
|
||||
`;
|
||||
};
|
||||
|
||||
```
|
||||
@@ -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
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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,
|
||||
> {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
@@ -1,16 +0,0 @@
|
||||
#### Allow hugging arguments that are non-concise arrow functions with return type annotations (#10316 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Prettier stable
|
||||
users.map(
|
||||
(user: User): User => {
|
||||
return user;
|
||||
}
|
||||
);
|
||||
|
||||
// Prettier main
|
||||
users.map((user: User): User => {
|
||||
return user;
|
||||
})
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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]!);
|
||||
```
|
||||
@@ -1,22 +0,0 @@
|
||||
#### Indent type assertions in heads of member and call expressions (#10341 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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;
|
||||
```
|
||||
@@ -1,14 +0,0 @@
|
||||
#### Support intrinsic keyword (#10390 by @sosukesuzuki)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
type Uppercase<S extends string> = intrinsic;
|
||||
|
||||
// Prettier stable
|
||||
Error: unknown type: "TSIntrinsicKeyword"
|
||||
|
||||
// Prettier main
|
||||
type Uppercase<S extends string> = intrinsic;
|
||||
|
||||
```
|
||||
@@ -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)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
import type A = require("A");
|
||||
|
||||
// Prettier stable
|
||||
SyntaxError: Only ECMAScript imports may use 'import type'.
|
||||
|
||||
// Prettier main
|
||||
import type A = require("A");
|
||||
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
#### Fix misplaced comments in unions and intersections (#10457 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
type Foo = "1" | "2" /* two */ | "3";
|
||||
|
||||
// Prettier stable
|
||||
type Foo = "1" | "2" | /* two */ "3";
|
||||
|
||||
// Prettier main
|
||||
type Foo = "1" | "2" /* two */ | "3";
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
#### Don’t print parens around nested type assertions (#10702 by @thorn0)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
foo as unknown as Bar
|
||||
|
||||
// Prettier stable
|
||||
(foo as unknown) as Bar;
|
||||
|
||||
// Prettier main
|
||||
foo as unknown as Bar;
|
||||
```
|
||||
@@ -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;
|
||||
}
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
#### Fix missing comments in `MethodDefinition` (#9872 by @fisker)
|
||||
|
||||
`typescript` parser only, `babel-ts` doesn't have this issue.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```typescript
|
||||
// Input
|
||||
class Foo {
|
||||
bar() /* bat */;
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
Error: Comment "bat" was not printed. Please report this error!
|
||||
|
||||
// Prettier main
|
||||
class Foo {
|
||||
bar /* bat */();
|
||||
}
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```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
|
||||
```
|
||||
Reference in new issue
Block a user