Skip to content

Commit 29f299f

Browse files
author
Sosuke Suzuki
committed
Release 3.2.0
1 parent c9fc23e commit 29f299f

8 files changed

Lines changed: 57 additions & 37 deletions

File tree

.github/ISSUE_TEMPLATE/formatting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Don't fill the form below manually! Let a program create a report for you:
2626
2727
-->
2828

29-
**Prettier 3.1.1**
29+
**Prettier 3.2.0**
3030
[Playground link](https://prettier.io/playground/#.....)
3131

3232
```sh

.github/ISSUE_TEMPLATE/integration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ BEFORE SUBMITTING AN ISSUE:
2020

2121
**Environments:**
2222

23-
- Prettier Version: 3.1.1
23+
- Prettier Version: 3.2.0
2424
- Running Prettier via: <!-- CLI, Node.js API, Browser API, etc. -->
2525
- Runtime: <!-- Node.js v14, Chrome v83, etc. -->
2626
- Operating System: <!-- Windows, Linux, macOS, etc. -->

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 3.2.0
2+
3+
[diff](https://github.com/prettier/prettier/compare/3.1.1...3.2.0)
4+
5+
🔗 [Release Notes](https://prettier.io/blog/2024/01/13/3.2.0.html)
6+
17
# 3.1.1
28

39
[diff](https://github.com/prettier/prettier/compare/3.1.0...3.1.1)

docs/browser.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Required options:
1818

1919
- **[`parser`](options.md#parser) (or [`filepath`](options.md#file-path))**: One of these options has to be specified for Prettier to know which parser to use.
2020

21-
- **`plugins`**: Unlike the `format` function from the [Node.js-based API](api.md#prettierformatsource--options), this function doesn’t load plugins automatically. The `plugins` option is required because all the parsers included in the Prettier package come as plugins (for reasons of file size). These plugins are files in <https://unpkg.com/browse/prettier@3.1.1/plugins/>. Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON.
21+
- **`plugins`**: Unlike the `format` function from the [Node.js-based API](api.md#prettierformatsource--options), this function doesn’t load plugins automatically. The `plugins` option is required because all the parsers included in the Prettier package come as plugins (for reasons of file size). These plugins are files in <https://unpkg.com/browse/prettier@3.2.0/plugins/>. Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON.
2222

2323
You need to load the ones that you’re going to use and pass them to `prettier.format` using the `plugins` option.
2424

@@ -29,8 +29,8 @@ See below for examples.
2929
### Global
3030

3131
```html
32-
<script src="https://unpkg.com/prettier@3.1.1/standalone.js"></script>
33-
<script src="https://unpkg.com/prettier@3.1.1/plugins/graphql.js"></script>
32+
<script src="https://unpkg.com/prettier@3.2.0/standalone.js"></script>
33+
<script src="https://unpkg.com/prettier@3.2.0/plugins/graphql.js"></script>
3434
<script>
3535
(async () => {
3636
const formatted = await prettier.format("type Query { hello: String }", {
@@ -47,8 +47,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
4747

4848
```html
4949
<script type="module">
50-
import * as prettier from "https://unpkg.com/prettier@3.1.1/standalone.mjs";
51-
import prettierPluginGraphql from "https://unpkg.com/prettier@3.1.1/plugins/graphql.mjs";
50+
import * as prettier from "https://unpkg.com/prettier@3.2.0/standalone.mjs";
51+
import prettierPluginGraphql from "https://unpkg.com/prettier@3.2.0/plugins/graphql.mjs";
5252
5353
const formatted = await prettier.format("type Query { hello: String }", {
5454
parser: "graphql",
@@ -61,8 +61,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
6161

6262
```js
6363
define([
64-
"https://unpkg.com/prettier@3.1.1/standalone.js",
65-
"https://unpkg.com/prettier@3.1.1/plugins/graphql.js",
64+
"https://unpkg.com/prettier@3.2.0/standalone.js",
65+
"https://unpkg.com/prettier@3.2.0/plugins/graphql.js",
6666
], async (prettier, ...plugins) => {
6767
const formatted = await prettier.format("type Query { hello: String }", {
6868
parser: "graphql",
@@ -90,8 +90,8 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
9090
### Worker
9191

9292
```js
93-
importScripts("https://unpkg.com/prettier@3.1.1/standalone.js");
94-
importScripts("https://unpkg.com/prettier@3.1.1/plugins/graphql.js");
93+
importScripts("https://unpkg.com/prettier@3.2.0/standalone.js");
94+
importScripts("https://unpkg.com/prettier@3.2.0/plugins/graphql.js");
9595

9696
(async () => {
9797
const formatted = await prettier.format("type Query { hello: String }", {
@@ -107,9 +107,9 @@ If you want to format [embedded code](options.md#embedded-language-formatting),
107107

108108
```html
109109
<script type="module">
110-
import * as prettier from "https://unpkg.com/prettier@3.1.1/standalone.mjs";
111-
import prettierPluginBabel from "https://unpkg.com/prettier@3.1.1/plugins/babel.mjs";
112-
import prettierPluginEstree from "https://unpkg.com/prettier@3.1.1/plugins/estree.mjs";
110+
import * as prettier from "https://unpkg.com/prettier@3.2.0/standalone.mjs";
111+
import prettierPluginBabel from "https://unpkg.com/prettier@3.2.0/plugins/babel.mjs";
112+
import prettierPluginEstree from "https://unpkg.com/prettier@3.2.0/plugins/estree.mjs";
113113
114114
console.log(
115115
await prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
@@ -125,10 +125,10 @@ The HTML code embedded in JavaScript stays unformatted because the `html` parser
125125

126126
```html
127127
<script type="module">
128-
import * as prettier from "https://unpkg.com/prettier@3.1.1/standalone.mjs";
129-
import prettierPluginBabel from "https://unpkg.com/prettier@3.1.1/plugins/babel.mjs";
130-
import prettierPluginEstree from "https://unpkg.com/prettier@3.1.1/plugins/estree.mjs";
131-
import prettierPluginHtml from "https://unpkg.com/prettier@3.1.1/plugins/html.mjs";
128+
import * as prettier from "https://unpkg.com/prettier@3.2.0/standalone.mjs";
129+
import prettierPluginBabel from "https://unpkg.com/prettier@3.2.0/plugins/babel.mjs";
130+
import prettierPluginEstree from "https://unpkg.com/prettier@3.2.0/plugins/estree.mjs";
131+
import prettierPluginHtml from "https://unpkg.com/prettier@3.2.0/plugins/html.mjs";
132132
133133
console.log(
134134
await prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "prettier",
3-
"version": "3.2.0-dev",
3+
"version": "3.2.0",
44
"description": "Prettier is an opinionated code formatter",
55
"bin": "./bin/prettier.cjs",
66
"repository": "prettier/prettier",

website/versioned_docs/version-stable/browser.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Required options:
1919

2020
- **[`parser`](options.md#parser) (or [`filepath`](options.md#file-path))**: One of these options has to be specified for Prettier to know which parser to use.
2121

22-
- **`plugins`**: Unlike the `format` function from the [Node.js-based API](api.md#prettierformatsource--options), this function doesn’t load plugins automatically. The `plugins` option is required because all the parsers included in the Prettier package come as plugins (for reasons of file size). These plugins are files in <https://unpkg.com/browse/prettier@3.1.1/plugins/>. Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON.
22+
- **`plugins`**: Unlike the `format` function from the [Node.js-based API](api.md#prettierformatsource--options), this function doesn’t load plugins automatically. The `plugins` option is required because all the parsers included in the Prettier package come as plugins (for reasons of file size). These plugins are files in <https://unpkg.com/browse/prettier@3.2.0/plugins/>. Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON.
2323

2424
You need to load the ones that you’re going to use and pass them to `prettier.format` using the `plugins` option.
2525

@@ -30,8 +30,8 @@ See below for examples.
3030
### Global
3131

3232
```html
33-
<script src="https://unpkg.com/prettier@3.1.1/standalone.js"></script>
34-
<script src="https://unpkg.com/prettier@3.1.1/plugins/graphql.js"></script>
33+
<script src="https://unpkg.com/prettier@3.2.0/standalone.js"></script>
34+
<script src="https://unpkg.com/prettier@3.2.0/plugins/graphql.js"></script>
3535
<script>
3636
(async () => {
3737
const formatted = await prettier.format("type Query { hello: String }", {
@@ -48,8 +48,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
4848

4949
```html
5050
<script type="module">
51-
import * as prettier from "https://unpkg.com/prettier@3.1.1/standalone.mjs";
52-
import prettierPluginGraphql from "https://unpkg.com/prettier@3.1.1/plugins/graphql.mjs";
51+
import * as prettier from "https://unpkg.com/prettier@3.2.0/standalone.mjs";
52+
import prettierPluginGraphql from "https://unpkg.com/prettier@3.2.0/plugins/graphql.mjs";
5353
5454
const formatted = await prettier.format("type Query { hello: String }", {
5555
parser: "graphql",
@@ -62,8 +62,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
6262

6363
```js
6464
define([
65-
"https://unpkg.com/prettier@3.1.1/standalone.js",
66-
"https://unpkg.com/prettier@3.1.1/plugins/graphql.js",
65+
"https://unpkg.com/prettier@3.2.0/standalone.js",
66+
"https://unpkg.com/prettier@3.2.0/plugins/graphql.js",
6767
], async (prettier, ...plugins) => {
6868
const formatted = await prettier.format("type Query { hello: String }", {
6969
parser: "graphql",
@@ -91,8 +91,8 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
9191
### Worker
9292

9393
```js
94-
importScripts("https://unpkg.com/prettier@3.1.1/standalone.js");
95-
importScripts("https://unpkg.com/prettier@3.1.1/plugins/graphql.js");
94+
importScripts("https://unpkg.com/prettier@3.2.0/standalone.js");
95+
importScripts("https://unpkg.com/prettier@3.2.0/plugins/graphql.js");
9696

9797
(async () => {
9898
const formatted = await prettier.format("type Query { hello: String }", {
@@ -108,9 +108,9 @@ If you want to format [embedded code](options.md#embedded-language-formatting),
108108

109109
```html
110110
<script type="module">
111-
import * as prettier from "https://unpkg.com/prettier@3.1.1/standalone.mjs";
112-
import prettierPluginBabel from "https://unpkg.com/prettier@3.1.1/plugins/babel.mjs";
113-
import prettierPluginEstree from "https://unpkg.com/prettier@3.1.1/plugins/estree.mjs";
111+
import * as prettier from "https://unpkg.com/prettier@3.2.0/standalone.mjs";
112+
import prettierPluginBabel from "https://unpkg.com/prettier@3.2.0/plugins/babel.mjs";
113+
import prettierPluginEstree from "https://unpkg.com/prettier@3.2.0/plugins/estree.mjs";
114114
115115
console.log(
116116
await prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
@@ -126,10 +126,10 @@ The HTML code embedded in JavaScript stays unformatted because the `html` parser
126126

127127
```html
128128
<script type="module">
129-
import * as prettier from "https://unpkg.com/prettier@3.1.1/standalone.mjs";
130-
import prettierPluginBabel from "https://unpkg.com/prettier@3.1.1/plugins/babel.mjs";
131-
import prettierPluginEstree from "https://unpkg.com/prettier@3.1.1/plugins/estree.mjs";
132-
import prettierPluginHtml from "https://unpkg.com/prettier@3.1.1/plugins/html.mjs";
129+
import * as prettier from "https://unpkg.com/prettier@3.2.0/standalone.mjs";
130+
import prettierPluginBabel from "https://unpkg.com/prettier@3.2.0/plugins/babel.mjs";
131+
import prettierPluginEstree from "https://unpkg.com/prettier@3.2.0/plugins/estree.mjs";
132+
import prettierPluginHtml from "https://unpkg.com/prettier@3.2.0/plugins/html.mjs";
133133
134134
console.log(
135135
await prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {

website/versioned_docs/version-stable/options.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ Note that Prettier never unquotes numeric property names in Angular expressions,
116116
[quote-props-flow]: https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVBjOA7AzgFzAA8wBeMAb1TDAAYAuMARlQF8g
117117
[quote-props-vue]: https://github.com/prettier/prettier/issues/10127
118118

119-
If this option is set to `preserve`, `singleQuote` to `false` (default value), and `parser` to `json5`, double quotes are always used for strings. This effectively allows using the `json5` parser for “JSON with comments and trailing commas”.
120-
121119
## JSX Quotes
122120

123121
Use single quotes instead of double quotes in JSX.
@@ -283,6 +281,7 @@ Valid options:
283281
- `"less"` (via [postcss-less](https://github.com/shellscape/postcss-less)) _First available in v1.7.1_
284282
- `"json"` (via [@babel/parser parseExpression](https://babeljs.io/docs/en/next/babel-parser.html#babelparserparseexpressioncode-options)) _First available in v1.5.0_
285283
- `"json5"` (same parser as `"json"`, but outputs as [json5](https://json5.org/)) _First available in v1.13.0_
284+
- `"jsonc"` (same parser as `"json"`, but outputs as "JSON with Comments") _First available in v3.2.0_
286285
- `"json-stringify"` (same parser as `"json"`, but outputs like `JSON.stringify`) _First available in v1.13.0_
287286
- `"graphql"` (via [graphql/language](https://github.com/graphql/graphql-js/tree/master/src/language)) _First available in v1.5.0_
288287
- `"markdown"` (via [remark-parse](https://github.com/wooorm/remark/tree/main/packages/remark-parse)) _First available in v1.8.0_

website/versioned_docs/version-stable/rationale.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ One final thing: TC39 has [not yet decided if decorators come before or after `e
144144
export @decorator class Foo {}
145145
```
146146

147+
### Template literals
148+
149+
Template literals can contain interpolations. Deciding whether it's appropriate to insert a linebreak within an interpolation unfortunately depends on the semantic content of the template - for example, introducing a linebreak in the middle of a natural-language sentence is usually undesirable. Since Prettier doesn't have enough information to make this decision itself, it uses a heuristic similar to that used for objects: it will only split an interpolation expression across multiple lines if there was already a linebreak within that interpolation.
150+
151+
This means that a literal like the following will not be broken onto multiple lines, even if it exceeds the print width:
152+
153+
<!-- prettier-ignore -->
154+
```js
155+
`this is a long message which contains an interpolation: ${format(data)} <- like this`;
156+
```
157+
158+
If you want Prettier to split up an interpolation, you'll need to ensure there's a linebreak somewhere within the `${...}`. Otherwise it will keep everything on a single line, no matter how long it is.
159+
160+
The team would prefer not to depend on the original formatting in this way, but it's the best heuristic we have at the moment.
161+
147162
### Semicolons
148163

149164
This is about using the [noSemi](options.md#semicolons) option.

0 commit comments

Comments
 (0)