prettier-plugin-embed 0.4.4 → 0.4.6

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/dist/options.d.ts CHANGED
@@ -13,7 +13,7 @@ export declare const options: {
13
13
  readonly default: [{
14
14
  readonly value: [];
15
15
  }];
16
- readonly description: "This option turns off \"/* identifier */ `...`\" comment-based language identification for the specified identifiers.";
16
+ readonly description: "Turns off `` /* identifier */ `...` `` comment-based embedded language identification for the specified identifiers.";
17
17
  };
18
18
  readonly noEmbeddedIdentificationByTag: {
19
19
  readonly category: "Embed";
@@ -22,16 +22,16 @@ export declare const options: {
22
22
  readonly default: [{
23
23
  readonly value: [];
24
24
  }];
25
- readonly description: "This option turns off \"identifier`...`\" tag-based language identification for the specified identifiers.";
25
+ readonly description: "Turns off `` identifier`...` `` tag-based embedded language identification for the specified identifiers.";
26
26
  };
27
27
  readonly preserveEmbeddedExteriorWhitespaces: {
28
- readonly category: "Config";
28
+ readonly category: "Embed";
29
29
  readonly type: "string";
30
30
  readonly array: true;
31
31
  readonly default: [{
32
32
  readonly value: [];
33
33
  }];
34
- readonly description: "This option preserves leading and trailing whitespaces in the formatting results for the specified identifiers.";
34
+ readonly description: "Preserves leading and trailing whitespaces in the formatting results for the specified identifiers.";
35
35
  };
36
36
  readonly noEmbeddedMultiLineIndentation: {
37
37
  readonly category: "Embed";
@@ -40,14 +40,14 @@ export declare const options: {
40
40
  readonly default: [{
41
41
  readonly value: [];
42
42
  }];
43
- readonly description: "This option turns off auto indentation in the formatting results for the specified identifiers when they are formatted to span multi lines.";
43
+ readonly description: "Turns off auto indentation in the formatting results for the specified identifiers when they are formatted to span multi lines.";
44
44
  };
45
45
  readonly embeddedOverrides: {
46
46
  readonly category: "Embed";
47
47
  readonly type: "string";
48
48
  readonly array: false;
49
49
  readonly default: undefined;
50
- readonly description: "This option accepts option overrides for the specified identifiers. It should either be a stringified JSON or an absolute filepath to the option overrides file.";
50
+ readonly description: "Option overrides for the specified identifiers. It should either be a stringified JSON or an absolute filepath to the option overrides file.";
51
51
  };
52
52
  readonly embeddedNoopIdentifiers: {
53
53
  readonly category: "Embed";
@@ -56,7 +56,7 @@ export declare const options: {
56
56
  readonly default: [{
57
57
  readonly value: [];
58
58
  }];
59
- readonly description: "Specify embedded language identifiers that will not be formatted.";
59
+ readonly description: "Tag or comment identifiers that prevent their subsequent template literals from being identified as embedded languages and thus from being formatted.";
60
60
  };
61
61
  readonly embeddedCssIdentifiers: {
62
62
  readonly category: "Embed";
@@ -65,7 +65,7 @@ export declare const options: {
65
65
  readonly default: [{
66
66
  readonly value: ["css"];
67
67
  }];
68
- readonly description: "Specify embedded CSS language identifiers.";
68
+ readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded CSS language.";
69
69
  };
70
70
  readonly embeddedEsIdentifiers: {
71
71
  readonly category: "Embed";
@@ -74,7 +74,7 @@ export declare const options: {
74
74
  readonly default: [{
75
75
  readonly value: ["js", "jsx", "es", "es6", "mjs", "cjs", "pac", "javascript"];
76
76
  }];
77
- readonly description: "Specify embedded ES language identifiers.";
77
+ readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded ECMAScript/JavaScript language.";
78
78
  };
79
79
  readonly embeddedEsParser: {
80
80
  category: string;
@@ -93,7 +93,7 @@ export declare const options: {
93
93
  readonly default: [{
94
94
  readonly value: ["glsl", "shader"];
95
95
  }];
96
- readonly description: "Specify embedded GLSL language identifiers. This requires \"prettier-plugin-glsl\".";
96
+ readonly 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.";
97
97
  };
98
98
  readonly embeddedGraphqlIdentifiers: {
99
99
  readonly category: "Embed";
@@ -102,7 +102,7 @@ export declare const options: {
102
102
  readonly default: [{
103
103
  readonly value: ["graphql", "gql"];
104
104
  }];
105
- readonly description: "Specify embedded GraphQL language identifiers.";
105
+ readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded GraphQL language.";
106
106
  };
107
107
  readonly embeddedHtmlIdentifiers: {
108
108
  readonly category: "Embed";
@@ -111,7 +111,17 @@ export declare const options: {
111
111
  readonly default: [{
112
112
  readonly value: ["html", "xhtml"];
113
113
  }];
114
- readonly description: "Specify embedded HTML language identifiers.";
114
+ readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded HTML language.";
115
+ };
116
+ readonly embeddedHtmlParser: {
117
+ category: string;
118
+ type: "choice";
119
+ default: "html";
120
+ description: string;
121
+ choices: {
122
+ value: "html" | "vue" | "angular" | "lwc";
123
+ description: string;
124
+ }[];
115
125
  };
116
126
  readonly embeddedIniIdentifiers: {
117
127
  readonly category: "Embed";
@@ -120,7 +130,7 @@ export declare const options: {
120
130
  readonly default: [{
121
131
  readonly value: ["ini", "cfg", "pro"];
122
132
  }];
123
- readonly description: "Specify embedded INI language identifiers. This requires \"prettier-plugin-ini\".";
133
+ readonly 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.";
124
134
  };
125
135
  readonly embeddedJsonIdentifiers: {
126
136
  readonly category: "Embed";
@@ -129,7 +139,7 @@ export declare const options: {
129
139
  readonly default: [{
130
140
  readonly value: ["json", "jsonl"];
131
141
  }];
132
- readonly description: "Specify embedded JSON language identifiers.";
142
+ readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded JSON language.";
133
143
  };
134
144
  readonly embeddedJsonParser: {
135
145
  category: string;
@@ -137,7 +147,7 @@ export declare const options: {
137
147
  default: "json";
138
148
  description: string;
139
149
  choices: {
140
- value: "json" | "json-stringify" | "json5";
150
+ value: "json" | "json5" | "jsonc" | "json-stringify";
141
151
  description: string;
142
152
  }[];
143
153
  };
@@ -148,7 +158,7 @@ export declare const options: {
148
158
  readonly default: [{
149
159
  readonly value: ["latex", "tex", "aux", "cls", "bbl", "bib", "toc", "sty"];
150
160
  }];
151
- readonly description: "Specify embedded LaTeX language identifiers. This requires \"prettier-plugin-latex\".";
161
+ readonly 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.";
152
162
  };
153
163
  readonly embeddedMarkdownIdentifiers: {
154
164
  readonly category: "Embed";
@@ -157,7 +167,7 @@ export declare const options: {
157
167
  readonly default: [{
158
168
  readonly value: ["md", "markdown"];
159
169
  }];
160
- readonly description: "Specify embedded Markdown language identifiers.";
170
+ readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded Markdown language.";
161
171
  };
162
172
  readonly embeddedPhpIdentifiers: {
163
173
  readonly category: "Embed";
@@ -166,7 +176,7 @@ export declare const options: {
166
176
  readonly default: [{
167
177
  readonly value: ["php", "php5"];
168
178
  }];
169
- readonly description: "Specify embedded PHP language identifiers. This requires \"@prettier/plugin-php\".";
179
+ readonly 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.";
170
180
  };
171
181
  readonly embeddedPropertiesIdentifiers: {
172
182
  readonly category: "Embed";
@@ -175,7 +185,7 @@ export declare const options: {
175
185
  readonly default: [{
176
186
  readonly value: ["properties"];
177
187
  }];
178
- readonly description: "Specify embedded Java Properties language identifiers. This requires \"prettier-plugin-properties\".";
188
+ readonly 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.";
179
189
  };
180
190
  readonly embeddedRubyIdentifiers: {
181
191
  readonly category: "Embed";
@@ -184,7 +194,7 @@ export declare const options: {
184
194
  readonly default: [{
185
195
  readonly value: ["ruby"];
186
196
  }];
187
- readonly description: "Specify embedded Ruby language identifiers. This requires \"@prettier/plugin-ruby\".";
197
+ readonly 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.";
188
198
  };
189
199
  readonly embeddedRubyParser: {
190
200
  category: string;
@@ -203,7 +213,7 @@ export declare const options: {
203
213
  readonly default: [{
204
214
  readonly value: ["sh"];
205
215
  }];
206
- readonly description: "Specify embedded Shell language identifiers.";
216
+ readonly 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.";
207
217
  };
208
218
  readonly embeddedSqlIdentifiers: {
209
219
  readonly category: "Embed";
@@ -212,7 +222,7 @@ export declare const options: {
212
222
  readonly default: [{
213
223
  readonly value: ["sql"];
214
224
  }];
215
- readonly description: "Specify embedded SQL language identifiers. This requires \"prettier-plugin-sql\" or \"prettier-plugin-sql-cst\".";
225
+ readonly 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.";
216
226
  };
217
227
  readonly embeddedSqlPlugin: {
218
228
  category: string;
@@ -241,7 +251,7 @@ export declare const options: {
241
251
  readonly default: [{
242
252
  readonly value: ["toml"];
243
253
  }];
244
- readonly description: "Specify embedded TOML language identifiers. This requires \"prettier-plugin-toml\".";
254
+ readonly 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.";
245
255
  };
246
256
  readonly embeddedTsIdentifiers: {
247
257
  readonly category: "Embed";
@@ -250,7 +260,7 @@ export declare const options: {
250
260
  readonly default: [{
251
261
  readonly value: ["ts", "tsx", "cts", "mts", "typescript"];
252
262
  }];
253
- readonly description: "Specify embedded TS language parsers.";
263
+ readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded TypeScript language.";
254
264
  };
255
265
  readonly embeddedTsParser: {
256
266
  category: string;
@@ -269,7 +279,7 @@ export declare const options: {
269
279
  readonly default: [{
270
280
  readonly value: ["xml", "opml", "rss", "svg"];
271
281
  }];
272
- readonly description: "Specify embedded XML language identifiers. This requires \"@prettier/plugin-xml\".";
282
+ readonly 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.";
273
283
  };
274
284
  readonly __embeddedXmlFragmentRecoverIndex: {
275
285
  readonly category: "Embed";
@@ -278,7 +288,7 @@ export declare const options: {
278
288
  readonly default: [{
279
289
  readonly value: [];
280
290
  }];
281
- readonly description: "This option is read only and used as a workaround to support xml fragments";
291
+ readonly description: "This option is read only and is used internally as a workaround to support xml fragments";
282
292
  };
283
293
  readonly embeddedYamlIdentifiers: {
284
294
  readonly category: "Embed";
@@ -287,7 +297,7 @@ export declare const options: {
287
297
  readonly default: [{
288
298
  readonly value: ["yaml", "yml"];
289
299
  }];
290
- readonly description: "Specify embedded YAML language identifiers.";
300
+ readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded YAML language.";
291
301
  };
292
302
  };
293
303
  export interface PrettierPluginGlobalOptions {
package/dist/parsers.d.ts CHANGED
@@ -17,5 +17,6 @@ export declare const parsers: {
17
17
  __babel_estree: import("prettier").Parser<any>;
18
18
  json: import("prettier").Parser<any>;
19
19
  json5: import("prettier").Parser<any>;
20
+ jsonc: import("prettier").Parser<any>;
20
21
  "json-stringify": import("prettier").Parser<any>;
21
22
  };
package/dist/types.d.ts CHANGED
@@ -1,14 +1,26 @@
1
- import type { Comment, Node as EsTreeNode, TemplateLiteral } from "estree";
1
+ import type { TemplateLiteral } from "estree";
2
2
  import type { AstPath, Doc, Options } from "prettier";
3
3
  import { makeIdentifiersOptionName, type AutocompleteStringList, type EmbeddedDefaultIdentifier, type EmbeddedLanguage, type PrettierPluginEmbedOptions } from "./embedded/index.js";
4
4
  import type { PrettierPluginGlobalOptions } from "./options.js";
5
- export type PrettierNode = EsTreeNode & {
6
- comments?: (Comment & {
5
+ import { RemoveIndex } from "./utils.js";
6
+ declare module "estree" {
7
+ interface Comment {
7
8
  leading: boolean;
8
9
  trailing: boolean;
9
10
  nodeDescription: string;
10
- })[];
11
- };
11
+ }
12
+ interface BaseNode {
13
+ comments?: Comment[];
14
+ }
15
+ interface File extends BaseNode {
16
+ type: "File";
17
+ sourceType: "script" | "module";
18
+ program: Program;
19
+ }
20
+ interface NodeMap {
21
+ File: File;
22
+ }
23
+ }
12
24
  export type InternalPrintFun = (selector?: string | number | (string | number)[] | AstPath<TemplateLiteral>) => Doc;
13
25
  export interface EmbedderPayload {
14
26
  identifier: string;
@@ -18,6 +30,6 @@ export interface EmbedderPayload {
18
30
  export type Embedder<T extends Options = Options> = (textToDoc: (text: string, options: T) => Promise<Doc>, print: InternalPrintFun, path: AstPath<TemplateLiteral>, options: T, embedderPayload: EmbedderPayload) => Promise<Doc>;
19
31
  export interface EmbeddedOverride {
20
32
  identifiers: AutocompleteStringList<EmbeddedDefaultIdentifier[]>;
21
- options: Omit<Omit<Options, keyof PrettierPluginEmbedOptions> & Omit<PrettierPluginEmbedOptions, keyof PrettierPluginGlobalOptions | ReturnType<typeof makeIdentifiersOptionName<EmbeddedLanguage>>>, "printWidth" | "endOfLine" | "useTabs" | "tabWidth" | "parser" | "filepath" | "embeddedLanguageFormatting" | `__${string}`>;
33
+ options: Omit<Omit<RemoveIndex<Options>, keyof PrettierPluginEmbedOptions> & Omit<PrettierPluginEmbedOptions, keyof PrettierPluginGlobalOptions | ReturnType<typeof makeIdentifiersOptionName<EmbeddedLanguage>>>, "printWidth" | "endOfLine" | "useTabs" | "tabWidth" | "parser" | "filepath" | "embeddedLanguageFormatting" | `__${string}`>;
22
34
  }
23
35
  export type EmbeddedOverrides = EmbeddedOverride[];
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- import { type AstPath } from "prettier";
2
- import type { PrettierNode } from "./types.js";
3
- export declare const resolveEmbeddedOverrideOptions: (embeddedOverridesString: string | undefined, identifier: string, sourceFilePath?: string) => Promise<Omit<Omit<import("prettier").Options, keyof import("./index.js").PrettierPluginEmbedOptions> & Omit<import("./index.js").PrettierPluginEmbedOptions, "embeddedNoopIdentifiers" | "embeddedCssIdentifiers" | "embeddedEsIdentifiers" | "embeddedGlslIdentifiers" | "embeddedGraphqlIdentifiers" | "embeddedHtmlIdentifiers" | "embeddedIniIdentifiers" | "embeddedJsonIdentifiers" | "embeddedLatexIdentifiers" | "embeddedMarkdownIdentifiers" | "embeddedPhpIdentifiers" | "embeddedPropertiesIdentifiers" | "embeddedRubyIdentifiers" | "embeddedShIdentifiers" | "embeddedSqlIdentifiers" | "embeddedTomlIdentifiers" | "embeddedTsIdentifiers" | "embeddedXmlIdentifiers" | "embeddedYamlIdentifiers" | keyof import("./options.js").PrettierPluginGlobalOptions>, "parser" | "filepath" | "endOfLine" | "embeddedLanguageFormatting" | "printWidth" | "tabWidth" | "useTabs" | `__${string}`> | undefined>;
4
- export declare function getIdentifierFromComment({ node, parent }: AstPath<PrettierNode>, comments: string[], noIdentificationList: string[]): string | undefined;
5
- export declare function getIdentifierFromTag({ node, parent }: AstPath<PrettierNode>, tags: string[], noIdentificationList: string[]): string | undefined;
1
+ import type { Node } from "estree";
2
+ import { type AstPath, type Options } from "prettier";
3
+ export declare const resolveEmbeddedOverrideOptions: (embeddedOverridesString: string | undefined, identifier: string, sourceFilePath?: string) => Promise<Omit<Omit<RemoveIndex<Options>, keyof import("./index.js").PrettierPluginEmbedOptions> & Omit<import("./index.js").PrettierPluginEmbedOptions, "embeddedNoopIdentifiers" | "embeddedCssIdentifiers" | "embeddedEsIdentifiers" | "embeddedGlslIdentifiers" | "embeddedGraphqlIdentifiers" | "embeddedHtmlIdentifiers" | "embeddedIniIdentifiers" | "embeddedJsonIdentifiers" | "embeddedLatexIdentifiers" | "embeddedMarkdownIdentifiers" | "embeddedPhpIdentifiers" | "embeddedPropertiesIdentifiers" | "embeddedRubyIdentifiers" | "embeddedShIdentifiers" | "embeddedSqlIdentifiers" | "embeddedTomlIdentifiers" | "embeddedTsIdentifiers" | "embeddedXmlIdentifiers" | "embeddedYamlIdentifiers" | keyof import("./options.js").PrettierPluginGlobalOptions>, "parser" | "filepath" | "endOfLine" | "embeddedLanguageFormatting" | "printWidth" | "tabWidth" | "useTabs" | `__${string}`> | undefined>;
4
+ export declare function getIdentifierFromComment({ node, parent }: AstPath<Node>, comments: string[], options: Options): string | undefined;
5
+ export declare function getIdentifierFromTag({ node, parent }: AstPath<Node>, tags: string[], options: Options): string | undefined;
6
+ export type RemoveIndex<T> = {
7
+ [K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K];
8
+ };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "prettier-plugin-embed",
3
3
  "description": "A configurable Prettier plugin to format embedded languages in js/ts files.",
4
4
  "private": false,
5
- "version": "0.4.4",
5
+ "version": "0.4.6",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "./dist"
@@ -22,7 +22,7 @@
22
22
  "homepage": "https://github.com/Sec-ant/prettier-plugin-embed",
23
23
  "bugs": {
24
24
  "url": "https://github.com/Sec-ant/prettier-plugin-embed/issues",
25
- "email": "zzwu@zju.edu.cn"
25
+ "email": "zezhengwu@proton.me"
26
26
  },
27
27
  "keywords": [
28
28
  "prettier",
@@ -64,21 +64,21 @@
64
64
  "@commitlint/cli": "^18.4.4",
65
65
  "@commitlint/config-conventional": "^18.4.4",
66
66
  "@prettier/plugin-php": "^0.22.1",
67
- "@prettier/plugin-ruby": "^4.0.0",
68
- "@prettier/plugin-xml": "^3.1.0",
67
+ "@prettier/plugin-ruby": "^4.0.4",
68
+ "@prettier/plugin-xml": "^3.2.2",
69
69
  "@types/estree": "^1.0.5",
70
- "@types/node": "^20.10.7",
71
- "@typescript-eslint/eslint-plugin": "^6.18.0",
72
- "@typescript-eslint/parser": "^6.18.0",
73
- "@vitest/coverage-istanbul": "^1.1.3",
74
- "@vitest/ui": "^1.1.3",
70
+ "@types/node": "^20.11.5",
71
+ "@typescript-eslint/eslint-plugin": "^6.19.0",
72
+ "@typescript-eslint/parser": "^6.19.0",
73
+ "@vitest/coverage-istanbul": "^1.2.1",
74
+ "@vitest/ui": "^1.2.1",
75
75
  "@xml-tools/parser": "^1.0.11",
76
76
  "chevrotain": "7.1.1",
77
77
  "esbuild": "^0.19.11",
78
78
  "eslint": "^8.56.0",
79
79
  "fast-glob": "^3.3.2",
80
80
  "npm-check-updates": "^16.14.12",
81
- "prettier": "^3.0.0",
81
+ "prettier": "^3.2.4",
82
82
  "prettier-plugin-glsl": "^0.1.3",
83
83
  "prettier-plugin-ini": "^1.1.0",
84
84
  "prettier-plugin-jsdoc": "^1.3.0",
@@ -87,12 +87,12 @@
87
87
  "prettier-plugin-properties": "^0.3.0",
88
88
  "prettier-plugin-sh": "^0.13.1",
89
89
  "prettier-plugin-sql": "^0.18.0",
90
- "prettier-plugin-sql-cst": "^0.10.0",
90
+ "prettier-plugin-sql-cst": "^0.10.2",
91
91
  "prettier-plugin-toml": "^2.0.1",
92
92
  "tsx": "^4.7.0",
93
93
  "typescript": "^5.3.3",
94
94
  "vite": "^5.0.11",
95
- "vitest": "^1.1.3"
95
+ "vitest": "^1.2.1"
96
96
  },
97
97
  "dependencies": {
98
98
  "dedent": "^1.5.1",