prettier-plugin-embed 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -406
- package/dist/embedded/es/options.d.ts +1 -1
- package/dist/embedded/html/options.d.ts +1 -1
- package/dist/embedded/json/options.d.ts +1 -1
- package/dist/embedded/register.d.ts +20 -20
- package/dist/embedded/ruby/options.d.ts +1 -1
- package/dist/embedded/sql/options.d.ts +1 -1
- package/dist/embedded/toml/plugin-toml-types.d.ts +2 -2
- package/dist/embedded/ts/options.d.ts +1 -1
- package/dist/embedded/types.d.ts +1 -1
- package/dist/embedded/utils.d.ts +13 -4
- package/dist/embedded/xml/parser.d.ts +6 -4
- package/dist/import-module-worker.js +45 -0
- package/dist/index.js +1767 -3209
- package/dist/options.d.ts +6 -6
- package/dist/parsers.d.ts +6 -6
- package/dist/type-utils.d.ts +5 -0
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +3 -3
- package/package.json +38 -47
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
A configurable [Prettier](https://prettier.io/) [plugin](https://prettier.io/docs/en/plugins.html) to format [embedded languages](https://prettier.io/docs/en/options.html#embedded-language-formatting) in JS/TS Files.
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
npm i -D prettier-plugin-embed
|
|
14
|
+
npm i -D prettier prettier-plugin-embed
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
</div>
|
|
@@ -20,19 +20,19 @@ npm i -D prettier-plugin-embed
|
|
|
20
20
|
|
|
21
21
|
### What?
|
|
22
22
|
|
|
23
|
-
This Prettier plugin
|
|
23
|
+
This Prettier plugin formats [embedded languages](https://prettier.io/docs/options#embedded-language-formatting) in [template literals](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Template_literals) within JavaScript and TypeScript files.
|
|
24
24
|
|
|
25
25
|
### Why?
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
It adds per-language formatting controls, configurable block comments and tags, and per-identifier overrides to Prettier's embedded formatting. See [prettier/prettier#4424](https://github.com/prettier/prettier/issues/4424) and [prettier/prettier#5588](https://github.com/prettier/prettier/issues/5588) for related use cases.
|
|
28
28
|
|
|
29
29
|
### How?
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
The plugin extends the [`embed`](https://prettier.io/docs/plugins#embed) method of Prettier's `estree` printer. Each integration delegates formatting to Prettier or a loaded language plugin. See [the printer implementation](./src/printers.ts) for the integration point.
|
|
32
32
|
|
|
33
33
|
## Features
|
|
34
34
|
|
|
35
|
-
- **Support for Additional Languages:** Extend
|
|
35
|
+
- **Support for Additional Languages:** Extend embedded formatting to languages such as XML, SQL, PHP, and more. See [Language-Specific Options](#language-specific-options) for the supported languages and their default identifiers.
|
|
36
36
|
|
|
37
37
|
- **Dual Identification Modes:** Identify embedded languages by block comments `` /* comment */ `...` `` or tags `` tag`...` `` preceding the template literals.
|
|
38
38
|
|
|
@@ -49,9 +49,33 @@ By leveraging Prettier's plugin system, this plugin overrides the default [`embe
|
|
|
49
49
|
## Installation
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
|
-
npm i -D prettier-plugin-embed
|
|
52
|
+
npm i -D prettier prettier-plugin-embed
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
Install Prettier 3 in the project that runs formatting. The consumer supplies the formatter and its language plugins.
|
|
56
|
+
|
|
57
|
+
Install the formatter plugin for each embedded language you use as a separate project dependency; the [Language-Specific Options](#language-specific-options) section shows which integrations require one.
|
|
58
|
+
|
|
59
|
+
Choose a Prettier version accepted by this plugin and every loaded language plugin. Each language plugin declares its own Prettier peer range.
|
|
60
|
+
|
|
61
|
+
<details>
|
|
62
|
+
<summary>Dependency resolution in strict installations</summary>
|
|
63
|
+
|
|
64
|
+
The plugin loads Prettier through static imports, which resolve from the plugin's installation location. Standard project installs and Yarn's default Plug'n'Play dependency fallback allow these imports to access the project's installed Prettier.
|
|
65
|
+
|
|
66
|
+
Yarn projects using `pnpFallbackMode: none`, and pnpm projects using `enableGlobalVirtualStore: true` with hoisting disabled, need an explicit dependency relationship for this resolution. For these configurations, add the following to `.yarnrc.yml` (Yarn) or `pnpm-workspace.yaml` (pnpm) to connect the plugin to the project's installed Prettier:
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
packageExtensions:
|
|
70
|
+
"prettier-plugin-embed@*":
|
|
71
|
+
peerDependencies:
|
|
72
|
+
prettier: ">=3.0.0 <4"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Projects can also use Yarn's default `pnpFallbackMode: dependencies-only` or pnpm's project-local virtual store (`enableGlobalVirtualStore: false`).
|
|
76
|
+
|
|
77
|
+
</details>
|
|
78
|
+
|
|
55
79
|
## Usage
|
|
56
80
|
|
|
57
81
|
### Getting Started
|
|
@@ -85,54 +109,75 @@ await prettier.format(code, {
|
|
|
85
109
|
}
|
|
86
110
|
```
|
|
87
111
|
|
|
112
|
+
For Yarn Plug'n'Play, load plugin objects from a JavaScript config so the imports resolve through Yarn's dependency map.
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
import * as prettierPluginEmbed from "prettier-plugin-embed";
|
|
116
|
+
|
|
117
|
+
export default {
|
|
118
|
+
plugins: [prettierPluginEmbed],
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
88
122
|
### Quick Start Config Examples
|
|
89
123
|
|
|
90
|
-
|
|
124
|
+
See [Config Examples](./ConfigExamples.md) for complete language plugin configurations and sample output.
|
|
91
125
|
|
|
92
126
|
### An Overview of the Philosophy
|
|
93
127
|
|
|
94
|
-
|
|
128
|
+
Set [`embeddedLanguageFormatting`](https://prettier.io/docs/options#embedded-language-formatting) to `"auto"` (Prettier's default) to enable embedded formatting.
|
|
95
129
|
|
|
96
|
-
This plugin
|
|
130
|
+
This plugin uses Prettier's built-in parsers and existing [language plugins](https://prettier.io/docs/plugins#official-plugins), adding the integration needed to format their languages inside template literals.
|
|
97
131
|
|
|
98
|
-
|
|
132
|
+
Install and load the formatter plugin for each additional language you use. For example, embedded XML requires both this plugin and [`@prettier/plugin-xml`](https://github.com/prettier/plugin-xml). The [Language-Specific Options](#language-specific-options) section lists the required plugins.
|
|
99
133
|
|
|
100
|
-
|
|
134
|
+
A preceding [block comment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#block_comments) such as `` /* xml */ `...` `` or a [tag](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) such as `` xml`...` `` identifies the embedded language. Configure each language with `embedded<Language>Comments` and `embedded<Language>Tags`. A leading block comment is checked first; templates without one are matched by their tag.
|
|
101
135
|
|
|
102
|
-
|
|
136
|
+
Tags support exact identifiers, member expressions, and regular expression strings in `/pattern/flags` form. Simple identifiers support patterns too: `"/^query$/"` matches the tag `query`. Member and call expressions use a normalized form for pattern matching; for example, `factory(argument).query` becomes `factory().query`.
|
|
137
|
+
|
|
138
|
+
For example, this JSON configuration matches `prisma.$queryRaw`, `client.$queryRaw`, and `ctx.prisma.$queryRaw`. JSON and JavaScript strings escape each backslash as `\\`:
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"plugins": ["prettier-plugin-embed", "prettier-plugin-sql"],
|
|
143
|
+
"embeddedSqlTags": ["/\\.\\$queryRaw$/"]
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Add comments or tags to `embeddedNoopComments` or `embeddedNoopTags` to preserve their template content as written. These options take priority among matching languages. Other overlapping matches use the first matching language in the internal registry; assign distinct identifiers or non-overlapping patterns to select a language explicitly.
|
|
103
148
|
|
|
104
149
|
> [!IMPORTANT]
|
|
105
150
|
>
|
|
106
|
-
>
|
|
151
|
+
> Specify comments or tags explicitly to keep language identification stable across plugin versions.
|
|
107
152
|
|
|
108
153
|
### Language-Specific Options
|
|
109
154
|
|
|
110
|
-
Supported embedded languages are:
|
|
111
|
-
|
|
112
|
-
- [CSS](#css)
|
|
113
|
-
- [ES (ECMAScript/JavaScript)](#es-ecmascriptjavascript)
|
|
114
|
-
- [GLSL](#glsl)
|
|
115
|
-
- [GraphQL](#graphql)
|
|
116
|
-
- [HTML](#html)
|
|
117
|
-
- [INI](#ini)
|
|
118
|
-
- [Java](#java)
|
|
119
|
-
- [JSON](#json)
|
|
120
|
-
- [JSONata](#jsonata)
|
|
121
|
-
- [LaTeX](#latex)
|
|
122
|
-
- [Markdown](#markdown)
|
|
123
|
-
- [NGINX](#nginx)
|
|
124
|
-
- [Pegjs](#pegjs)
|
|
125
|
-
- [PHP](#php)
|
|
126
|
-
- [Prisma](#prisma)
|
|
127
|
-
- [Properties](#properties)
|
|
128
|
-
- [Pug](#pug)
|
|
129
|
-
- [Ruby](#ruby)
|
|
130
|
-
- [Sh (Shell)](#sh-shell)
|
|
131
|
-
- [SQL](#sql)
|
|
132
|
-
- [TOML](#
|
|
133
|
-
- [TS (TypeScript)](#ts-typescript)
|
|
134
|
-
- [XML](#xml)
|
|
135
|
-
- [YAML](#yaml)
|
|
155
|
+
Supported embedded languages and their default comment/tag identifiers are:
|
|
156
|
+
|
|
157
|
+
- [CSS](#css): `css`
|
|
158
|
+
- [ES (ECMAScript/JavaScript)](#es-ecmascriptjavascript): `js`, `jsx`, `es`, `es6`, `mjs`, `cjs`, `pac`, `javascript`
|
|
159
|
+
- [GLSL](#glsl): `glsl`, `shader`
|
|
160
|
+
- [GraphQL](#graphql): `graphql`, `gql`
|
|
161
|
+
- [HTML](#html): `html`, `xhtml`
|
|
162
|
+
- [INI](#ini): `ini`, `cfg`, `pro`
|
|
163
|
+
- [Java](#java): `java`
|
|
164
|
+
- [JSON](#json): `json`, `jsonl`
|
|
165
|
+
- [JSONata](#jsonata): `jsonata`
|
|
166
|
+
- [LaTeX](#latex): `latex`, `tex`, `aux`, `cls`, `bbl`, `bib`, `toc`, `sty`
|
|
167
|
+
- [Markdown](#markdown): `md`, `markdown`
|
|
168
|
+
- [NGINX](#nginx): `nginx`
|
|
169
|
+
- [Pegjs](#pegjs): `pegjs`, `peggy`, `peg`
|
|
170
|
+
- [PHP](#php): `php`, `php5`
|
|
171
|
+
- [Prisma](#prisma): `prisma`
|
|
172
|
+
- [Properties](#properties): `properties`
|
|
173
|
+
- [Pug](#pug): `pug`, `jade`
|
|
174
|
+
- [Ruby](#ruby): `ruby`
|
|
175
|
+
- [Sh (Shell)](#sh-shell): `sh`
|
|
176
|
+
- [SQL](#sql): `sql`
|
|
177
|
+
- [TOML](#toml): `toml`
|
|
178
|
+
- [TS (TypeScript)](#ts-typescript): `ts`, `tsx`, `cts`, `mts`, `typescript`
|
|
179
|
+
- [XML](#xml): `xml`, `opml`, `rss`, `svg`
|
|
180
|
+
- [YAML](#yaml): `yaml`, `yml`
|
|
136
181
|
|
|
137
182
|
<details open>
|
|
138
183
|
<summary>
|
|
@@ -153,20 +198,7 @@ Click Here to Toggle
|
|
|
153
198
|
- **Default**: [`[]`](./src/embedded/noop/options.ts)
|
|
154
199
|
- **Description**: Tags that prevent their subsequent template literals from being identified as embedded languages and thus from being formatted.
|
|
155
200
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
<details>
|
|
159
|
-
<summary>deprecated</summary>
|
|
160
|
-
|
|
161
|
-
- **Type**: `string[]`
|
|
162
|
-
- **Default**: [`[]`](./src/embedded/noop/options.ts)
|
|
163
|
-
- **Description**: Comment or tag identifiers that prevent their subsequent template literals from being identified as embedded languages and thus from being formatted.
|
|
164
|
-
|
|
165
|
-
Please use `embeddedNoopComments` or `embeddedNoopTags`.
|
|
166
|
-
|
|
167
|
-
</details>
|
|
168
|
-
|
|
169
|
-
This "language" doesn't require other plugins and can override the native embedded language formatting. It serves as a way to turn off embedded language formatting for the specified language comments or tags.
|
|
201
|
+
This built-in option can override native embedded language formatting for the specified comments or tags, preserving their template literal content as written.
|
|
170
202
|
|
|
171
203
|
#### CSS
|
|
172
204
|
|
|
@@ -182,28 +214,15 @@ This "language" doesn't require other plugins and can override the native embedd
|
|
|
182
214
|
- **Default**: [`["css"]`](./src/embedded/css/options.ts)
|
|
183
215
|
- **Description**: Tags that make their subsequent template literals be identified as embedded CSS language.
|
|
184
216
|
|
|
185
|
-
##### ~~`embeddedCssIdentifiers`~~
|
|
186
|
-
|
|
187
|
-
<details>
|
|
188
|
-
<summary>deprecated</summary>
|
|
189
|
-
|
|
190
|
-
- **Type**: `string[]`
|
|
191
|
-
- **Default**: [`["css"]`](./src/embedded/css/options.ts)
|
|
192
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded CSS language.
|
|
193
|
-
|
|
194
|
-
Please use `embeddedCssComments` or `embeddedCssTags`.
|
|
195
|
-
|
|
196
|
-
</details>
|
|
197
|
-
|
|
198
217
|
##### `embeddedCssParser`
|
|
199
218
|
|
|
200
219
|
- **Type**: [`"css" | "less" | "scss"`](./src/embedded/css/options.ts)
|
|
201
220
|
- **Default**: [`"scss"`](./src/embedded/css/options.ts)
|
|
202
221
|
- **Description**: The parser used to parse the embedded CSS language.
|
|
203
222
|
|
|
204
|
-
|
|
223
|
+
Embedded CSS uses the parsers and printers included with Prettier.
|
|
205
224
|
|
|
206
|
-
This can override the native formatting
|
|
225
|
+
This can override the native formatting behavior for embedded CSS language. If you want to keep the native behavior, set `embeddedCssComments` or `embeddedCssTags` to `[]` or other values.
|
|
207
226
|
|
|
208
227
|
If you want to specify different parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
209
228
|
|
|
@@ -221,26 +240,13 @@ If you want to specify different parsers for different comments or tags, check [
|
|
|
221
240
|
- **Default**: [`["js", "jsx", "es", "es6", "mjs", "cjs", "pac", "javascript"]`](./src/embedded/es/options.ts)
|
|
222
241
|
- **Description**: Tags that make their subsequent template literals be identified as embedded ECMAScript/JavaScript language.
|
|
223
242
|
|
|
224
|
-
##### ~~`embeddedEsIdentifiers`~~
|
|
225
|
-
|
|
226
|
-
<details>
|
|
227
|
-
<summary>deprecated</summary>
|
|
228
|
-
|
|
229
|
-
- **Type**: `string[]`
|
|
230
|
-
- **Default**: [`["js", "jsx", "es", "es6", "mjs", "cjs", "pac", "javascript"]`](./src/embedded/es/options.ts)
|
|
231
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded ECMAScript/JavaScript language.
|
|
232
|
-
|
|
233
|
-
Please use `embeddedEsComments` or `embeddedEsTags`.
|
|
234
|
-
|
|
235
|
-
</details>
|
|
236
|
-
|
|
237
243
|
##### `embeddedEsParser`
|
|
238
244
|
|
|
239
245
|
- **Type**: [`"babel" | "babel-flow" | "acorn" | "espree" | "flow" | "meriyah"`](./src/embedded/es/options.ts)
|
|
240
246
|
- **Default**: [`"babel"`](./src/embedded/es/options.ts)
|
|
241
247
|
- **Description**: The parser used to parse the embedded ECMASCript/JavaScript language.
|
|
242
248
|
|
|
243
|
-
|
|
249
|
+
Embedded ECMAScript and JavaScript use the parsers and printers included with Prettier.
|
|
244
250
|
|
|
245
251
|
If you want to specify different parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
246
252
|
|
|
@@ -258,19 +264,6 @@ If you want to specify different parsers for different comments or tags, check [
|
|
|
258
264
|
- **Default**: [`["glsl", "shader"]`](./src/embedded/glsl/options.ts)
|
|
259
265
|
- **Description**: Tags that make their subsequent template literals be identified as embedded GLSL language. This option requires the `prettier-plugin-glsl` plugin.
|
|
260
266
|
|
|
261
|
-
##### ~~`embeddedGlslIdentifiers`~~
|
|
262
|
-
|
|
263
|
-
<details>
|
|
264
|
-
<summary>deprecated</summary>
|
|
265
|
-
|
|
266
|
-
- **Type**: `string[]`
|
|
267
|
-
- **Default**: [`["glsl", "shader"]`](./src/embedded/glsl/options.ts)
|
|
268
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded GLSL language. This option requires the `prettier-plugin-glsl` plugin.
|
|
269
|
-
|
|
270
|
-
Please use `embeddedGlslComments` or `embeddedGlslTags`.
|
|
271
|
-
|
|
272
|
-
</details>
|
|
273
|
-
|
|
274
267
|
Formatting embedded GLSL language requires the [`prettier-plugin-glsl`](https://github.com/NaridaL/glsl-language-toolkit/tree/main/packages/prettier-plugin-glsl) plugin to be loaded as well.
|
|
275
268
|
|
|
276
269
|
#### GraphQL
|
|
@@ -287,20 +280,7 @@ Formatting embedded GLSL language requires the [`prettier-plugin-glsl`](https://
|
|
|
287
280
|
- **Default**: [`["graphql", "gql"]`](./src/embedded/graphql/options.ts)
|
|
288
281
|
- **Description**: Tags that make their subsequent template literals be identified as embedded GraphQL language.
|
|
289
282
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
<details>
|
|
293
|
-
<summary>deprecated</summary>
|
|
294
|
-
|
|
295
|
-
- **Type**: `string[]`
|
|
296
|
-
- **Default**: [`["graphql", "gql"]`](./src/embedded/graphql/options.ts)
|
|
297
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded GraphQL language.
|
|
298
|
-
|
|
299
|
-
Please use `embeddedGraphqlComments` or `embeddedGraphqlTags`.
|
|
300
|
-
|
|
301
|
-
</details>
|
|
302
|
-
|
|
303
|
-
Formatting embedded GraphQL language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
283
|
+
Embedded GraphQL uses the parsers and printers included with Prettier.
|
|
304
284
|
|
|
305
285
|
This can override the native formatting behavior for embedded GraphQL language. If you want to keep the native behavior, set `embeddedGraphqlComments` or `embeddedGraphqlTags` to `[]` or other values.
|
|
306
286
|
|
|
@@ -318,26 +298,13 @@ This can override the native formatting behavior for embedded GraphQL language.
|
|
|
318
298
|
- **Default**: [`["html", "xhtml"]`](./src/embedded/html/options.ts)
|
|
319
299
|
- **Description**: Tags that make their subsequent template literals be identified as embedded HTML language.
|
|
320
300
|
|
|
321
|
-
##### ~~`embeddedHtmlIdentifiers`~~
|
|
322
|
-
|
|
323
|
-
<details>
|
|
324
|
-
<summary>deprecated</summary>
|
|
325
|
-
|
|
326
|
-
- **Type**: `string[]`
|
|
327
|
-
- **Default**: [`["html", "xhtml"]`](./src/embedded/html/options.ts)
|
|
328
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded HTML language.
|
|
329
|
-
|
|
330
|
-
Please use `embeddedHtmlComments` or `embeddedHtmlTags`.
|
|
331
|
-
|
|
332
|
-
</details>
|
|
333
|
-
|
|
334
301
|
##### `embeddedHtmlParser`
|
|
335
302
|
|
|
336
303
|
- **Type**: [`"html" | "vue" | "angular" | "lwc"`](./src/embedded/html/options.ts)
|
|
337
304
|
- **Default**: [`"html"`](./src/embedded/html/options.ts)
|
|
338
305
|
- **Description**: The parser used to parse the embedded HTML language.
|
|
339
306
|
|
|
340
|
-
|
|
307
|
+
Embedded HTML uses the parsers and printers included with Prettier.
|
|
341
308
|
|
|
342
309
|
This can override the native formatting behavior for embedded HTML language. If you want to keep the native behavior, set `embeddedHtmlComments` or `embeddedHtmlTags` to `[]` or other values.
|
|
343
310
|
|
|
@@ -357,19 +324,6 @@ If you want to specify different parsers for different comments or tags, check [
|
|
|
357
324
|
- **Default**: [`["ini", "cfg", "pro"]`](./src/embedded/ini/options.ts)
|
|
358
325
|
- **Description**: Tags that make their subsequent template literals be identified as embedded INI language. This option requires the `prettier-plugin-ini` plugin.
|
|
359
326
|
|
|
360
|
-
##### ~~`embeddedIniIdentifiers`~~
|
|
361
|
-
|
|
362
|
-
<details>
|
|
363
|
-
<summary>deprecated</summary>
|
|
364
|
-
|
|
365
|
-
- **Type**: `string[]`
|
|
366
|
-
- **Default**: [`["ini", "cfg", "pro"]`](./src/embedded/ini/options.ts)
|
|
367
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded INI language. This option requires the `prettier-plugin-ini` plugin.
|
|
368
|
-
|
|
369
|
-
Please use `embeddedIniComments` or `embeddedIniTags`.
|
|
370
|
-
|
|
371
|
-
</details>
|
|
372
|
-
|
|
373
327
|
Formatting embedded INI language requires the [`prettier-plugin-ini`](https://github.com/kddnewton/prettier-plugin-ini) plugin to be loaded as well. And [options](https://github.com/kddnewton/prettier-plugin-ini#configuration) supported by `prettier-plugin-ini` can therefore be used to further control the formatting behavior.
|
|
374
328
|
|
|
375
329
|
#### Java
|
|
@@ -386,19 +340,6 @@ Formatting embedded INI language requires the [`prettier-plugin-ini`](https://gi
|
|
|
386
340
|
- **Default**: [`["java"]`](./src/embedded/java/options.ts)
|
|
387
341
|
- **Description**: Tags that make their subsequent template literals be identified as embedded Java language. This option requires the `prettier-plugin-java` plugin.
|
|
388
342
|
|
|
389
|
-
##### ~~`embeddedJavaIdentifiers`~~
|
|
390
|
-
|
|
391
|
-
<details>
|
|
392
|
-
<summary>deprecated</summary>
|
|
393
|
-
|
|
394
|
-
- **Type**: `string[]`
|
|
395
|
-
- **Default**: [`["java"]`](./src/embedded/java/options.ts)
|
|
396
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Java language. This option requires the `prettier-plugin-java` plugin.
|
|
397
|
-
|
|
398
|
-
Please use `embeddedJavaComments` or `embeddedJavaTags`.
|
|
399
|
-
|
|
400
|
-
</details>
|
|
401
|
-
|
|
402
343
|
Formatting embedded Java language requires the [`prettier-plugin-java`](https://github.com/jhipster/prettier-java/tree/main/packages/prettier-plugin-java) plugin to be loaded as well. And [options](https://github.com/jhipster/prettier-java/tree/main/packages/prettier-plugin-java#options) supported by `prettier-plugin-java` can therefore be used to further control the formatting behavior.
|
|
403
344
|
|
|
404
345
|
#### JSON
|
|
@@ -415,26 +356,13 @@ Formatting embedded Java language requires the [`prettier-plugin-java`](https://
|
|
|
415
356
|
- **Default**: [`["json", "jsonl"]`](./src/embedded/json/options.ts)
|
|
416
357
|
- **Description**: Tags that make their subsequent template literals be identified as embedded JSON language.
|
|
417
358
|
|
|
418
|
-
##### ~~`embeddedJsonIdentifiers`~~
|
|
419
|
-
|
|
420
|
-
<details>
|
|
421
|
-
<summary>deprecated</summary>
|
|
422
|
-
|
|
423
|
-
- **Type**: `string[]`
|
|
424
|
-
- **Default**: [`["json", "jsonl"]`](./src/embedded/json/options.ts)
|
|
425
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded JSON language.
|
|
426
|
-
|
|
427
|
-
Please use `embeddedJsonComments` or `embeddedJsonTags`.
|
|
428
|
-
|
|
429
|
-
</details>
|
|
430
|
-
|
|
431
359
|
##### `embeddedJsonParser`
|
|
432
360
|
|
|
433
361
|
- **Type**: [`"json" | "json5" | "jsonc" | "json-stringify"`](./src/embedded/json/options.ts)
|
|
434
362
|
- **Default**: [`"json"`](./src/embedded/json/options.ts)
|
|
435
363
|
- **Description**: The parser used to parse the embedded JSON language.
|
|
436
364
|
|
|
437
|
-
|
|
365
|
+
Embedded JSON uses the parsers and printers included with Prettier.
|
|
438
366
|
|
|
439
367
|
If you want to specify different parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
440
368
|
|
|
@@ -452,19 +380,6 @@ If you want to specify different parsers for different comments or tags, check [
|
|
|
452
380
|
- **Default**: [`["jsonata"]`](./src/embedded/jsonata/options.ts)
|
|
453
381
|
- **Description**: Tags that make their subsequent template literals be identified as embedded JSONata language. This option requires the `@stedi/prettier-plugin-jsonata` plugin.
|
|
454
382
|
|
|
455
|
-
##### ~~`embeddedJsonataIdentifiers`~~
|
|
456
|
-
|
|
457
|
-
<details>
|
|
458
|
-
<summary>deprecated</summary>
|
|
459
|
-
|
|
460
|
-
- **Type**: `string[]`
|
|
461
|
-
- **Default**: [`["jsonata"]`](./src/embedded/jsonata/options.ts)
|
|
462
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded JSONata language. This option requires the `@stedi/prettier-plugin-jsonata` plugin.
|
|
463
|
-
|
|
464
|
-
Please use `embeddedJsonataComments` or `embeddedJsonataTags`.
|
|
465
|
-
|
|
466
|
-
</details>
|
|
467
|
-
|
|
468
383
|
Formatting embedded JSONata language requires the [`@stedi/prettier-plugin-jsonata`](https://github.com/Stedi/prettier-plugin-jsonata) plugin to be loaded as well.
|
|
469
384
|
|
|
470
385
|
#### LaTeX
|
|
@@ -481,19 +396,6 @@ Formatting embedded JSONata language requires the [`@stedi/prettier-plugin-jsona
|
|
|
481
396
|
- **Default**: [`["latex", "tex", "aux", "cls", "bbl", "bib", "toc", "sty"]`](./src/embedded/latex/options.ts)
|
|
482
397
|
- **Description**: Tags that make their subsequent template literals be identified as embedded LaTeX language. This option requires the `prettier-plugin-latex` plugin.
|
|
483
398
|
|
|
484
|
-
##### ~~`embeddedLatexIdentifiers`~~
|
|
485
|
-
|
|
486
|
-
<details>
|
|
487
|
-
<summary>deprecated</summary>
|
|
488
|
-
|
|
489
|
-
- **Type**: `string[]`
|
|
490
|
-
- **Default**: [`["latex", "tex", "aux", "cls", "bbl", "bib", "toc", "sty"]`](./src/embedded/latex/options.ts)
|
|
491
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded LaTeX language. This option requires the `prettier-plugin-latex` plugin.
|
|
492
|
-
|
|
493
|
-
Please use `embeddedLatexComments` or `embeddedLatexTags`.
|
|
494
|
-
|
|
495
|
-
</details>
|
|
496
|
-
|
|
497
399
|
Formatting embedded LaTeX language requires the [`prettier-plugin-latex`](https://github.com/siefkenj/prettier-plugin-latex) plugin to be loaded as well.
|
|
498
400
|
|
|
499
401
|
#### Markdown
|
|
@@ -510,26 +412,13 @@ Formatting embedded LaTeX language requires the [`prettier-plugin-latex`](https:
|
|
|
510
412
|
- **Default**: [`["md", "markdown"]`](./src/embedded/markdown/options.ts)
|
|
511
413
|
- **Description**: Tags that make their subsequent template literals be identified as embedded Markdown language.
|
|
512
414
|
|
|
513
|
-
##### ~~`embeddedMarkdownIdentifiers`~~
|
|
514
|
-
|
|
515
|
-
<details>
|
|
516
|
-
<summary>deprecated</summary>
|
|
517
|
-
|
|
518
|
-
- **Type**: `string[]`
|
|
519
|
-
- **Default**: [`["md", "markdown"]`](./src/embedded/markdown/options.ts)
|
|
520
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Markdown language.
|
|
521
|
-
|
|
522
|
-
Please use `embeddedMarkdownComments` or `embeddedMarkdownTags`.
|
|
523
|
-
|
|
524
|
-
</details>
|
|
525
|
-
|
|
526
415
|
##### `embeddedMarkdownParser`
|
|
527
416
|
|
|
528
417
|
- **Type**: [`"markdown" | "mdx" | "remark"`](./src/embedded/markdown/options.ts)
|
|
529
418
|
- **Default**: [`"markdown"`](./src/embedded/markdown/options.ts)
|
|
530
419
|
- **Description**: The parser used to parse the embedded Markdown language.
|
|
531
420
|
|
|
532
|
-
|
|
421
|
+
Embedded Markdown uses the parsers and printers included with Prettier.
|
|
533
422
|
|
|
534
423
|
This can override the native formatting for embedded Markdown language. If you want to keep the native behavior, set `embeddedMarkdownComments` or `embeddedMarkdownTags` to `[]` or other values.
|
|
535
424
|
|
|
@@ -551,19 +440,6 @@ The `remark` parser is [an alias of the `markdown` parser](https://github.com/pr
|
|
|
551
440
|
- **Default**: [`["nginx"]`](./src/embedded/nginx/options.ts)
|
|
552
441
|
- **Description**: Tags that make their subsequent template literals be identified as embedded NGINX language. This option requires the `prettier-plugin-nginx` plugin.
|
|
553
442
|
|
|
554
|
-
##### ~~`embeddedNginxIdentifiers`~~
|
|
555
|
-
|
|
556
|
-
<details>
|
|
557
|
-
<summary>deprecated</summary>
|
|
558
|
-
|
|
559
|
-
- **Type**: `string[]`
|
|
560
|
-
- **Default**: [`["nginx"]`](./src/embedded/nginx/options.ts)
|
|
561
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded NGINX language. This option requires the `prettier-plugin-nginx` plugin.
|
|
562
|
-
|
|
563
|
-
Please use `embeddedNginxComments` or `embeddedNginxTags`.
|
|
564
|
-
|
|
565
|
-
</details>
|
|
566
|
-
|
|
567
443
|
Formatting embedded NGINX language requires the [`prettier-plugin-nginx`](https://github.com/jxddk/prettier-plugin-nginx) plugin to be loaded as well. And [options](https://github.com/jxddk/prettier-plugin-nginx?tab=readme-ov-file#configuration) supported by `prettier-plugin-nginx` can therefore be used to further control the formatting behavior.
|
|
568
444
|
|
|
569
445
|
#### Pegjs
|
|
@@ -580,19 +456,6 @@ Formatting embedded NGINX language requires the [`prettier-plugin-nginx`](https:
|
|
|
580
456
|
- **Default**: [`["pegjs", "peggy", "peg"]`](./src/embedded/pegjs/options.ts)
|
|
581
457
|
- **Description**: Tags that make their subsequent template literals be identified as embedded Pegjs language. This option requires the `prettier-plugin-pegjs` plugin.
|
|
582
458
|
|
|
583
|
-
##### ~~`embeddedPegjsIdentifiers`~~
|
|
584
|
-
|
|
585
|
-
<details>
|
|
586
|
-
<summary>deprecated</summary>
|
|
587
|
-
|
|
588
|
-
- **Type**: `string[]`
|
|
589
|
-
- **Default**: [`["pegjs", "peggy", "peg"]`](./src/embedded/pegjs/options.ts)
|
|
590
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Pegjs language. This option requires the `prettier-plugin-pegjs` plugin.
|
|
591
|
-
|
|
592
|
-
Please use `embeddedPegjsComments` or `embeddedPegjsTags`.
|
|
593
|
-
|
|
594
|
-
</details>
|
|
595
|
-
|
|
596
459
|
Formatting embedded Pegjs language requires the [`prettier-plugin-pegjs`](https://github.com/siefkenj/prettier-plugin-pegjs) plugin to be loaded as well. And [options](https://github.com/siefkenj/prettier-plugin-pegjs?tab=readme-ov-file#options) supported by `prettier-plugin-pegjs` can therefore be used to further control the formatting behavior.
|
|
597
460
|
|
|
598
461
|
Note that `prettier-plugin-pegjs` supports different parsers for the action blocks and they are specified by the [`actionParser` option](https://github.com/siefkenj/prettier-plugin-pegjs?tab=readme-ov-file#options). If you want to specify different action parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
@@ -611,19 +474,6 @@ Note that `prettier-plugin-pegjs` supports different parsers for the action bloc
|
|
|
611
474
|
- **Default**: [`["php", "php5"]`](./src/embedded/php/options.ts)
|
|
612
475
|
- **Description**: Tags that make their subsequent template literals be identified as embedded PHP language. This option requires the `@prettier/plugin-php` plugin.
|
|
613
476
|
|
|
614
|
-
##### ~~`embeddedPhpIdentifiers`~~
|
|
615
|
-
|
|
616
|
-
<details>
|
|
617
|
-
<summary>deprecated</summary>
|
|
618
|
-
|
|
619
|
-
- **Type**: `string[]`
|
|
620
|
-
- **Default**: [`["php", "php5"]`](./src/embedded/php/options.ts)
|
|
621
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded PHP language. This option requires the `@prettier/plugin-php` plugin.
|
|
622
|
-
|
|
623
|
-
Please use `embeddedPhpComments` or `embeddedPhpTags`.
|
|
624
|
-
|
|
625
|
-
</details>
|
|
626
|
-
|
|
627
477
|
Formatting embedded PHP language requires the [`@prettier/plugin-php`](https://github.com/prettier/plugin-php) plugin to be loaded as well. And [options](https://github.com/prettier/plugin-php#configuration) supported by `@prettier/plugin-php` can therefore be used to further control the formatting behavior.
|
|
628
478
|
|
|
629
479
|
#### Prisma
|
|
@@ -640,19 +490,6 @@ Formatting embedded PHP language requires the [`@prettier/plugin-php`](https://g
|
|
|
640
490
|
- **Default**: [`["prisma"]`](./src/embedded/prisma/options.ts)
|
|
641
491
|
- **Description**: Tags that make their subsequent template literals be identified as embedded Prisma language. This option requires the `prettier-plugin-prisma` plugin.
|
|
642
492
|
|
|
643
|
-
##### ~~`embeddedPrismaIdentifiers`~~
|
|
644
|
-
|
|
645
|
-
<details>
|
|
646
|
-
<summary>deprecated</summary>
|
|
647
|
-
|
|
648
|
-
- **Type**: `string[]`
|
|
649
|
-
- **Default**: [`["prisma"]`](./src/embedded/prisma/options.ts)
|
|
650
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Prisma language. This option requires the `prettier-plugin-prisma` plugin.
|
|
651
|
-
|
|
652
|
-
Please use `embeddedPrismaComments` or `embeddedPrismaTags`.
|
|
653
|
-
|
|
654
|
-
</details>
|
|
655
|
-
|
|
656
493
|
Formatting embedded Prisma language requires the [`prettier-plugin-prisma`](https://github.com/avocadowastaken/prettier-plugin-prisma) plugin to be loaded as well.
|
|
657
494
|
|
|
658
495
|
#### Properties
|
|
@@ -669,19 +506,6 @@ Formatting embedded Prisma language requires the [`prettier-plugin-prisma`](http
|
|
|
669
506
|
- **Default**: [`["properties"]`](./src/embedded/properties/options.ts)
|
|
670
507
|
- **Description**: Tags that make their subsequent template literals be identified as embedded Properties language. This option requires the `prettier-plugin-properties` plugin.
|
|
671
508
|
|
|
672
|
-
##### ~~`embeddedPropertiesIdentifiers`~~
|
|
673
|
-
|
|
674
|
-
<details>
|
|
675
|
-
<summary>deprecated</summary>
|
|
676
|
-
|
|
677
|
-
- **Type**: `string[]`
|
|
678
|
-
- **Default**: [`["properties"]`](./src/embedded/properties/options.ts)
|
|
679
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Properties language. This option requires the `prettier-plugin-properties` plugin.
|
|
680
|
-
|
|
681
|
-
Please use `embeddedPropertiesComments` or `embeddedPropertiesTags`.
|
|
682
|
-
|
|
683
|
-
</details>
|
|
684
|
-
|
|
685
509
|
Formatting embedded Properties language requires the [`prettier-plugin-properties`](https://github.com/eemeli/prettier-plugin-properties) plugin to be loaded as well. And [options](https://github.com/eemeli/prettier-plugin-properties#configuration) supported by `prettier-plugin-properties` can therefore be used to further control the formatting behavior.
|
|
686
510
|
|
|
687
511
|
#### Pug
|
|
@@ -698,19 +522,6 @@ Formatting embedded Properties language requires the [`prettier-plugin-propertie
|
|
|
698
522
|
- **Default**: [`["pug", "jade"]`](./src/embedded/pug/options.ts)
|
|
699
523
|
- **Description**: Tags that make their subsequent template literals be identified as embedded Pug language. This option requires the `@prettier/plugin-pug` plugin.
|
|
700
524
|
|
|
701
|
-
##### ~~`embeddedPugIdentifiers`~~
|
|
702
|
-
|
|
703
|
-
<details>
|
|
704
|
-
<summary>deprecated</summary>
|
|
705
|
-
|
|
706
|
-
- **Type**: `string[]`
|
|
707
|
-
- **Default**: [`["pug", "jade"]`](./src/embedded/pug/options.ts)
|
|
708
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Pug language. This option requires the `@prettier/plugin-pug` plugin.
|
|
709
|
-
|
|
710
|
-
Please use `embeddedPugComments` or `embeddedPugTags`.
|
|
711
|
-
|
|
712
|
-
</details>
|
|
713
|
-
|
|
714
525
|
Formatting embedded Pug language requires the [`@prettier/plugin-pug`](https://github.com/prettier/plugin-pug) plugin to be loaded as well. And [options](https://github.com/prettier/plugin-pug?tab=readme-ov-file#configuration) supported by `@prettier/plugin-pug` can therefore be used to further control the formatting behavior.
|
|
715
526
|
|
|
716
527
|
#### Ruby
|
|
@@ -727,19 +538,6 @@ Formatting embedded Pug language requires the [`@prettier/plugin-pug`](https://g
|
|
|
727
538
|
- **Default**: [`["ruby"]`](./src/embedded/ruby/options.ts)
|
|
728
539
|
- **Description**: Tags that make their subsequent template literals be identified as embedded Ruby language. This option requires the `@prettier/plugin-ruby` plugin.
|
|
729
540
|
|
|
730
|
-
##### ~~`embeddedRubyIdentifiers`~~
|
|
731
|
-
|
|
732
|
-
<details>
|
|
733
|
-
<summary>deprecated</summary>
|
|
734
|
-
|
|
735
|
-
- **Type**: `string[]`
|
|
736
|
-
- **Default**: [`["ruby"]`](./src/embedded/ruby/options.ts)
|
|
737
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Ruby language. This option requires the `@prettier/plugin-ruby` plugin.
|
|
738
|
-
|
|
739
|
-
Please use `embeddedRubyComments` or `embeddedRubyTags`.
|
|
740
|
-
|
|
741
|
-
</details>
|
|
742
|
-
|
|
743
541
|
##### `embeddedRubyParser`
|
|
744
542
|
|
|
745
543
|
- **Type**: [`"ruby" | "rbs" | "haml"`](./src/embedded/ruby/options.ts)
|
|
@@ -764,19 +562,6 @@ If you want to specify different parsers for different comments or tags, check [
|
|
|
764
562
|
- **Default**: [`["sh"]`](./src/embedded/sh/options.ts)
|
|
765
563
|
- **Description**: Tags that make their subsequent template literals be identified as embedded Shell language. This option requires the `prettier-plugin-sh` plugin.
|
|
766
564
|
|
|
767
|
-
##### ~~`embeddedShIdentifiers`~~
|
|
768
|
-
|
|
769
|
-
<details>
|
|
770
|
-
<summary>deprecated</summary>
|
|
771
|
-
|
|
772
|
-
- **Type**: `string[]`
|
|
773
|
-
- **Default**: [`["sh"]`](./src/embedded/sh/options.ts)
|
|
774
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded Shell language. This option requires the `prettier-plugin-sh` plugin.
|
|
775
|
-
|
|
776
|
-
Please use `embeddedShComments` or `embeddedShTags`.
|
|
777
|
-
|
|
778
|
-
</details>
|
|
779
|
-
|
|
780
565
|
Formatting embedded Shell language requires the [`prettier-plugin-sh`](https://github.com/un-ts/prettier/tree/master/packages/sh#readme) plugin to be loaded as well. And [options](https://github.com/un-ts/prettier/tree/master/packages/sh#parser-options) supported by `prettier-plugin-sh` can therefore be used to further control the formatting behavior.
|
|
781
566
|
|
|
782
567
|
Note that `prettier-plugin-sh` supports different variants of shell syntaxes and they are specified by the [`variant` option](https://github.com/un-ts/prettier/tree/master/packages/sh#parser-options). If you want to specify different variants for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
@@ -795,19 +580,6 @@ Note that `prettier-plugin-sh` supports different variants of shell syntaxes and
|
|
|
795
580
|
- **Default**: [`["sql"]`](./src/embedded/sql/options.ts)
|
|
796
581
|
- **Description**: Tags that make their subsequent template literals be identified as embedded SQL language. This option requires the `prettier-plugin-sql` plugin or the `prettier-plugin-sql-cst` plugin.
|
|
797
582
|
|
|
798
|
-
##### ~~`embeddedSqlIdentifiers`~~
|
|
799
|
-
|
|
800
|
-
<details>
|
|
801
|
-
<summary>deprecated</summary>
|
|
802
|
-
|
|
803
|
-
- **Type**: `string[]`
|
|
804
|
-
- **Default**: [`["sql"]`](./src/embedded/sql/options.ts)
|
|
805
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded SQL language. This option requires the `prettier-plugin-sql` plugin or the `prettier-plugin-sql-cst` plugin.
|
|
806
|
-
|
|
807
|
-
Please use `embeddedSqlComments` or `embeddedSqlTags`.
|
|
808
|
-
|
|
809
|
-
</details>
|
|
810
|
-
|
|
811
583
|
##### `embeddedSqlPlugin`
|
|
812
584
|
|
|
813
585
|
- **Type**: [`"prettier-plugin-sql" | "prettier-plugin-sql-cst"`](./src/embedded/sql/options.ts)
|
|
@@ -838,19 +610,6 @@ Note that `prettier-plugin-sql` supports many different SQL dialects which are s
|
|
|
838
610
|
- **Default**: [`["toml"]`](./src/embedded/toml/options.ts)
|
|
839
611
|
- **Description**: Tags that make their subsequent template literals be identified as embedded TOML language. This option requires the `prettier-plugin-toml` plugin.
|
|
840
612
|
|
|
841
|
-
##### ~~`embeddedTomlIdentifiers`~~
|
|
842
|
-
|
|
843
|
-
<details>
|
|
844
|
-
<summary>deprecated</summary>
|
|
845
|
-
|
|
846
|
-
- **Type**: `string[]`
|
|
847
|
-
- **Default**: [`["toml"]`](./src/embedded/toml/options.ts)
|
|
848
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded TOML language. This option requires the `prettier-plugin-toml` plugin.
|
|
849
|
-
|
|
850
|
-
Please use `embeddedTomlComments` or `embeddedTomlTags`.
|
|
851
|
-
|
|
852
|
-
</details>
|
|
853
|
-
|
|
854
613
|
Formatting embedded TOML language requires the [`prettier-plugin-toml`](https://github.com/un-ts/prettier/tree/master/packages/toml#readme) plugin to be loaded as well. And [options](https://github.com/un-ts/prettier/blob/master/packages/toml/src/options.ts) supported by `prettier-plugin-toml` can therefore be used to further control the formatting behavior.
|
|
855
614
|
|
|
856
615
|
#### TS (TypeScript)
|
|
@@ -867,26 +626,13 @@ Formatting embedded TOML language requires the [`prettier-plugin-toml`](https://
|
|
|
867
626
|
- **Default**: [`["ts", "tsx", "cts", "mts", "typescript"]`](./src/embedded/ts/options.ts)
|
|
868
627
|
- **Description**: Tags that make their subsequent template literals be identified as embedded TypeScript language.
|
|
869
628
|
|
|
870
|
-
##### ~~`embeddedTsIdentifiers`~~
|
|
871
|
-
|
|
872
|
-
<details>
|
|
873
|
-
<summary>deprecated</summary>
|
|
874
|
-
|
|
875
|
-
- **Type**: `string[]`
|
|
876
|
-
- **Default**: [`["ts", "tsx", "cts", "mts", "typescript"]`](./src/embedded/ts/options.ts)
|
|
877
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded TypeScript language.
|
|
878
|
-
|
|
879
|
-
Please use `embeddedTsComments` or `embeddedTsTags`.
|
|
880
|
-
|
|
881
|
-
</details>
|
|
882
|
-
|
|
883
629
|
##### `embeddedTsParser`
|
|
884
630
|
|
|
885
631
|
- **Type**: [`"typescript" | "babel-ts"`](./src/embedded/ts/options.ts)
|
|
886
632
|
- **Default**: [`"typescript"`](./src/embedded/ts/options.ts)
|
|
887
633
|
- **Description**: The parser used to parse the embedded TypeScript language.
|
|
888
634
|
|
|
889
|
-
|
|
635
|
+
Embedded TypeScript uses the parsers and printers included with Prettier.
|
|
890
636
|
|
|
891
637
|
If you want to specify different parsers for different comments or tags, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
892
638
|
|
|
@@ -904,20 +650,7 @@ If you want to specify different parsers for different comments or tags, check [
|
|
|
904
650
|
- **Default**: [`["xml", "opml", "rss", "svg"]`](./src/embedded/xml/options.ts)
|
|
905
651
|
- **Description**: Tags that make their subsequent template literals be identified as embedded XML language. This option requires the `@prettier/plugin-xml` plugin.
|
|
906
652
|
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
<details>
|
|
910
|
-
<summary>deprecated</summary>
|
|
911
|
-
|
|
912
|
-
- **Type**: `string[]`
|
|
913
|
-
- **Default**: [`["xml", "opml", "rss", "svg"]`](./src/embedded/xml/options.ts)
|
|
914
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded XML language. This option requires the `@prettier/plugin-xml` plugin.
|
|
915
|
-
|
|
916
|
-
Please use `embeddedXmlComments` or `embeddedXmlTags`.
|
|
917
|
-
|
|
918
|
-
</details>
|
|
919
|
-
|
|
920
|
-
Formatting embedded XML language requires the [`@prettier/plugin-xml`](https://github.com/prettier/plugin-xml) plugin to be loaded as well. And [options](https://github.com/prettier/plugin-xml#configuration) supported by `@prettier/plugin-xml` can therefore be used to further control the formatting behavior.
|
|
653
|
+
Embedded XML uses the parser provided by [`@prettier/plugin-xml`](https://github.com/prettier/plugin-xml), which must be loaded when XML formatting is enabled. Its [options](https://github.com/prettier/plugin-xml#configuration) control the XML formatting behavior.
|
|
921
654
|
|
|
922
655
|
#### YAML
|
|
923
656
|
|
|
@@ -933,20 +666,7 @@ Formatting embedded XML language requires the [`@prettier/plugin-xml`](https://g
|
|
|
933
666
|
- **Default**: [`["yaml", "yml"]`](./src/embedded/yaml/options.ts)
|
|
934
667
|
- **Description**: Tags that make their subsequent template literals be identified as embedded YAML language.
|
|
935
668
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
<details>
|
|
939
|
-
<summary>deprecated</summary>
|
|
940
|
-
|
|
941
|
-
- **Type**: `string[]`
|
|
942
|
-
- **Default**: [`["yaml", "yml"]`](./src/embedded/yaml/options.ts)
|
|
943
|
-
- **Description**: Comment or tag identifiers that make their subsequent template literals be identified as embedded YAML language.
|
|
944
|
-
|
|
945
|
-
Please use `embeddedYamlComments` or `embeddedYamlTags`.
|
|
946
|
-
|
|
947
|
-
</details>
|
|
948
|
-
|
|
949
|
-
Formatting embedded YAML language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
669
|
+
Embedded YAML uses the parsers and printers included with Prettier.
|
|
950
670
|
|
|
951
671
|
</details>
|
|
952
672
|
|
|
@@ -954,32 +674,6 @@ Formatting embedded YAML language doesn't require other plugins and uses the par
|
|
|
954
674
|
|
|
955
675
|
#### Language-Agnostic
|
|
956
676
|
|
|
957
|
-
##### ~~`noEmbeddedIdentificationByComment`~~
|
|
958
|
-
|
|
959
|
-
<details>
|
|
960
|
-
<summary>deprecated</summary>
|
|
961
|
-
|
|
962
|
-
- **Type**: `string[]`
|
|
963
|
-
- **Default**: `[]`
|
|
964
|
-
- **Description**: Turns off `` /* comment */ `...` `` comment-based embedded language identification for the specified identifiers.
|
|
965
|
-
|
|
966
|
-
Please use `embedded<Language>Comments` or `embedded<Language>Tags` to configure each embedded language, and you won't need this option anymore.
|
|
967
|
-
|
|
968
|
-
</details>
|
|
969
|
-
|
|
970
|
-
##### ~~`noEmbeddedIdentificationByTag`~~
|
|
971
|
-
|
|
972
|
-
<details>
|
|
973
|
-
<summary>deprecated</summary>
|
|
974
|
-
|
|
975
|
-
- **Type**: `string[]`
|
|
976
|
-
- **Default**: `[]`
|
|
977
|
-
- **Description**: Turns off `` tag`...` `` tag-based embedded language identification for the specified identifiers.
|
|
978
|
-
|
|
979
|
-
Please use `embedded<Language>Comments` or `embedded<Language>Tags` to configure each embedded language, and you won't need this option anymore.
|
|
980
|
-
|
|
981
|
-
</details>
|
|
982
|
-
|
|
983
677
|
##### `preserveEmbeddedExteriorWhitespaces`
|
|
984
678
|
|
|
985
679
|
- **Type**: `string[]`
|
|
@@ -1002,11 +696,29 @@ Please use `embedded<Language>Comments` or `embedded<Language>Tags` to configure
|
|
|
1002
696
|
|
|
1003
697
|
This option is provided for users to override certain options based on comments or tags. Due to the lack of support for using objects in prettier plugin options (https://github.com/prettier/prettier/issues/14671), it accepts a **stringified** json string, or a file path with an extension of `.json`, `.jsonc`, `.js`, `.cjs`, `.mjs`, `.ts`, `.cts` or `.mts` as its value. If no extension is provided, it will be treated as a `.json`/`.jsonc` file. For relative paths, it will automatically figure out the prettier config location and use that as the base path.
|
|
1004
698
|
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
699
|
+
TypeScript override files (`.ts`, `.mts` and `.cts`) are loaded with the active runtime's `import()`. Node.js with [native type stripping](https://nodejs.org/api/typescript.html) enabled can load erasable TypeScript, and Bun provides native TypeScript loading. The runtime determines module semantics: `.mts` uses ES modules, `.cts` uses CommonJS, and `.ts` follows the package's module type.
|
|
700
|
+
|
|
701
|
+
Consumers can enable a compatible loader through Node.js startup options, such as `node --import tsx node_modules/prettier/bin/prettier.cjs . --write`. Override files are evaluated in workers, which inherit the runtime's startup preloads. Enable synchronous module hooks through a `--import` or `--require` preload so they are available in those workers. When the runtime reports unsupported module loading or TypeScript transformation, the plugin can use the consumer project's optional [`tsx`](https://github.com/privatenumber/tsx) 4.19+ installation as a fallback. This fallback uses Node.js's [`module.register()`](https://nodejs.org/api/module.html#moduleregisterspecifier-parenturl-options) API, introduced in Node.js 18.19 and 20.6. Configuration errors include their original diagnostics.
|
|
702
|
+
|
|
703
|
+
The Prettier VS Code extension uses its bundled Node.js runtime; JavaScript override files provide the simplest editor setup.
|
|
704
|
+
|
|
705
|
+
Each override module load uses a fresh worker and module cache, so edits to the override file and its imported modules are reflected in subsequent formatting calls. Workers are released after the configuration has been read. Relative paths follow Prettier's configuration discovery and its [`clearConfigCache()`](https://prettier.io/docs/api#prettierclearconfigcache) API.
|
|
706
|
+
|
|
707
|
+
The resolved value should be an array of objects. Each object in the array must have 2 fields: `comments` and `options`, or `tags` and `options`. The `options` are considered overrides that will be applied to the global `options` of prettier for those `comments` and `tags` only. It's like the [`overrides`](https://prettier.io/docs/en/configuration.html#configuration-overrides) of `prettier`, but it is comment/tag-based instead of file-based.
|
|
708
|
+
|
|
709
|
+
Per-tag overrides refer to the matching entry from `embedded<Language>Tags`, including the pattern string when a regular expression matches. The first matching override applies. For example, this JavaScript configuration gives embedded JavaScript selected by `query` its own quote style:
|
|
710
|
+
|
|
711
|
+
```js
|
|
712
|
+
export default {
|
|
713
|
+
plugins: ["prettier-plugin-embed"],
|
|
714
|
+
embeddedEsTags: ["/^query$/"],
|
|
715
|
+
embeddedOverrides: JSON.stringify([
|
|
716
|
+
{ tags: ["/^query$/"], options: { singleQuote: true } },
|
|
717
|
+
]),
|
|
718
|
+
};
|
|
719
|
+
```
|
|
1008
720
|
|
|
1009
|
-
|
|
721
|
+
Embedded parsers receive the override options. The resulting document is laid out with the surrounding JavaScript or TypeScript document, using the outer Prettier `printWidth`.
|
|
1010
722
|
|
|
1011
723
|
In a json file, the root is the array of objects. In a JavaScript/TypeScript file, the array of objects should be a default export, or a named export with the name `embeddedOverrides`.
|
|
1012
724
|
|
|
@@ -1031,7 +743,7 @@ An example `.json`/`.jsonc` file is:
|
|
|
1031
743
|
|
|
1032
744
|
> [!CAUTION]
|
|
1033
745
|
>
|
|
1034
|
-
>
|
|
746
|
+
> `embeddedOverrides` supports options applied during parsing and document generation. Options applied during final document printing, such as `tabWidth`, are configured globally. The [`EmbeddedOverride` interface](https://github.com/Sec-ant/prettier-plugin-embed/blob/main/src/types.ts) lists the supported override options.
|
|
1035
747
|
|
|
1036
748
|
### Typed Options
|
|
1037
749
|
|