prettier-plugin-embed 0.4.9 → 0.4.10
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 +227 -104
- package/dist/embedded/register.d.ts +2 -2
- package/dist/index.js +702 -667
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -141,49 +141,69 @@ Click Here to Toggle
|
|
|
141
141
|
|
|
142
142
|
#### NOOP
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
| :-----------------------: | :--------: | :------------------------------------: | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
146
|
-
| `embeddedNoopIdentifiers` | `string[]` | [`[]`](./src/embedded/noop/options.ts) | Tag or comment identifiers that prevent their subsequent template literals from being identified as embedded languages and thus from being formatted. |
|
|
144
|
+
##### `embeddedNoopIdentifiers`
|
|
147
145
|
|
|
148
|
-
|
|
146
|
+
- **Type**: `string[]`
|
|
147
|
+
- **Default**: [`[]`](./src/embedded/noop/options.ts)
|
|
148
|
+
- **Description**: Tag or comment identifiers that prevent their subsequent template literals from being identified as embedded languages and thus from being formatted.
|
|
149
|
+
|
|
150
|
+
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 identifiers.
|
|
149
151
|
|
|
150
152
|
#### CSS
|
|
151
153
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
##### `embeddedCssIdentifiers`
|
|
155
|
+
|
|
156
|
+
- **Type**: `string[]`
|
|
157
|
+
- **Default**: [`["css"]`](./src/embedded/css/options.ts)
|
|
158
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded CSS language.
|
|
159
|
+
|
|
160
|
+
##### `embeddedCssParser`
|
|
161
|
+
|
|
162
|
+
- **Type**: [`"css" | "less" | "scss"`](./src/embedded/css/options.ts)
|
|
163
|
+
- **Default**: [`"scss"`](./src/embedded/css/options.ts)
|
|
164
|
+
- **Description**: The parser used to parse the embedded CSS language.
|
|
156
165
|
|
|
157
166
|
Formatting embedded CSS language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
158
167
|
|
|
159
168
|
This can override the native formatting bahavior for embedded CSS language. If you want to keep the native behavior, set `embeddedCssIdentifiers` to `[]` or other identifiers.
|
|
160
169
|
|
|
161
|
-
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides).
|
|
170
|
+
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
162
171
|
|
|
163
172
|
#### ES (ECMAScript/JavaScript)
|
|
164
173
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
174
|
+
##### `embeddedEsIdentifiers`
|
|
175
|
+
|
|
176
|
+
- **Type**: `string[]`
|
|
177
|
+
- **Default**: [`["js", "jsx", "es", "es6", "mjs", "cjs", "pac", "javascript"]`](./src/embedded/es/options.ts)
|
|
178
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded ECMAScript/JavaScript language.
|
|
179
|
+
|
|
180
|
+
##### `embeddedEsParser`
|
|
181
|
+
|
|
182
|
+
- **Type**: [`"babel" | "babel-flow" | "acorn" | "espree" | "flow" | "meriyah"`](./src/embedded/es/options.ts)
|
|
183
|
+
- **Default**: [`"babel"`](./src/embedded/es/options.ts)
|
|
184
|
+
- **Description**: The parser used to parse the embedded ECMASCript/JavaScript language.
|
|
169
185
|
|
|
170
186
|
Formatting embedded ECMAScript/JavaScript language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
171
187
|
|
|
172
|
-
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides).
|
|
188
|
+
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
173
189
|
|
|
174
190
|
#### GLSL
|
|
175
191
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
192
|
+
##### `embeddedGlslIdentifiers`
|
|
193
|
+
|
|
194
|
+
- **Type**: `string[]`
|
|
195
|
+
- **Default**: [`["glsl", "shader"]`](./src/embedded/glsl/options.ts)
|
|
196
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded GLSL language. This option requires the `prettier-plugin-glsl` plugin.
|
|
179
197
|
|
|
180
198
|
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.
|
|
181
199
|
|
|
182
200
|
#### GraphQL
|
|
183
201
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
202
|
+
##### `embeddedGraphqlIdentifiers`
|
|
203
|
+
|
|
204
|
+
- **Type**: `string[]`
|
|
205
|
+
- **Default**: [`["graphql", "gql"]`](./src/embedded/graphql/options.ts)
|
|
206
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded GraphQL language.
|
|
187
207
|
|
|
188
208
|
Formatting embedded GraphQL language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
189
209
|
|
|
@@ -191,190 +211,265 @@ This can override the native formatting behavior for embedded GraphQL language.
|
|
|
191
211
|
|
|
192
212
|
#### HTML
|
|
193
213
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
214
|
+
##### `embeddedHtmlIdentifiers`
|
|
215
|
+
|
|
216
|
+
- **Type**: `string[]`
|
|
217
|
+
- **Default**: [`["html", "xhtml"]`](./src/embedded/html/options.ts)
|
|
218
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded HTML language.
|
|
219
|
+
|
|
220
|
+
##### `embeddedHtmlParser`
|
|
221
|
+
|
|
222
|
+
- **Type**: [`"html" | "vue" | "angular" | "lwc"`](./src/embedded/html/options.ts)
|
|
223
|
+
- **Default**: [`"html"`](./src/embedded/html/options.ts)
|
|
224
|
+
- **Description**: The parser used to parse the embedded HTML language.
|
|
198
225
|
|
|
199
226
|
Formatting embedded HTML language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
200
227
|
|
|
201
228
|
This can override the native formatting behavior for embedded HTML language. If you want to keep the native behavior, set `embeddedHtmlIdentifiers` to `[]` or other identifiers.
|
|
202
229
|
|
|
203
|
-
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides).
|
|
230
|
+
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
204
231
|
|
|
205
232
|
#### INI
|
|
206
233
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
234
|
+
##### `embeddedIniIdentifiers`
|
|
235
|
+
|
|
236
|
+
- **Type**: `string[]`
|
|
237
|
+
- **Default**: [`["ini", "cfg", "pro"]`](./src/embedded/ini/options.ts)
|
|
238
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded INI language. This option requires the `prettier-plugin-ini` plugin.
|
|
210
239
|
|
|
211
240
|
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.
|
|
212
241
|
|
|
213
242
|
#### Java
|
|
214
243
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
244
|
+
##### `embeddedJavaIdentifiers`
|
|
245
|
+
|
|
246
|
+
- **Type**: `string[]`
|
|
247
|
+
- **Default**: [`["java"]`](./src/embedded/java/options.ts)
|
|
248
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded Java language. This option requires the `prettier-plugin-java` plugin.
|
|
218
249
|
|
|
219
250
|
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.
|
|
220
251
|
|
|
221
252
|
#### JSON
|
|
222
253
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
254
|
+
##### `embeddedJsonIdentifiers`
|
|
255
|
+
|
|
256
|
+
- **Type**: `string[]`
|
|
257
|
+
- **Default**: [`["json", "jsonl"]`](./src/embedded/json/options.ts)
|
|
258
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded JSON language.
|
|
259
|
+
|
|
260
|
+
##### `embeddedJsonParser`
|
|
261
|
+
|
|
262
|
+
- **Type**: [`"json" | "json5" | "jsonc" | "json-stringify"`](./src/embedded/json/options.ts)
|
|
263
|
+
- **Default**: [`"json"`](./src/embedded/json/options.ts)
|
|
264
|
+
- **Description**: The parser used to parse the embedded JSON language.
|
|
227
265
|
|
|
228
266
|
Formatting embedded JSON language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
229
267
|
|
|
230
|
-
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides).
|
|
268
|
+
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
231
269
|
|
|
232
270
|
#### JSONata
|
|
233
271
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
272
|
+
##### `embeddedJsonataIdentifiers`
|
|
273
|
+
|
|
274
|
+
- **Type**: `string[]`
|
|
275
|
+
- **Default**: [`["jsonata"]`](./src/embedded/jsonata/options.ts)
|
|
276
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded JSONata language. This option requires the `@stedi/prettier-plugin-jsonata` plugin.
|
|
237
277
|
|
|
238
278
|
Formatting embedded JSONata language requires the [`@stedi/prettier-plugin-jsonata`](https://github.com/Stedi/prettier-plugin-jsonata) plugin to be loaded as well.
|
|
239
279
|
|
|
240
280
|
#### LaTeX
|
|
241
281
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
282
|
+
##### `embeddedLatexIdentifiers`
|
|
283
|
+
|
|
284
|
+
- **Type**: `string[]`
|
|
285
|
+
- **Default**: [`["latex", "tex", "aux", "cls", "bbl", "bib", "toc", "sty"]`](./src/embedded/latex/options.ts)
|
|
286
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded LaTeX language. This option requires the `prettier-plugin-latex` plugin.
|
|
245
287
|
|
|
246
288
|
Formatting embedded LaTeX language requires the [`prettier-plugin-latex`](https://github.com/siefkenj/prettier-plugin-latex) plugin to be loaded as well.
|
|
247
289
|
|
|
248
290
|
#### Markdown
|
|
249
291
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
292
|
+
##### `embeddedMarkdownIdentifiers`
|
|
293
|
+
|
|
294
|
+
- **Type**: `string[]`
|
|
295
|
+
- **Default**: [`["md", "markdown"]`](./src/embedded/markdown/options.ts)
|
|
296
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded Markdown language.
|
|
297
|
+
|
|
298
|
+
##### `embeddedMarkdownParser`
|
|
299
|
+
|
|
300
|
+
- **Type**: [`"markdown" | "mdx" | "remark"`](./src/embedded/markdown/options.ts)
|
|
301
|
+
- **Default**: [`"markdown"`](./src/embedded/markdown/options.ts)
|
|
302
|
+
- **Description**: The parser used to parse the embedded Markdown language.
|
|
254
303
|
|
|
255
304
|
Formatting embedded Markdown language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
256
305
|
|
|
257
306
|
This can override the native formatting for embedded Markdown language. If you want to keep the native behavior, set `embeddedMarkdownIdentifiers` to `[]` or other identifiers.
|
|
258
307
|
|
|
259
|
-
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides).
|
|
308
|
+
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
260
309
|
|
|
261
310
|
The `remark` parser is [an alias of the `markdown` parser](https://github.com/prettier/prettier/blob/ed23dacc9e655c3876971b30859497b17ff2cf9f/src/language-markdown/parser-markdown.js#L57).
|
|
262
311
|
|
|
263
312
|
#### NGINX
|
|
264
313
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
314
|
+
##### `embeddedNginxIdentifiers`
|
|
315
|
+
|
|
316
|
+
- **Type**: `string[]`
|
|
317
|
+
- **Default**: [`["nginx"]`](./src/embedded/nginx/options.ts)
|
|
318
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded NGINX language. This option requires the `prettier-plugin-nginx` plugin.
|
|
268
319
|
|
|
269
320
|
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.
|
|
270
321
|
|
|
271
322
|
#### Pegjs
|
|
272
323
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
324
|
+
##### `embeddedPegjsIdentifiers`
|
|
325
|
+
|
|
326
|
+
- **Type**: `string[]`
|
|
327
|
+
- **Default**: [`["pegjs", "peggy", "peg"]`](./src/embedded/pegjs/options.ts)
|
|
328
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded Pegjs language. This option requires the `prettier-plugin-pegjs` plugin.
|
|
276
329
|
|
|
277
330
|
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.
|
|
278
331
|
|
|
279
|
-
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 identifiers, check [`embeddedOverrides`](#embeddedoverrides).
|
|
332
|
+
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 identifiers, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
280
333
|
|
|
281
334
|
#### PHP
|
|
282
335
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
336
|
+
##### `embeddedPhpIdentifiers`
|
|
337
|
+
|
|
338
|
+
- **Type**: `string[]`
|
|
339
|
+
- **Default**: [`["php", "php5"]`](./src/embedded/php/options.ts)
|
|
340
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded PHP language. This option requires the `@prettier/plugin-php` plugin.
|
|
286
341
|
|
|
287
342
|
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.
|
|
288
343
|
|
|
289
344
|
#### Prisma
|
|
290
345
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
346
|
+
##### `embeddedPrismaIdentifiers`
|
|
347
|
+
|
|
348
|
+
- **Type**: `string[]`
|
|
349
|
+
- **Default**: [`["prisma"]`](./src/embedded/prisma/options.ts)
|
|
350
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded Prisma language. This option requires the `prettier-plugin-prisma` plugin.
|
|
294
351
|
|
|
295
352
|
Formatting embedded Prisma language requires the [`prettier-plugin-prisma`](https://github.com/avocadowastaken/prettier-plugin-prisma) plugin to be loaded as well.
|
|
296
353
|
|
|
297
354
|
#### Properties
|
|
298
355
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
356
|
+
##### `embeddedPropertiesIdentifiers`
|
|
357
|
+
|
|
358
|
+
- **Type**: `string[]`
|
|
359
|
+
- **Default**: [`["properties"]`](./src/embedded/properties/options.ts)
|
|
360
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded Properties language. This option requires the `prettier-plugin-properties` plugin.
|
|
302
361
|
|
|
303
362
|
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.
|
|
304
363
|
|
|
305
364
|
#### Pug
|
|
306
365
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
366
|
+
##### `embeddedPugIdentifiers`
|
|
367
|
+
|
|
368
|
+
- **Type**: `string[]`
|
|
369
|
+
- **Default**: [`["pug", "jade"]`](./src/embedded/pug/options.ts)
|
|
370
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded Pug language. This option requires the `@prettier/plugin-pug` plugin.
|
|
310
371
|
|
|
311
372
|
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.
|
|
312
373
|
|
|
313
374
|
#### Ruby
|
|
314
375
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
376
|
+
##### `embeddedRubyIdentifiers`
|
|
377
|
+
|
|
378
|
+
- **Type**: `string[]`
|
|
379
|
+
- **Default**: [`["ruby"]`](./src/embedded/ruby/options.ts)
|
|
380
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded Ruby language. This option requires the `@prettier/plugin-ruby` plugin.
|
|
381
|
+
|
|
382
|
+
##### `embeddedRubyParser`
|
|
383
|
+
|
|
384
|
+
- **Type**: [`"ruby" | "rbs" | "haml"`](./src/embedded/ruby/options.ts)
|
|
385
|
+
- **Default**: [`"ruby"`](./src/embedded/ruby/options.ts)
|
|
386
|
+
- **Description**: The parser used to parse the embedded Ruby language. This option requires the `@prettier/plugin-ruby` plugin.
|
|
319
387
|
|
|
320
388
|
Formatting embedded Ruby language requires the [`@prettier/plugin-ruby`](https://github.com/prettier/plugin-ruby) to be loaded and [its dependencies to be installed](https://github.com/prettier/plugin-ruby#getting-started) as well. And [options](https://github.com/prettier/plugin-ruby#configuration) supported by `@prettier/plugin-ruby` can therefore be used to further control the formatting behavior.
|
|
321
389
|
|
|
322
|
-
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides).
|
|
390
|
+
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
323
391
|
|
|
324
392
|
#### Sh (Shell)
|
|
325
393
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
394
|
+
##### `embeddedShIdentifiers`
|
|
395
|
+
|
|
396
|
+
- **Type**: `string[]`
|
|
397
|
+
- **Default**: [`["sh"]`](./src/embedded/sh/options.ts)
|
|
398
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded Shell language. This option requires the `prettier-plugin-sh` plugin.
|
|
329
399
|
|
|
330
400
|
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.
|
|
331
401
|
|
|
332
|
-
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 identifiers, check [`embeddedOverrides`](#embeddedoverrides).
|
|
402
|
+
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 identifiers, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
333
403
|
|
|
334
404
|
#### SQL
|
|
335
405
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
406
|
+
##### `embeddedSqlIdentifiers`
|
|
407
|
+
|
|
408
|
+
- **Type**: `string[]`
|
|
409
|
+
- **Default**: [`["sql"]`](./src/embedded/sql/options.ts)
|
|
410
|
+
- **Description**: Tag or comment 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.
|
|
411
|
+
|
|
412
|
+
##### `embeddedSqlPlugin`
|
|
413
|
+
|
|
414
|
+
- **Type**: [`"prettier-plugin-sql" | "prettier-plugin-sql-cst"`](./src/embedded/sql/options.ts)
|
|
415
|
+
- **Default**: [`"prettier-plugin-sql"`](./src/embedded/sql/options.ts)
|
|
416
|
+
- **Description**: The plugin used to format the embedded SQL language. This option requires the `prettier-plugin-sql` plugin or the `prettier-plugin-sql-cst` plugin.
|
|
417
|
+
|
|
418
|
+
##### `embeddedSqlParser`
|
|
419
|
+
|
|
420
|
+
- **Type**: [`"sqlite" | "bigquery" | "mysql" | "mariadb" | "postgresql"` ](./src/embedded/sql/options.ts)
|
|
421
|
+
- **Default**: [`"sqlite"`](./src/embedded/sql/options.ts)
|
|
422
|
+
- **Description**: Specify the embedded SQL language parser. This option is only needed with the `prettier-plugin-sql-cst` plugin.
|
|
341
423
|
|
|
342
424
|
Formatting embedded SQL language requires the [`prettier-plugin-sql`](https://github.com/un-ts/prettier/tree/master/packages/sql#readme) plugin or the [`prettier-plugin-sql-cst`](https://github.com/nene/prettier-plugin-sql-cst) plugin to be loaded as well. And [options](https://github.com/un-ts/prettier/tree/master/packages/sql#parser-options) supported by `prettier-plugin-sql`, or [options](https://github.com/nene/prettier-plugin-sql-cst?tab=readme-ov-file#configuration) supported by `prettier-plugin-sql-cst` can therefore be used to further control the formatting behavior.
|
|
343
425
|
|
|
344
|
-
Note that `prettier-plugin-sql` supports many different SQL dialects which are specified by the [`language`, `database` or `dialect` option](https://github.com/un-ts/prettier/tree/master/packages/sql#parser-options). And `prettier-plugin-sql-cst` also supports various parsers as shown above. If you want to specify different dialects or parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides).
|
|
426
|
+
Note that `prettier-plugin-sql` supports many different SQL dialects which are specified by the [`language`, `database` or `dialect` option](https://github.com/un-ts/prettier/tree/master/packages/sql#parser-options). And `prettier-plugin-sql-cst` also supports various parsers as shown above. If you want to specify different dialects or parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
345
427
|
|
|
346
428
|
#### TOML
|
|
347
429
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
430
|
+
##### `embeddedTomlIdentifiers`
|
|
431
|
+
|
|
432
|
+
- **Type**: `string[]`
|
|
433
|
+
- **Default**: [`["toml"]`](./src/embedded/toml/options.ts)
|
|
434
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded TOML language. This option requires the `prettier-plugin-toml` plugin.
|
|
351
435
|
|
|
352
436
|
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.
|
|
353
437
|
|
|
354
438
|
#### TS (TypeScript)
|
|
355
439
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
440
|
+
##### `embeddedTsIdentifiers`
|
|
441
|
+
|
|
442
|
+
- **Type**: `string[]`
|
|
443
|
+
- **Default**: [`["ts", "tsx", "cts", "mts", "typescript"]`](./src/embedded/ts/options.ts)
|
|
444
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded TypeScript language.
|
|
445
|
+
|
|
446
|
+
##### `embeddedTsParser`
|
|
447
|
+
|
|
448
|
+
- **Type**: [`"typescript" | "babel-ts"`](./src/embedded/ts/options.ts)
|
|
449
|
+
- **Default**: [`"typescript"`](./src/embedded/ts/options.ts)
|
|
450
|
+
- **Description**: The parser used to parse the embedded TypeScript language.
|
|
360
451
|
|
|
361
452
|
Formatting embedded TypeScript language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
362
453
|
|
|
363
|
-
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides).
|
|
454
|
+
If you want to specify different parsers for different identifiers, check [`embeddedOverrides`](#embeddedoverrides-1).
|
|
364
455
|
|
|
365
456
|
#### XML
|
|
366
457
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
458
|
+
##### `embeddedXmlIdentifiers`
|
|
459
|
+
|
|
460
|
+
- **Type**: `string[]`
|
|
461
|
+
- **Default**: [`["xml", "opml", "rss", "svg"]`](./src/embedded/xml/options.ts)
|
|
462
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded XML language. This option requires the `@prettier/plugin-xml` plugin.
|
|
370
463
|
|
|
371
464
|
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.
|
|
372
465
|
|
|
373
466
|
#### YAML
|
|
374
467
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
468
|
+
##### `embeddedYamlIdentifiers`
|
|
469
|
+
|
|
470
|
+
- **Type**: `string[]`
|
|
471
|
+
- **Default**: [`["yaml", "yml"]`](./src/embedded/yaml/options.ts)
|
|
472
|
+
- **Description**: Tag or comment identifiers that make their subsequent template literals be identified as embedded YAML language.
|
|
378
473
|
|
|
379
474
|
Formatting embedded YAML language doesn't require other plugins and uses the parsers and printers provided by Prettier natively.
|
|
380
475
|
|
|
@@ -382,23 +477,51 @@ Formatting embedded YAML language doesn't require other plugins and uses the par
|
|
|
382
477
|
|
|
383
478
|
### Language-Agnostic Options
|
|
384
479
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
480
|
+
#### Language-Agnostic
|
|
481
|
+
|
|
482
|
+
##### `noEmbeddedIdentificationByComment`
|
|
483
|
+
|
|
484
|
+
- **Type**: `string[]`
|
|
485
|
+
- **Default**: `[]`
|
|
486
|
+
- **Description**: Turns off `` /* identifier */ `...` `` comment-based embedded language identification for the specified identifiers.
|
|
487
|
+
|
|
488
|
+
##### `noEmbeddedIdentificationByTag`
|
|
489
|
+
|
|
490
|
+
- **Type**: `string[]`
|
|
491
|
+
- **Default**: `[]`
|
|
492
|
+
- **Description**: Turns off `` identifier`...` `` tag-based embedded language identification for the specified identifiers.
|
|
493
|
+
|
|
494
|
+
##### `preserveEmbeddedExteriorWhitespaces`
|
|
495
|
+
|
|
496
|
+
- **Type**: `string[]`
|
|
497
|
+
- **Default**: `[]`
|
|
498
|
+
- **Description**: Preserves leading and trailing whitespaces in the formatting results for the specified identifiers.
|
|
499
|
+
|
|
500
|
+
##### `noEmbeddedMultiLineIndentation`
|
|
501
|
+
|
|
502
|
+
- **Type**: `string[]`
|
|
503
|
+
- **Default**: `[]`
|
|
504
|
+
- **Description**: Turns off auto indentation in the formatting results when they are formatted to span multi lines for the specified identifiers.
|
|
505
|
+
|
|
506
|
+
##### `embeddedOverrides`
|
|
507
|
+
|
|
508
|
+
- **Type**: `string`
|
|
509
|
+
- **Default**: `undefined`
|
|
510
|
+
- **Description**: Option overrides for the specified identifiers. It should either be a stringified JSON or an absolute filepath to the option overrides file. See [below](#embeddedoverrides-1) for a detailed explanation.
|
|
392
511
|
|
|
393
512
|
#### `embeddedOverrides`
|
|
394
513
|
|
|
395
|
-
This option is provided for users to override certain options based on identifiers. 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
|
|
514
|
+
This option is provided for users to override certain options based on identifiers. 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.
|
|
515
|
+
|
|
516
|
+
> [!NOTE]
|
|
517
|
+
>
|
|
518
|
+
> The support for using `.ts`, `.mts` or `.cts` files for `embeddedOverrides` requires a minimal `node` version of [18.19.0](https://nodejs.org/en/blog/release/v18.19.0#esm-and-customization-hook-changes), and [`tsx`](https://github.com/privatenumber/tsx) as a dependency in your project. And it currently doesn't work with the Prettier VSCode extension.
|
|
396
519
|
|
|
397
520
|
The resolved value should be an array of objects. Each object in the array must have 2 fields: `identifiers` and `options`. The `options` are considerred overrides that will be applied to the global `options` of prettier for those `idenfitiers` only. It's like the [`overrides`](https://prettier.io/docs/en/configuration.html#configuration-overrides) of `prettier`, but it is identifier-based instead of file-based.
|
|
398
521
|
|
|
399
522
|
In a json file, the root is the array of objects. In a JavaScript file, the array of objects should be a default export, or a named export with the name `embeddedOverrides`.
|
|
400
523
|
|
|
401
|
-
An example `.json` file is:
|
|
524
|
+
An example `.json`/`.jsonc` file is:
|
|
402
525
|
|
|
403
526
|
```json
|
|
404
527
|
[
|
|
@@ -15,8 +15,8 @@ import * as __glob__0_8 from "./jsonata/index.js";
|
|
|
15
15
|
import * as __glob__0_9 from "./latex/index.js";
|
|
16
16
|
import * as __glob__0_10 from "./markdown/index.js";
|
|
17
17
|
import * as __glob__0_11 from "./nginx/index.js";
|
|
18
|
-
import * as __glob__0_12 from "./
|
|
19
|
-
import * as __glob__0_13 from "./
|
|
18
|
+
import * as __glob__0_12 from "./noop/index.js";
|
|
19
|
+
import * as __glob__0_13 from "./pegjs/index.js";
|
|
20
20
|
import * as __glob__0_14 from "./php/index.js";
|
|
21
21
|
import * as __glob__0_15 from "./prisma/index.js";
|
|
22
22
|
import * as __glob__0_16 from "./properties/index.js";
|