prettier-plugin-embed 0.3.0-rc.0 → 0.3.0-rc.2
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 +10 -18
- package/dist/embedded/css/embedder.d.ts +1 -1
- package/dist/embedded/es/embedder.d.ts +1 -1
- package/dist/embedded/html/embedder.d.ts +1 -1
- package/dist/embedded/index.d.ts +1 -1
- package/dist/embedded/noop/options.d.ts +1 -1
- package/dist/embedded/register.d.ts +1 -1
- package/dist/embedded/ts/embedder.d.ts +1 -1
- package/dist/embedded/types.d.ts +1 -1
- package/dist/embedded/utils.d.ts +2 -3
- package/dist/embedded/xml/embedder.d.ts +1 -1
- package/dist/embedded/xml/index.d.ts +1 -1
- package/dist/embedded/xml/parser.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +808 -738
- package/dist/options.d.ts +1 -1
- package/dist/types.d.ts +9 -4
- package/dist/utils.d.ts +5 -0
- package/package.json +10 -8
package/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
# Prettier Plugin Embed
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/prettier-plugin-embed/v/latest) [](https://www.npmjs.com/package/prettier-plugin-embed/v/latest) [](https://www.npmjs.com/package/prettier-plugin-embed/v/latest)
|
|
8
|
+
|
|
9
|
+
[](https://github.com/Sec-ant/prettier-plugin-embed) [](https://bundlephobia.com/package/prettier-plugin-embed@latest) [](https://www.jsdelivr.com/package/npm/prettier-plugin-embed)
|
|
8
10
|
|
|
9
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.
|
|
10
12
|
|
|
@@ -50,20 +52,6 @@ By leveraging Prettier's plugin system, this plugin overrides the default [`embe
|
|
|
50
52
|
npm i -D prettier-plugin-embed
|
|
51
53
|
```
|
|
52
54
|
|
|
53
|
-
Peer dependecies are automatically installed by default if you're using npm v7 or higher versions. The peer dependencies of this plugin are mainly packages to support parsing and formatting for different languages. If you only plan to use this plugin for a very specific language and don't want to bloat your node modules folder, you can omit the peer dependencies by changing the installation command to either:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
npm i -D --legacy-peer-deps prettier-plugin-embed
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
or:
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
npm i -D --omit=peer prettier-plugin-embed
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
For other package managers, refer to their documents on how to achieve the same result.
|
|
66
|
-
|
|
67
55
|
## Usage
|
|
68
56
|
|
|
69
57
|
### Getting Started
|
|
@@ -214,9 +202,13 @@ Formatting embedded XML code requires [`@prettier/plugin-xml`](https://github.co
|
|
|
214
202
|
|
|
215
203
|
#### `embeddedOverrides`
|
|
216
204
|
|
|
217
|
-
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 an
|
|
205
|
+
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` or `.js` or `.cjs` or `.mjs` as its value. If no extension is provided, it will be treated as a `.json` file. For relative paths, it will automatically figure out the prettier config location and use that as the base path.
|
|
206
|
+
|
|
207
|
+
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.
|
|
208
|
+
|
|
209
|
+
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`.
|
|
218
210
|
|
|
219
|
-
|
|
211
|
+
An example `.json` file is:
|
|
220
212
|
|
|
221
213
|
```json
|
|
222
214
|
[
|
package/dist/embedded/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from "./register.js";
|
|
2
|
-
export type {
|
|
2
|
+
export type { EmbeddedDefaultIdentifier, EmbeddedEmbedders, EmbeddedLanguage, EmbeddedOptions, EmbeddedParsers, PrettierPluginEmbedOptions, } from "./types.js";
|
|
3
3
|
export { makeIdentifiersOptionName, type AutocompleteStringList, } from "./utils.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type AutocompleteStringList } from "../utils.js";
|
|
2
1
|
import type { EmbeddedDefaultIdentifier } from "../types.js";
|
|
2
|
+
import { type AutocompleteStringList } from "../utils.js";
|
|
3
3
|
type EmbeddedIdentifiers = AutocompleteStringList<EmbeddedDefaultIdentifier[]>;
|
|
4
4
|
declare const embeddedLanguageIdentifiers: "embeddedNoopIdentifiers";
|
|
5
5
|
export declare const options: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EmbeddedEmbedders, EmbeddedLanguage,
|
|
1
|
+
import type { EmbeddedEmbedders, EmbeddedLanguage, EmbeddedOptions, EmbeddedParsers } from "./types.js";
|
|
2
2
|
export declare const embeddedLanguages: EmbeddedLanguage[];
|
|
3
3
|
export declare const embeddedParsers: EmbeddedParsers;
|
|
4
4
|
export declare const embeddedEmbedders: EmbeddedEmbedders;
|
package/dist/embedded/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Parser, SupportOption
|
|
1
|
+
import type { Options, Parser, SupportOption } from "prettier";
|
|
2
2
|
import type { Embedder } from "../types.js";
|
|
3
3
|
import type { Satisfies } from "./utils.js";
|
|
4
4
|
type EmbeddedLanguageNamingConvention = `embedded${Capitalize<string>}`;
|
package/dist/embedded/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AstPath,
|
|
1
|
+
import type { Comment, Expression, TemplateLiteral } from "estree";
|
|
2
|
+
import type { AstPath, Doc, Options } from "prettier";
|
|
3
3
|
import { builders } from "prettier/doc";
|
|
4
4
|
import type { InternalPrintFun } from "../types.js";
|
|
5
5
|
export declare function printTemplateExpression(path: AstPath<Expression & {
|
|
@@ -22,4 +22,3 @@ export type StringListToInterfaceKey<T extends readonly string[]> = {
|
|
|
22
22
|
[key in T[number]]: void;
|
|
23
23
|
};
|
|
24
24
|
export type Satisfies<U, T extends U> = T;
|
|
25
|
-
export declare const parseEmbeddedOverrideOptions: import("micro-memoize").Memoized<(embeddedOverrides: string | undefined, identifier: string) => Omit<Omit<Options, keyof import("./types.js").PrettierPluginEmbedOptions> & Omit<import("./types.js").PrettierPluginEmbedOptions, "embeddedNoopIdentifiers" | "embeddedCssIdentifiers" | "embeddedEsIdentifiers" | "embeddedGlslIdentifiers" | "embeddedHtmlIdentifiers" | "embeddedMarkdownIdentifiers" | "embeddedPhpIdentifiers" | "embeddedRubyIdentifiers" | "embeddedSqlIdentifiers" | "embeddedTsIdentifiers" | "embeddedXmlIdentifiers" | keyof import("../options.js").PrettierPluginGlobalOptions>, "parser" | "filepath" | "endOfLine" | "embeddedLanguageFormatting" | "printWidth" | "tabWidth" | "useTabs" | `__${string}`> | undefined>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
export * from "./embedded/index.js";
|
|
2
|
+
export { options } from "./options.js";
|
|
1
3
|
export { parsers } from "./parsers.js";
|
|
2
4
|
export { printers } from "./printers.js";
|
|
3
|
-
export { options } from "./options.js";
|
|
4
5
|
export type * from "./types.js";
|
|
5
|
-
export * from "./embedded/index.js";
|