Skip to content

Commit 7584432

Browse files
committed
Release 3.5.0
1 parent 4797054 commit 7584432

File tree

9 files changed

+112
-26
lines changed

9 files changed

+112
-26
lines changed

.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.4.2**
29+
**Prettier 3.5.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.4.2
23+
- Prettier Version: 3.5.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.5.0
2+
3+
[diff](https://github.com/prettier/prettier/compare/3.4.2...3.5.0)
4+
5+
🔗 [Release Notes](https://prettier.io/blog/2025/02/09/3.5.0.html)
6+
17
# 3.4.2
28

39
[diff](https://github.com/prettier/prettier/compare/3.4.1...3.4.2)

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.5.0-dev",
3+
"version": "3.5.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
@@ -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.4.2/plugins](https://unpkg.com/browse/prettier@3.4.2/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.5.0/plugins](https://unpkg.com/browse/prettier@3.5.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.4.2/standalone.js"></script>
33-
<script src="https://unpkg.com/prettier@3.4.2/plugins/graphql.js"></script>
32+
<script src="https://unpkg.com/prettier@3.5.0/standalone.js"></script>
33+
<script src="https://unpkg.com/prettier@3.5.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.4.2/standalone.mjs";
51-
import prettierPluginGraphql from "https://unpkg.com/prettier@3.4.2/plugins/graphql.mjs";
50+
import * as prettier from "https://unpkg.com/prettier@3.5.0/standalone.mjs";
51+
import prettierPluginGraphql from "https://unpkg.com/prettier@3.5.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.4.2/standalone.js",
65-
"https://unpkg.com/prettier@3.4.2/plugins/graphql.js",
64+
"https://unpkg.com/prettier@3.5.0/standalone.js",
65+
"https://unpkg.com/prettier@3.5.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.4.2/standalone.js");
94-
importScripts("https://unpkg.com/prettier@3.4.2/plugins/graphql.js");
93+
importScripts("https://unpkg.com/prettier@3.5.0/standalone.js");
94+
importScripts("https://unpkg.com/prettier@3.5.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.4.2/standalone.mjs";
111-
import prettierPluginBabel from "https://unpkg.com/prettier@3.4.2/plugins/babel.mjs";
112-
import prettierPluginEstree from "https://unpkg.com/prettier@3.4.2/plugins/estree.mjs";
110+
import * as prettier from "https://unpkg.com/prettier@3.5.0/standalone.mjs";
111+
import prettierPluginBabel from "https://unpkg.com/prettier@3.5.0/plugins/babel.mjs";
112+
import prettierPluginEstree from "https://unpkg.com/prettier@3.5.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.4.2/standalone.mjs";
129-
import prettierPluginBabel from "https://unpkg.com/prettier@3.4.2/plugins/babel.mjs";
130-
import prettierPluginEstree from "https://unpkg.com/prettier@3.4.2/plugins/estree.mjs";
131-
import prettierPluginHtml from "https://unpkg.com/prettier@3.4.2/plugins/html.mjs";
128+
import * as prettier from "https://unpkg.com/prettier@3.5.0/standalone.mjs";
129+
import prettierPluginBabel from "https://unpkg.com/prettier@3.5.0/plugins/babel.mjs";
130+
import prettierPluginEstree from "https://unpkg.com/prettier@3.5.0/plugins/estree.mjs";
131+
import prettierPluginHtml from "https://unpkg.com/prettier@3.5.0/plugins/html.mjs";
132132
133133
console.log(
134134
await prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {

website/versioned_docs/version-stable/configuration.md

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,37 @@ You can configure Prettier via (in order of precedence):
88
- A `"prettier"` key in your `package.json`, or [`package.yaml`](https://github.com/pnpm/pnpm/pull/1799) file.
99
- A `.prettierrc` file written in JSON or YAML.
1010
- A `.prettierrc.json`, `.prettierrc.yml`, `.prettierrc.yaml`, or `.prettierrc.json5` file.
11-
- A `.prettierrc.js`, or `prettier.config.js` file that exports an object using `export default` or `module.exports` (depends on the [`type`](https://nodejs.org/api/packages.html#type) value in your `package.json`).
12-
- A `.prettierrc.mjs`, or `prettier.config.mjs` file that exports an object using `export default`.
13-
- A `.prettierrc.cjs`, or `prettier.config.cjs` file that exports an object using `module.exports`.
11+
- A `.prettierrc.js`, `prettier.config.js`, `.prettierrc.ts`, or `prettier.config.ts` file that exports an object using `export default` or `module.exports` (depends on the [`type`](https://nodejs.org/api/packages.html#type) value in your `package.json`).
12+
- A `.prettierrc.mjs`, `prettier.config.mjs`, `.prettierrc.mts`, or `prettier.config.mts` file that exports an object using `export default`.
13+
- A `.prettierrc.cjs`, `prettier.config.cjs`, `.prettierrc.cts`, or `prettier.config.cts` file that exports an object using `module.exports`.
1414
- A `.prettierrc.toml` file.
1515

16+
:::info
17+
18+
TypeScript configuration files support requires [additional setup](#typescript-configuration-files)
19+
20+
:::
21+
1622
The configuration file will be resolved starting from the location of the file being formatted, and searching up the file tree until a config file is (or isn’t) found.
1723

1824
Prettier intentionally doesn’t support any kind of global configuration. This is to make sure that when a project is copied to another computer, Prettier’s behavior stays the same. Otherwise, Prettier wouldn’t be able to guarantee that everybody in a team gets the same consistent results.
1925

2026
The options you can use in the configuration file are the same as the [API options](options.md).
2127

28+
### TypeScript Configuration Files
29+
30+
TypeScript support for Node.js is currently experimental, Node.js>=22.6.0 is required and `--experimental-strip-types` is required to run Node.js.
31+
32+
```sh
33+
node --experimental-strip-types node_modules/prettier/bin/prettier.cjs . --write
34+
```
35+
36+
or
37+
38+
```sh
39+
NODE_OPTIONS="--experimental-strip-types" prettier . --write
40+
```
41+
2242
## Basic Configuration
2343

2444
JSON:
@@ -70,6 +90,34 @@ const config = {
7090
module.exports = config;
7191
```
7292

93+
TypeScript (ES Modules):
94+
95+
```ts
96+
// prettier.config.ts, .prettierrc.ts, prettier.config.mts, or .prettierrc.mts
97+
98+
import { type Config } from "prettier";
99+
100+
const config: Config = {
101+
trailingComma: "none",
102+
};
103+
104+
export default config;
105+
```
106+
107+
TypeScript (CommonJS):
108+
109+
```ts
110+
// prettier.config.ts, .prettierrc.ts, prettier.config.cts, or .prettierrc.cts
111+
112+
import { type Config } from "prettier";
113+
114+
const config: Config = {
115+
trailingComma: "none",
116+
};
117+
118+
module.exports = config;
119+
```
120+
73121
YAML:
74122

75123
```yaml
@@ -171,7 +219,7 @@ You can also switch to the `flow` parser instead of the default `babel` for .js
171219

172220
## Configuration Schema
173221

174-
If you’d like a JSON schema to validate your configuration, one is available here: https://json.schemastore.org/prettierrc.
222+
If you’d like a JSON schema to validate your configuration, one is available here: [https://json.schemastore.org/prettierrc](https://json.schemastore.org/prettierrc).
175223

176224
## EditorConfig
177225

website/versioned_docs/version-stable/ignore.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ This type of ignore is only allowed to be used in top-level and aimed to disable
145145
<!-- prettier-ignore-end -->
146146
```
147147

148+
**Important:** You must have a blank line before `<!-- prettier-ignore-start -->` and `<!-- prettier-ignore-end -->` for Prettier to recognize the comments.
149+
148150
## YAML
149151

150152
To ignore a part of a YAML file, `# prettier-ignore` should be placed on the line immediately above the ignored node:

website/versioned_docs/version-stable/options.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ Valid options:
2222
| ------- | -------------------------- | ------------------------------- |
2323
| `false` | `--experimental-ternaries` | `experimentalTernaries: <bool>` |
2424

25+
## Experimental Operator Position
26+
27+
Valid options:
28+
29+
- `"start"` - When binary expressions wrap lines, print operators at the start of new lines.
30+
- `"end"` - Default behavior; when binary expressions wrap lines, print operators at the end of previous lines.
31+
32+
| Default | CLI Override | API Override |
33+
| ------- | --------------------------------------------------------------- | -------------------------------------------------------------- |
34+
| `"end"` | <code>--experimental-operator-position \<start&#124;end></code> | <code>experimentalOperatorPosition: "\<start&#124;end>"</code> |
35+
2536
## Print Width
2637

2738
Specify the line length that the printer will wrap on.
@@ -156,6 +167,23 @@ Valid options:
156167
| ------- | ---------------------- | ------------------------ |
157168
| `true` | `--no-bracket-spacing` | `bracketSpacing: <bool>` |
158169

170+
## Object Wrap
171+
172+
_First available in v3.5.0_
173+
174+
Configure how Prettier wraps object literals when they could fit on one line or span multiple lines.
175+
176+
By default, Prettier formats objects as multi-line if there is a newline prior to the first property. Authors can use this heuristic to contextually improve readability, though it has some downsides. See [Multi-line objects](rationale.md#multi-line-objects).
177+
178+
Valid options:
179+
180+
- `"preserve"` - Keep as multi-line, if there is a newline between the opening brace and first property.
181+
- `"collapse"` - Fit to a single line when possible.
182+
183+
| Default | CLI Override | API Override |
184+
| ------------ | ---------------------------------------------------- | ---------------------------------------------------- |
185+
| `"preserve"` | <code>--object-wrap \<preserve&#124;collapse></code> | <code>objectWrap: "\<preserve&#124;collapse>"</code> |
186+
159187
## Bracket Line
160188

161189
Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being alone on the next line (does not apply to self closing elements).

website/versioned_docs/version-stable/rationale.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ It turns out that empty lines are very hard to automatically generate. The appro
2929

3030
### Multi-line objects
3131

32-
By default, Prettier’s printing algorithm prints expressions on a single line if they fit. Objects are used for a lot of different things in JavaScript, though, and sometimes it really helps readability if they stay multiline. See [object lists], [nested configs], [stylesheets] and [keyed methods], for example. We haven’t been able to find a good rule for all those cases, so Prettier instead keeps objects multiline if there’s a newline between the `{` and the first key in the original source code. A consequence of this is that long singleline objects are automatically expanded, but short multiline objects are never collapsed.
32+
By default, Prettier’s printing algorithm prints expressions on a single line if they fit. Objects are used for a lot of different things in JavaScript, though, and sometimes it really helps readability if they stay multiline. See [object lists], [nested configs], [stylesheets] and [keyed methods], for example. We haven’t been able to find a good rule for all those cases, so by default Prettier keeps objects multi-line if there’s a newline between the `{` and the first key in the original source code. Consequently, long single-line objects are automatically expanded, but short multi-line objects are never collapsed.
3333

34-
**Tip:** If you have a multiline object that you’d like to join up into a single line:
34+
You can disable this conditional behavior with the [`objectWrap`](options.md#object-wrap) option.
35+
36+
**Tip:** If you have a multi-line object that you’d like to join up into a single line:
3537

3638
```js
3739
const user = {
@@ -55,7 +57,7 @@ const user = { name: "John Doe",
5557
const user = { name: "John Doe", age: 30 };
5658
```
5759

58-
And if you’d like to go multiline again, add in a newline after `{`:
60+
And if you’d like to go multi-line again, add in a newline after `{`:
5961

6062
<!-- prettier-ignore -->
6163
```js

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy