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: website/versioned_docs/version-stable/browser.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ Required options:
21
21
22
22
-**[`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.
23
23
24
-
-**`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.6.2/plugins](https://unpkg.com/browse/prettier@3.6.2/plugins). Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON.
24
+
-**`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.7.0/plugins](https://unpkg.com/browse/prettier@3.7.0/plugins). Note that `estree` plugin should be loaded when printing JavaScript, TypeScript, Flow, or JSON.
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.
@@ -50,8 +50,8 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack
@@ -64,8 +64,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/plugins.md
+33-4Lines changed: 33 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,11 +51,13 @@ Strings provided to `plugins` are ultimately passed to [`import()` expression](h
51
51
52
52
-[`prettier-plugin-apex`](https://github.com/dangmai/prettier-plugin-apex) by [**@dangmai**](https://github.com/dangmai)
53
53
-[`prettier-plugin-astro`](https://github.com/withastro/prettier-plugin-astro) by [**@withastro contributors**](https://github.com/withastro/prettier-plugin-astro/graphs/contributors)
54
+
-[`prettier-plugin-bigcommerce-stencil`](https://github.com/phoenix128/prettier-plugin-bigcommerce-stencil) by [**@phoenix128**](https://github.com/phoenix128)
54
55
-[`prettier-plugin-elm`](https://github.com/gicentre/prettier-plugin-elm) by [**@giCentre**](https://github.com/gicentre)
55
56
-[`prettier-plugin-erb`](https://github.com/adamzapasnik/prettier-plugin-erb) by [**@adamzapasnik**](https://github.com/adamzapasnik)
56
57
-[`prettier-plugin-gherkin`](https://github.com/mapado/prettier-plugin-gherkin) by [**@mapado**](https://github.com/mapado)
57
58
-[`prettier-plugin-glsl`](https://github.com/NaridaL/glsl-language-toolkit/tree/main/packages/prettier-plugin-glsl) by [**@NaridaL**](https://github.com/NaridaL)
58
59
-[`prettier-plugin-go-template`](https://github.com/NiklasPor/prettier-plugin-go-template) by [**@NiklasPor**](https://github.com/NiklasPor)
60
+
-[`prettier-plugin-hugo-post`](https://github.com/metcalfc/prettier-plugin-hugo-post) by [**@metcalfc**](https://github.com/metcalfc)
59
61
-[`prettier-plugin-java`](https://github.com/jhipster/prettier-java) by [**@JHipster**](https://github.com/jhipster)
60
62
-[`prettier-plugin-jinja-template`](https://github.com/davidodenwald/prettier-plugin-jinja-template) by [**@davidodenwald**](https://github.com/davidodenwald)
61
63
-[`prettier-plugin-jsonata`](https://github.com/Stedi/prettier-plugin-jsonata) by [**@Stedi**](https://github.com/Stedi)
@@ -149,9 +151,11 @@ function hasIgnorePragma(text: string): boolean;
149
151
_(Optional)_ The preprocess function can process the input text before passing into `parse` function.
150
152
151
153
```ts
152
-
function preprocess(text:string, options:object):string;
154
+
function preprocess(text:string, options:object):string|Promise<string>;
153
155
```
154
156
157
+
_Support for async preprocess first added in v3.7.0_
158
+
155
159
### `printers`
156
160
157
161
Printers convert ASTs into a Prettier intermediate representation, also known as a Doc.
@@ -170,6 +174,8 @@ export const printers = {
170
174
isBlockComment,
171
175
printComment,
172
176
getCommentChildNodes,
177
+
hasPrettierIgnore,
178
+
printPrettierIgnored,
173
179
handleComments: {
174
180
ownLine,
175
181
endOfLine,
@@ -394,6 +400,22 @@ function getCommentChildNodes(
394
400
395
401
Return `[]` if the node has no children or `undefined` to fall back on the default behavior.
396
402
403
+
### (optional) `hasPrettierIgnore`
404
+
405
+
```ts
406
+
function hasPrettierIgnore(path: AstPath): boolean;
407
+
```
408
+
409
+
Returns whether or not the AST node is `prettier-ignore`d.
410
+
411
+
### (optional) `printPrettierIgnored`
412
+
413
+
If the AST node is `prettier-ignore`d, Prettier will slice for the text for parsing without calling `print` function by default, however plugin can also handle the `prettier-ignore`d node print by adding this property.
414
+
415
+
This property have the same signature as the `print` property.
416
+
417
+
_First available in v3.7.0_
418
+
397
419
#### (optional) `printComment`
398
420
399
421
Called whenever a comment node needs to be printed. It has the signature:
@@ -410,17 +432,24 @@ function printComment(
410
432
#### (optional) `canAttachComment`
411
433
412
434
```ts
413
-
function canAttachComment(node: AST): boolean;
435
+
function canAttachComment(node: AST, ancestors: T[]): boolean;
414
436
```
415
437
416
438
This function is used for deciding whether a comment can be attached to a particular AST node. By default, _all_ AST properties are traversed searching for nodes that comments can be attached to. This function is used to prevent comments from being attached to a particular node. A typical implementation looks like
417
439
418
440
```js
419
-
function canAttachComment(node) {
420
-
returnnode.type&&node.type!=="comment";
441
+
function canAttachComment(node, [parent]) {
442
+
return!(
443
+
node.type==="comment"||
444
+
(parent?.type==="shorthand-property"&&
445
+
parent.key=== node &&
446
+
parent.key!==parent.value)
447
+
);
421
448
}
422
449
```
423
450
451
+
_The second parameter `ancestors` first added in v3.7.0._
Copy file name to clipboardExpand all lines: website/versioned_docs/version-stable/related-projects.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,4 +30,6 @@ title: Related Projects
30
30
-[prettier-chrome](https://github.com/u3u/prettier-chrome) is an extension that runs Prettier in the browser
31
31
-[spotless](https://github.com/diffplug/spotless) lets you run prettier from [gradle](https://github.com/diffplug/spotless/tree/main/plugin-gradle#prettier) or [maven](https://github.com/diffplug/spotless/tree/main/plugin-maven#prettier).
32
32
-[csharpier](https://github.com/belav/csharpier) is a port of Prettier for C#
33
+
-[Prettier](https://github.com/jaywcjlove/Prettier) is a Swift version based on Prettier
33
34
-[reviewdog-action-prettier](https://github.com/EPMatt/reviewdog-action-prettier) runs Prettier in GitHub Actions CI/CD workflows
35
+
-[monaco-prettier](https://github.com/remcohaszing/monaco-prettier) integrates Prettier into [Monaco editor](https://microsoft.github.io/monaco-editor/)
0 commit comments