prettier-plugin-embed 0.3.0-rc.0 → 0.3.0-rc.1
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 -4
- 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 +6 -6
- 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 +906 -811
- package/dist/options.d.ts +1 -1
- package/dist/types.d.ts +9 -4
- package/dist/utils.d.ts +5 -0
- package/package.json +8 -3
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
|
|
|
@@ -214,9 +216,13 @@ Formatting embedded XML code requires [`@prettier/plugin-xml`](https://github.co
|
|
|
214
216
|
|
|
215
217
|
#### `embeddedOverrides`
|
|
216
218
|
|
|
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
|
|
219
|
+
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.
|
|
220
|
+
|
|
221
|
+
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.
|
|
222
|
+
|
|
223
|
+
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
224
|
|
|
219
|
-
|
|
225
|
+
An example `.json` file is:
|
|
220
226
|
|
|
221
227
|
```json
|
|
222
228
|
[
|
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,14 +1,14 @@
|
|
|
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;
|
|
5
5
|
export declare const embeddedOptions: EmbeddedOptions;
|
|
6
6
|
import * as __glob__0_0 from "./css/index.js";
|
|
7
|
-
import * as __glob__0_1 from "./
|
|
8
|
-
import * as __glob__0_2 from "./
|
|
9
|
-
import * as __glob__0_3 from "./
|
|
10
|
-
import * as __glob__0_4 from "./
|
|
11
|
-
import * as __glob__0_5 from "./
|
|
7
|
+
import * as __glob__0_1 from "./glsl/index.js";
|
|
8
|
+
import * as __glob__0_2 from "./markdown/index.js";
|
|
9
|
+
import * as __glob__0_3 from "./noop/index.js";
|
|
10
|
+
import * as __glob__0_4 from "./es/index.js";
|
|
11
|
+
import * as __glob__0_5 from "./html/index.js";
|
|
12
12
|
import * as __glob__0_6 from "./php/index.js";
|
|
13
13
|
import * as __glob__0_7 from "./ruby/index.js";
|
|
14
14
|
import * as __glob__0_8 from "./sql/index.js";
|
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";
|