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 CHANGED
@@ -1,10 +1,12 @@
1
1
  <div align="center">
2
2
 
3
- ![prettier-plugin-embed-light](./public/prettier-plugin-embed-wide-light.svg)
3
+ ![prettier-plugin-embed-light](./asset/prettier-plugin-embed-wide-light.svg)
4
4
 
5
5
  # Prettier Plugin Embed
6
6
 
7
- [![npm](https://img.shields.io/npm/v/prettier-plugin-embed)](https://www.npmjs.com/package/prettier-plugin-embed/v/latest) [![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/prettier-plugin-embed)](https://www.npmjs.com/package/prettier-plugin-embed/v/latest) [![jsDelivr hits (npm scoped)](https://img.shields.io/jsdelivr/npm/hm/prettier-plugin-embed?color=%23ff5627)](https://cdn.jsdelivr.net/npm/prettier-plugin-embed@latest/)
7
+ [![npm version](https://badgen.net/npm/v/prettier-plugin-embed?cache=300)](https://www.npmjs.com/package/prettier-plugin-embed/v/latest) [![npm downloads](https://badgen.net/npm/dm/prettier-plugin-embed?cache=300)](https://www.npmjs.com/package/prettier-plugin-embed/v/latest) [![npm license](https://badgen.net/npm/license/prettier-plugin-embed?cache=300)](https://www.npmjs.com/package/prettier-plugin-embed/v/latest)
8
+
9
+ [![github last commit](https://badgen.net/github/last-commit/Sec-ant/prettier-plugin-embed?cache=300)](https://github.com/Sec-ant/prettier-plugin-embed) [![bundlephobia minzipped](https://badgen.net/bundlephobia/minzip/prettier-plugin-embed?cache=300)](https://bundlephobia.com/package/prettier-plugin-embed@latest) [![](https://data.jsdelivr.com/v1/package/npm/prettier-plugin-embed/badge?style=rounded)](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 **absolute** json file path as its value.
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
- The value should be an array of objects. Each object 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. An example is:
225
+ An example `.json` file is:
220
226
 
221
227
  ```json
222
228
  [
@@ -1,4 +1,4 @@
1
- import { type Options } from "prettier";
1
+ import type { Options } from "prettier";
2
2
  import type { Embedder } from "../../types.js";
3
3
  import { embeddedLanguage } from "./embedded-language.js";
4
4
  export declare const embedder: Embedder<Options>;
@@ -1,4 +1,4 @@
1
- import { type Options } from "prettier";
1
+ import type { Options } from "prettier";
2
2
  import type { Embedder } from "../../types.js";
3
3
  import { embeddedLanguage } from "./embedded-language.js";
4
4
  export declare const embedder: Embedder<Options>;
@@ -1,4 +1,4 @@
1
- import { type Options } from "prettier";
1
+ import type { Options } from "prettier";
2
2
  import type { Embedder } from "../../types.js";
3
3
  import { embeddedLanguage } from "./embedded-language.js";
4
4
  export declare const embedder: Embedder<Options>;
@@ -1,3 +1,3 @@
1
1
  export * from "./register.js";
2
- export type { EmbeddedLanguage, EmbeddedParsers, EmbeddedEmbedders, EmbeddedOptions, EmbeddedDefaultIdentifier, PrettierPluginEmbedOptions, } from "./types.js";
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, EmbeddedParsers, EmbeddedOptions } from "./types.js";
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 "./es/index.js";
8
- import * as __glob__0_2 from "./glsl/index.js";
9
- import * as __glob__0_3 from "./html/index.js";
10
- import * as __glob__0_4 from "./markdown/index.js";
11
- import * as __glob__0_5 from "./noop/index.js";
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";
@@ -1,4 +1,4 @@
1
- import { type Options } from "prettier";
1
+ import type { Options } from "prettier";
2
2
  import type { Embedder } from "../../types.js";
3
3
  import { embeddedLanguage } from "./embedded-language.js";
4
4
  export declare const embedder: Embedder<Options>;
@@ -1,4 +1,4 @@
1
- import type { Parser, SupportOption, Options } from "prettier";
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>}`;
@@ -1,5 +1,5 @@
1
- import type { Expression, Comment, TemplateLiteral } from "estree";
2
- import type { AstPath, Options, Doc } from "prettier";
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>;
@@ -1,4 +1,4 @@
1
- import { type Options } from "prettier";
1
+ import type { Options } from "prettier";
2
2
  import type { Embedder } from "../../types.js";
3
3
  import { embeddedLanguage } from "./embedded-language.js";
4
4
  export declare const embedder: Embedder<Options>;
@@ -1,4 +1,4 @@
1
1
  export * from "./embedded-language.js";
2
- export * from "./parser.js";
3
2
  export * from "./embedder.js";
4
3
  export * from "./options.js";
4
+ export * from "./parser.js";
@@ -1,5 +1,5 @@
1
- import type { Parser } from "prettier";
2
1
  import type { CstNode } from "chevrotain";
2
+ import type { Parser } from "prettier";
3
3
  import { embeddedLanguage } from "./embedded-language.js";
4
4
  export declare const parser: Parser<CstNode>;
5
5
  declare module "../types.js" {
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";