Skip to content

Commit dcc0623

Browse files
committed
Release 2.8.0
1 parent 7f74981 commit dcc0623

File tree

11 files changed

+76
-40
lines changed

11 files changed

+76
-40
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 2.7.1**
29+
**Prettier 2.8.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: 2.7.1
23+
- Prettier Version: 2.8.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+
# 2.8.0
2+
3+
[diff](https://github.com/prettier/prettier/compare/2.7.1...2.8.0)
4+
5+
🔗 [Release Notes](https://prettier.io/blog/2022/11/23/2.8.0.html)
6+
17
# 2.7.1
28

39
[diff](https://github.com/prettier/prettier/compare/2.7.0...2.7.1)

docs/browser.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Required options:
2020

2121
- **`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 named
2222

23-
- `parser-*.js` in <https://unpkg.com/browse/prettier@2.7.1/> and
24-
- `parser-*.mjs` in <https://unpkg.com/browse/prettier@2.7.1/esm/>
23+
- `parser-*.js` in <https://unpkg.com/browse/prettier@2.8.0/> and
24+
- `parser-*.mjs` in <https://unpkg.com/browse/prettier@2.8.0/esm/>
2525

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

@@ -32,8 +32,8 @@ See below for examples.
3232
### Global
3333

3434
```html
35-
<script src="https://unpkg.com/prettier@2.7.1/standalone.js"></script>
36-
<script src="https://unpkg.com/prettier@2.7.1/parser-graphql.js"></script>
35+
<script src="https://unpkg.com/prettier@2.8.0/standalone.js"></script>
36+
<script src="https://unpkg.com/prettier@2.8.0/parser-graphql.js"></script>
3737
<script>
3838
prettier.format("type Query { hello: String }", {
3939
parser: "graphql",
@@ -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 prettier from "https://unpkg.com/prettier@2.7.1/esm/standalone.mjs";
52-
import parserGraphql from "https://unpkg.com/prettier@2.7.1/esm/parser-graphql.mjs";
51+
import prettier from "https://unpkg.com/prettier@2.8.0/esm/standalone.mjs";
52+
import parserGraphql from "https://unpkg.com/prettier@2.8.0/esm/parser-graphql.mjs";
5353
5454
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@2.7.1/standalone.js",
66-
"https://unpkg.com/prettier@2.7.1/parser-graphql.js",
65+
"https://unpkg.com/prettier@2.8.0/standalone.js",
66+
"https://unpkg.com/prettier@2.8.0/parser-graphql.js",
6767
], (prettier, ...plugins) => {
6868
prettier.format("type Query { hello: String }", {
6969
parser: "graphql",
@@ -88,8 +88,8 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
8888
### Worker
8989

9090
```js
91-
importScripts("https://unpkg.com/prettier@2.7.1/standalone.js");
92-
importScripts("https://unpkg.com/prettier@2.7.1/parser-graphql.js");
91+
importScripts("https://unpkg.com/prettier@2.8.0/standalone.js");
92+
importScripts("https://unpkg.com/prettier@2.8.0/parser-graphql.js");
9393
prettier.format("type Query { hello: String }", {
9494
parser: "graphql",
9595
plugins: prettierPlugins,
@@ -102,8 +102,8 @@ If you want to format [embedded code](options.md#embedded-language-formatting),
102102

103103
```html
104104
<script type="module">
105-
import prettier from "https://unpkg.com/prettier@2.7.1/esm/standalone.mjs";
106-
import parserBabel from "https://unpkg.com/prettier@2.7.1/esm/parser-babel.mjs";
105+
import prettier from "https://unpkg.com/prettier@2.8.0/esm/standalone.mjs";
106+
import parserBabel from "https://unpkg.com/prettier@2.8.0/esm/parser-babel.mjs";
107107
108108
console.log(
109109
prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
@@ -119,9 +119,9 @@ The HTML code embedded in JavaScript stays unformatted because the `html` parser
119119

120120
```html
121121
<script type="module">
122-
import prettier from "https://unpkg.com/prettier@2.7.1/esm/standalone.mjs";
123-
import parserBabel from "https://unpkg.com/prettier@2.7.1/esm/parser-babel.mjs";
124-
import parserHtml from "https://unpkg.com/prettier@2.7.1/esm/parser-html.mjs";
122+
import prettier from "https://unpkg.com/prettier@2.8.0/esm/standalone.mjs";
123+
import parserBabel from "https://unpkg.com/prettier@2.8.0/esm/parser-babel.mjs";
124+
import parserHtml from "https://unpkg.com/prettier@2.8.0/esm/parser-html.mjs";
125125
126126
console.log(
127127
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": "2.8.0-dev",
3+
"version": "2.8.0",
44
"description": "Prettier is an opinionated code formatter",
55
"bin": "./bin/prettier.js",
66
"repository": "prettier/prettier",

website/versioned_docs/version-stable/browser.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Required options:
2121

2222
- **`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 named
2323

24-
- `parser-*.js` in <https://unpkg.com/browse/prettier@2.7.1/> and
25-
- `parser-*.mjs` in <https://unpkg.com/browse/prettier@2.7.1/esm/>
24+
- `parser-*.js` in <https://unpkg.com/browse/prettier@2.8.0/> and
25+
- `parser-*.mjs` in <https://unpkg.com/browse/prettier@2.8.0/esm/>
2626

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

@@ -33,8 +33,8 @@ See below for examples.
3333
### Global
3434

3535
```html
36-
<script src="https://unpkg.com/prettier@2.7.1/standalone.js"></script>
37-
<script src="https://unpkg.com/prettier@2.7.1/parser-graphql.js"></script>
36+
<script src="https://unpkg.com/prettier@2.8.0/standalone.js"></script>
37+
<script src="https://unpkg.com/prettier@2.8.0/parser-graphql.js"></script>
3838
<script>
3939
prettier.format("type Query { hello: String }", {
4040
parser: "graphql",
@@ -49,8 +49,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
4949

5050
```html
5151
<script type="module">
52-
import prettier from "https://unpkg.com/prettier@2.7.1/esm/standalone.mjs";
53-
import parserGraphql from "https://unpkg.com/prettier@2.7.1/esm/parser-graphql.mjs";
52+
import prettier from "https://unpkg.com/prettier@2.8.0/esm/standalone.mjs";
53+
import parserGraphql from "https://unpkg.com/prettier@2.8.0/esm/parser-graphql.mjs";
5454
5555
prettier.format("type Query { hello: String }", {
5656
parser: "graphql",
@@ -63,8 +63,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
6363

6464
```js
6565
define([
66-
"https://unpkg.com/prettier@2.7.1/standalone.js",
67-
"https://unpkg.com/prettier@2.7.1/parser-graphql.js",
66+
"https://unpkg.com/prettier@2.8.0/standalone.js",
67+
"https://unpkg.com/prettier@2.8.0/parser-graphql.js",
6868
], (prettier, ...plugins) => {
6969
prettier.format("type Query { hello: String }", {
7070
parser: "graphql",
@@ -89,8 +89,8 @@ This syntax doesn’t necessarily work in the browser, but it can be used when b
8989
### Worker
9090

9191
```js
92-
importScripts("https://unpkg.com/prettier@2.7.1/standalone.js");
93-
importScripts("https://unpkg.com/prettier@2.7.1/parser-graphql.js");
92+
importScripts("https://unpkg.com/prettier@2.8.0/standalone.js");
93+
importScripts("https://unpkg.com/prettier@2.8.0/parser-graphql.js");
9494
prettier.format("type Query { hello: String }", {
9595
parser: "graphql",
9696
plugins: prettierPlugins,
@@ -103,8 +103,8 @@ If you want to format [embedded code](options.md#embedded-language-formatting),
103103

104104
```html
105105
<script type="module">
106-
import prettier from "https://unpkg.com/prettier@2.7.1/esm/standalone.mjs";
107-
import parserBabel from "https://unpkg.com/prettier@2.7.1/esm/parser-babel.mjs";
106+
import prettier from "https://unpkg.com/prettier@2.8.0/esm/standalone.mjs";
107+
import parserBabel from "https://unpkg.com/prettier@2.8.0/esm/parser-babel.mjs";
108108
109109
console.log(
110110
prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
@@ -120,9 +120,9 @@ The HTML code embedded in JavaScript stays unformatted because the `html` parser
120120

121121
```html
122122
<script type="module">
123-
import prettier from "https://unpkg.com/prettier@2.7.1/esm/standalone.mjs";
124-
import parserBabel from "https://unpkg.com/prettier@2.7.1/esm/parser-babel.mjs";
125-
import parserHtml from "https://unpkg.com/prettier@2.7.1/esm/parser-html.mjs";
123+
import prettier from "https://unpkg.com/prettier@2.8.0/esm/standalone.mjs";
124+
import parserBabel from "https://unpkg.com/prettier@2.8.0/esm/parser-babel.mjs";
125+
import parserHtml from "https://unpkg.com/prettier@2.8.0/esm/parser-html.mjs";
126126
127127
console.log(
128128
prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {

website/versioned_docs/version-stable/cli.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ Also, since the cache file is stored in `./node_modules/.cache/prettier/.prettie
226226

227227
> Plugins version and implementation are not used as cache keys. We recommend that you delete the cache when updating plugins.
228228
229+
## `--cache-location`
230+
231+
Path to the cache file location used by `--cache` flag. If you don't explicit `--cache-location`, Prettier saves cache file at `./node_modules/.cache/prettier/.prettier-cache`.
232+
233+
If a file path is passed, that file is used as the cache file.
234+
235+
```bash
236+
prettier --write --cache --cache-location=my_cache_file src
237+
```
238+
229239
## `--cache-strategy`
230240

231241
Strategy for the cache to use for detecting changed files. Can be either `metadata` or `content`.

website/versioned_docs/version-stable/install.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ For example, you can do the following to have Prettier run before each commit:
104104
```bash
105105
npm install --save-dev husky lint-staged
106106
npx husky install
107-
npm set-script prepare "husky install"
107+
npm pkg set scripts.prepare="husky install"
108108
npx husky add .husky/pre-commit "npx lint-staged"
109109
```
110110

@@ -113,16 +113,14 @@ For example, you can do the following to have Prettier run before each commit:
113113
```bash
114114
yarn add --dev husky lint-staged
115115
npx husky install
116-
npm set-script prepare "husky install"
116+
npm pkg set scripts.prepare="husky install"
117117
npx husky add .husky/pre-commit "npx lint-staged"
118118
```
119119

120120
> If you use Yarn 2, see https://typicode.github.io/husky/#/?id=yarn-2
121121
122122
<!--END_DOCUSAURUS_CODE_TABS-->
123123

124-
> Note: npm **set-script** command requires at least **npm v7.x**. See https://docs.npmjs.com/cli/v7/commands/npm-set-script.
125-
126124
2. Add the following to your `package.json`:
127125

128126
```json

website/versioned_docs/version-stable/integrating-with-linters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The downsides of those plugins are:
3030
- They are slower than running Prettier directly.
3131
- They’re yet one layer of indirection where things may break.
3232

33-
Finally, we have tools that run `prettier` and then immediately for example `eslint --fix` on files.
33+
Finally, we have tools that run `prettier` and then immediately lint files by running, for example, `eslint --fix` on them.
3434

3535
- [prettier-eslint](https://github.com/prettier/prettier-eslint)
3636
- [prettier-stylelint](https://github.com/hugomrdias/prettier-stylelint)

website/versioned_docs/version-stable/plugins.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,20 @@ To turn off plugin autoloading, use `--no-plugin-search` when using Prettier CLI
5959
## Community Plugins
6060

6161
- [`prettier-plugin-apex`](https://github.com/dangmai/prettier-plugin-apex) by [**@dangmai**](https://github.com/dangmai)
62+
- [`prettier-plugin-astro`](https://github.com/withastro/prettier-plugin-astro) by [**@withastro contributors**](https://github.com/withastro/prettier-plugin-astro/graphs/contributors)
6263
- [`prettier-plugin-elm`](https://github.com/gicentre/prettier-plugin-elm) by [**@giCentre**](https://github.com/gicentre)
6364
- [`prettier-plugin-erb`](https://github.com/adamzapasnik/prettier-plugin-erb) by [**@adamzapasnik**](https://github.com/adamzapasnik)
6465
- [`prettier-plugin-glsl`](https://github.com/NaridaL/glsl-language-toolkit/tree/main/packages/prettier-plugin-glsl) by [**@NaridaL**](https://github.com/NaridaL)
6566
- [`prettier-plugin-go-template`](https://github.com/NiklasPor/prettier-plugin-go-template) by [**@NiklasPor**](https://github.com/NiklasPor)
6667
- [`prettier-plugin-java`](https://github.com/jhipster/prettier-java) by [**@JHipster**](https://github.com/jhipster)
6768
- [`prettier-plugin-jsonata`](https://github.com/Stedi/prettier-plugin-jsonata) by [**@Stedi**](https://github.com/Stedi)
6869
- [`prettier-plugin-kotlin`](https://github.com/Angry-Potato/prettier-plugin-kotlin) by [**@Angry-Potato**](https://github.com/Angry-Potato)
70+
- [`prettier-plugin-motoko`](https://github.com/dfinity/prettier-plugin-motoko) by [**@dfinity**](https://github.com/dfinity)
71+
- [`prettier-plugin-nginx`](https://github.com/joedeandev/prettier-plugin-nginx) by [**@joedeandev**](https://github.com/joedeandev)
72+
- [`prettier-plugin-prisma`](https://github.com/umidbekk/prettier-plugin-prisma) by [**@umidbekk**](https://github.com/umidbekk)
6973
- [`prettier-plugin-properties`](https://github.com/eemeli/prettier-plugin-properties) by [**@eemeli**](https://github.com/eemeli)
70-
- [`prettier-plugin-rust`](https://github.com/jinxdash/prettier-plugin-rust) by [**@jinxdash**](https://github.com/jinxdash)
71-
- [`prettier-plugin-sh`](https://github.com/rx-ts/prettier/tree/master/packages/sh) by [**@JounQin**](https://github.com/JounQin)
74+
- [`prettier-plugin-sh`](https://github.com/un-ts/prettier/tree/master/packages/sh) by [**@JounQin**](https://github.com/JounQin)
75+
- [`prettier-plugin-sql`](https://github.com/un-ts/prettier/tree/master/packages/sql) by [**@JounQin**](https://github.com/JounQin)
7276
- [`prettier-plugin-solidity`](https://github.com/prettier-solidity/prettier-plugin-solidity) by [**@mattiaerre**](https://github.com/mattiaerre)
7377
- [`prettier-plugin-svelte`](https://github.com/UnwrittenFun/prettier-plugin-svelte) by [**@UnwrittenFun**](https://github.com/UnwrittenFun)
7478
- [`prettier-plugin-toml`](https://github.com/bd82/toml-tools/tree/master/packages/prettier-plugin-toml) by [**@bd82**](https://github.com/bd82)
@@ -161,6 +165,7 @@ export const printers = {
161165
canAttachComment,
162166
isBlockComment,
163167
printComment,
168+
getCommentChildNodes,
164169
handleComments: {
165170
ownLine,
166171
endOfLine,
@@ -295,6 +300,21 @@ Comments are often not part of a language's AST and present a challenge for pret
295300

296301
By default, if the AST has a top-level `comments` property, Prettier assumes that `comments` stores an array of comment nodes. Prettier will then use the provided `parsers[<plugin>].locStart`/`locEnd` functions to search for the AST node that each comment "belongs" to. Comments are then attached to these nodes **mutating the AST in the process**, and the `comments` property is deleted from the AST root. The `*Comment` functions are used to adjust Prettier's algorithm. Once the comments are attached to the AST, Prettier will automatically call the `printComment(path, options): Doc` function and insert the returned doc into the (hopefully) correct place.
297302

303+
#### (optional) `getCommentChildNodes`
304+
305+
By default, Prettier searches all object properties (except for a few predefined ones) of each node recursively. This function can be provided to override that behavior. It has the signature:
306+
307+
```ts
308+
function getCommentChildNodes(
309+
// The node whose children should be returned.
310+
node: AST,
311+
// Current options
312+
options: object
313+
): AST[] | undefined;
314+
```
315+
316+
Return `[]` if the node has no children or `undefined` to fall back on the default behavior.
317+
298318
#### (optional) `printComment`
299319

300320
Called whenever a comment node needs to be printed. It has the signature:

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