You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/browser.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,8 @@ Required options:
20
20
21
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 named
22
22
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/>
25
25
26
26
You need to load the ones that you’re going to use and pass them to `prettier.format` using the `plugins` option.
@@ -48,8 +48,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
@@ -62,8 +62,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
Copy file name to clipboardExpand all lines: website/versioned_docs/version-stable/browser.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,8 +21,8 @@ Required options:
21
21
22
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 named
23
23
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/>
26
26
27
27
You need to load the ones that you’re going to use and pass them to `prettier.format` using the `plugins` option.
@@ -49,8 +49,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
@@ -63,8 +63,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
Copy file name to clipboardExpand all lines: website/versioned_docs/version-stable/cli.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -226,6 +226,16 @@ Also, since the cache file is stored in `./node_modules/.cache/prettier/.prettie
226
226
227
227
> Plugins version and implementation are not used as cache keys. We recommend that you delete the cache when updating plugins.
228
228
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.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-stable/install.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,7 +104,7 @@ For example, you can do the following to have Prettier run before each commit:
104
104
```bash
105
105
npm install --save-dev husky lint-staged
106
106
npx husky install
107
-
npm set-script prepare"husky install"
107
+
npm pkg set scripts.prepare="husky install"
108
108
npx husky add .husky/pre-commit "npx lint-staged"
109
109
```
110
110
@@ -113,16 +113,14 @@ For example, you can do the following to have Prettier run before each commit:
113
113
```bash
114
114
yarn add --dev husky lint-staged
115
115
npx husky install
116
-
npm set-script prepare"husky install"
116
+
npm pkg set scripts.prepare="husky install"
117
117
npx husky add .husky/pre-commit "npx lint-staged"
118
118
```
119
119
120
120
> If you use Yarn 2, see https://typicode.github.io/husky/#/?id=yarn-2
121
121
122
122
<!--END_DOCUSAURUS_CODE_TABS-->
123
123
124
-
> Note: npm **set-script** command requires at least **npm v7.x**. See https://docs.npmjs.com/cli/v7/commands/npm-set-script.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-stable/plugins.md
+22-2Lines changed: 22 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,16 +59,20 @@ To turn off plugin autoloading, use `--no-plugin-search` when using Prettier CLI
59
59
## Community Plugins
60
60
61
61
-[`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)
62
63
-[`prettier-plugin-elm`](https://github.com/gicentre/prettier-plugin-elm) by [**@giCentre**](https://github.com/gicentre)
63
64
-[`prettier-plugin-erb`](https://github.com/adamzapasnik/prettier-plugin-erb) by [**@adamzapasnik**](https://github.com/adamzapasnik)
64
65
-[`prettier-plugin-glsl`](https://github.com/NaridaL/glsl-language-toolkit/tree/main/packages/prettier-plugin-glsl) by [**@NaridaL**](https://github.com/NaridaL)
65
66
-[`prettier-plugin-go-template`](https://github.com/NiklasPor/prettier-plugin-go-template) by [**@NiklasPor**](https://github.com/NiklasPor)
66
67
-[`prettier-plugin-java`](https://github.com/jhipster/prettier-java) by [**@JHipster**](https://github.com/jhipster)
67
68
-[`prettier-plugin-jsonata`](https://github.com/Stedi/prettier-plugin-jsonata) by [**@Stedi**](https://github.com/Stedi)
68
69
-[`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)
69
73
-[`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)
72
76
-[`prettier-plugin-solidity`](https://github.com/prettier-solidity/prettier-plugin-solidity) by [**@mattiaerre**](https://github.com/mattiaerre)
73
77
-[`prettier-plugin-svelte`](https://github.com/UnwrittenFun/prettier-plugin-svelte) by [**@UnwrittenFun**](https://github.com/UnwrittenFun)
74
78
-[`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 = {
161
165
canAttachComment,
162
166
isBlockComment,
163
167
printComment,
168
+
getCommentChildNodes,
164
169
handleComments: {
165
170
ownLine,
166
171
endOfLine,
@@ -295,6 +300,21 @@ Comments are often not part of a language's AST and present a challenge for pret
295
300
296
301
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.
297
302
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
+
298
318
#### (optional) `printComment`
299
319
300
320
Called whenever a comment node needs to be printed. It has the signature:
0 commit comments