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 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
 
@@ -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 **absolute** json file path as its value.
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
- 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:
211
+ An example `.json` file is:
220
212
 
221
213
  ```json
222
214
  [
@@ -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,4 +1,4 @@
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;
@@ -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";