prettier-plugin-embed 0.4.5 → 0.4.7
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 +155 -103
- package/dist/embedded/css/options.d.ts +15 -1
- package/dist/embedded/es/options.d.ts +1 -1
- package/dist/embedded/glsl/options.d.ts +1 -1
- package/dist/embedded/graphql/options.d.ts +1 -1
- package/dist/embedded/html/options.d.ts +15 -1
- package/dist/embedded/ini/options.d.ts +1 -1
- package/dist/embedded/json/options.d.ts +1 -1
- package/dist/embedded/latex/options.d.ts +1 -1
- package/dist/embedded/markdown/options.d.ts +15 -1
- package/dist/embedded/noop/options.d.ts +1 -1
- package/dist/embedded/php/options.d.ts +1 -1
- package/dist/embedded/properties/options.d.ts +1 -1
- package/dist/embedded/register.d.ts +5 -5
- package/dist/embedded/ruby/options.d.ts +1 -1
- package/dist/embedded/sh/options.d.ts +3 -3
- package/dist/embedded/sql/options.d.ts +1 -1
- package/dist/embedded/toml/options.d.ts +3 -3
- package/dist/embedded/ts/options.d.ts +1 -1
- package/dist/embedded/xml/options.d.ts +2 -2
- package/dist/embedded/yaml/options.d.ts +1 -1
- package/dist/index.js +754 -724
- package/dist/options.d.ts +55 -25
- package/dist/types.d.ts +2 -1
- package/dist/utils.d.ts +4 -1
- package/package.json +9 -9
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: "
|
|
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,7 +22,7 @@ export declare const options: {
|
|
|
22
22
|
readonly default: [{
|
|
23
23
|
readonly value: [];
|
|
24
24
|
}];
|
|
25
|
-
readonly description: "
|
|
25
|
+
readonly description: "Turns off `` identifier`...` `` tag-based embedded language identification for the specified identifiers.";
|
|
26
26
|
};
|
|
27
27
|
readonly preserveEmbeddedExteriorWhitespaces: {
|
|
28
28
|
readonly category: "Embed";
|
|
@@ -31,7 +31,7 @@ export declare const options: {
|
|
|
31
31
|
readonly default: [{
|
|
32
32
|
readonly value: [];
|
|
33
33
|
}];
|
|
34
|
-
readonly description: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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,17 @@ export declare const options: {
|
|
|
65
65
|
readonly default: [{
|
|
66
66
|
readonly value: ["css"];
|
|
67
67
|
}];
|
|
68
|
-
readonly description: "
|
|
68
|
+
readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded CSS language.";
|
|
69
|
+
};
|
|
70
|
+
readonly embeddedCssParser: {
|
|
71
|
+
category: string;
|
|
72
|
+
type: "choice";
|
|
73
|
+
default: "scss";
|
|
74
|
+
description: string;
|
|
75
|
+
choices: {
|
|
76
|
+
value: "css" | "less" | "scss";
|
|
77
|
+
description: string;
|
|
78
|
+
}[];
|
|
69
79
|
};
|
|
70
80
|
readonly embeddedEsIdentifiers: {
|
|
71
81
|
readonly category: "Embed";
|
|
@@ -74,7 +84,7 @@ export declare const options: {
|
|
|
74
84
|
readonly default: [{
|
|
75
85
|
readonly value: ["js", "jsx", "es", "es6", "mjs", "cjs", "pac", "javascript"];
|
|
76
86
|
}];
|
|
77
|
-
readonly description: "
|
|
87
|
+
readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded ECMAScript/JavaScript language.";
|
|
78
88
|
};
|
|
79
89
|
readonly embeddedEsParser: {
|
|
80
90
|
category: string;
|
|
@@ -93,7 +103,7 @@ export declare const options: {
|
|
|
93
103
|
readonly default: [{
|
|
94
104
|
readonly value: ["glsl", "shader"];
|
|
95
105
|
}];
|
|
96
|
-
readonly description: "
|
|
106
|
+
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
107
|
};
|
|
98
108
|
readonly embeddedGraphqlIdentifiers: {
|
|
99
109
|
readonly category: "Embed";
|
|
@@ -102,7 +112,7 @@ export declare const options: {
|
|
|
102
112
|
readonly default: [{
|
|
103
113
|
readonly value: ["graphql", "gql"];
|
|
104
114
|
}];
|
|
105
|
-
readonly description: "
|
|
115
|
+
readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded GraphQL language.";
|
|
106
116
|
};
|
|
107
117
|
readonly embeddedHtmlIdentifiers: {
|
|
108
118
|
readonly category: "Embed";
|
|
@@ -111,7 +121,17 @@ export declare const options: {
|
|
|
111
121
|
readonly default: [{
|
|
112
122
|
readonly value: ["html", "xhtml"];
|
|
113
123
|
}];
|
|
114
|
-
readonly description: "
|
|
124
|
+
readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded HTML language.";
|
|
125
|
+
};
|
|
126
|
+
readonly embeddedHtmlParser: {
|
|
127
|
+
category: string;
|
|
128
|
+
type: "choice";
|
|
129
|
+
default: "html";
|
|
130
|
+
description: string;
|
|
131
|
+
choices: {
|
|
132
|
+
value: "html" | "vue" | "angular" | "lwc";
|
|
133
|
+
description: string;
|
|
134
|
+
}[];
|
|
115
135
|
};
|
|
116
136
|
readonly embeddedIniIdentifiers: {
|
|
117
137
|
readonly category: "Embed";
|
|
@@ -120,7 +140,7 @@ export declare const options: {
|
|
|
120
140
|
readonly default: [{
|
|
121
141
|
readonly value: ["ini", "cfg", "pro"];
|
|
122
142
|
}];
|
|
123
|
-
readonly description: "
|
|
143
|
+
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
144
|
};
|
|
125
145
|
readonly embeddedJsonIdentifiers: {
|
|
126
146
|
readonly category: "Embed";
|
|
@@ -129,7 +149,7 @@ export declare const options: {
|
|
|
129
149
|
readonly default: [{
|
|
130
150
|
readonly value: ["json", "jsonl"];
|
|
131
151
|
}];
|
|
132
|
-
readonly description: "
|
|
152
|
+
readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded JSON language.";
|
|
133
153
|
};
|
|
134
154
|
readonly embeddedJsonParser: {
|
|
135
155
|
category: string;
|
|
@@ -148,7 +168,7 @@ export declare const options: {
|
|
|
148
168
|
readonly default: [{
|
|
149
169
|
readonly value: ["latex", "tex", "aux", "cls", "bbl", "bib", "toc", "sty"];
|
|
150
170
|
}];
|
|
151
|
-
readonly description: "
|
|
171
|
+
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
172
|
};
|
|
153
173
|
readonly embeddedMarkdownIdentifiers: {
|
|
154
174
|
readonly category: "Embed";
|
|
@@ -157,7 +177,17 @@ export declare const options: {
|
|
|
157
177
|
readonly default: [{
|
|
158
178
|
readonly value: ["md", "markdown"];
|
|
159
179
|
}];
|
|
160
|
-
readonly description: "
|
|
180
|
+
readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded Markdown language.";
|
|
181
|
+
};
|
|
182
|
+
readonly embeddedMarkdownParser: {
|
|
183
|
+
category: string;
|
|
184
|
+
type: "choice";
|
|
185
|
+
default: "markdown";
|
|
186
|
+
description: string;
|
|
187
|
+
choices: {
|
|
188
|
+
value: "markdown" | "mdx" | "remark";
|
|
189
|
+
description: string;
|
|
190
|
+
}[];
|
|
161
191
|
};
|
|
162
192
|
readonly embeddedPhpIdentifiers: {
|
|
163
193
|
readonly category: "Embed";
|
|
@@ -166,7 +196,7 @@ export declare const options: {
|
|
|
166
196
|
readonly default: [{
|
|
167
197
|
readonly value: ["php", "php5"];
|
|
168
198
|
}];
|
|
169
|
-
readonly description: "
|
|
199
|
+
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
200
|
};
|
|
171
201
|
readonly embeddedPropertiesIdentifiers: {
|
|
172
202
|
readonly category: "Embed";
|
|
@@ -175,7 +205,7 @@ export declare const options: {
|
|
|
175
205
|
readonly default: [{
|
|
176
206
|
readonly value: ["properties"];
|
|
177
207
|
}];
|
|
178
|
-
readonly description: "
|
|
208
|
+
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
209
|
};
|
|
180
210
|
readonly embeddedRubyIdentifiers: {
|
|
181
211
|
readonly category: "Embed";
|
|
@@ -184,7 +214,7 @@ export declare const options: {
|
|
|
184
214
|
readonly default: [{
|
|
185
215
|
readonly value: ["ruby"];
|
|
186
216
|
}];
|
|
187
|
-
readonly description: "
|
|
217
|
+
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
218
|
};
|
|
189
219
|
readonly embeddedRubyParser: {
|
|
190
220
|
category: string;
|
|
@@ -203,7 +233,7 @@ export declare const options: {
|
|
|
203
233
|
readonly default: [{
|
|
204
234
|
readonly value: ["sh"];
|
|
205
235
|
}];
|
|
206
|
-
readonly description: "
|
|
236
|
+
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
237
|
};
|
|
208
238
|
readonly embeddedSqlIdentifiers: {
|
|
209
239
|
readonly category: "Embed";
|
|
@@ -212,7 +242,7 @@ export declare const options: {
|
|
|
212
242
|
readonly default: [{
|
|
213
243
|
readonly value: ["sql"];
|
|
214
244
|
}];
|
|
215
|
-
readonly description: "
|
|
245
|
+
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
246
|
};
|
|
217
247
|
readonly embeddedSqlPlugin: {
|
|
218
248
|
category: string;
|
|
@@ -241,7 +271,7 @@ export declare const options: {
|
|
|
241
271
|
readonly default: [{
|
|
242
272
|
readonly value: ["toml"];
|
|
243
273
|
}];
|
|
244
|
-
readonly description: "
|
|
274
|
+
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
275
|
};
|
|
246
276
|
readonly embeddedTsIdentifiers: {
|
|
247
277
|
readonly category: "Embed";
|
|
@@ -250,7 +280,7 @@ export declare const options: {
|
|
|
250
280
|
readonly default: [{
|
|
251
281
|
readonly value: ["ts", "tsx", "cts", "mts", "typescript"];
|
|
252
282
|
}];
|
|
253
|
-
readonly description: "
|
|
283
|
+
readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded TypeScript language.";
|
|
254
284
|
};
|
|
255
285
|
readonly embeddedTsParser: {
|
|
256
286
|
category: string;
|
|
@@ -269,7 +299,7 @@ export declare const options: {
|
|
|
269
299
|
readonly default: [{
|
|
270
300
|
readonly value: ["xml", "opml", "rss", "svg"];
|
|
271
301
|
}];
|
|
272
|
-
readonly description: "
|
|
302
|
+
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
303
|
};
|
|
274
304
|
readonly __embeddedXmlFragmentRecoverIndex: {
|
|
275
305
|
readonly category: "Embed";
|
|
@@ -278,7 +308,7 @@ export declare const options: {
|
|
|
278
308
|
readonly default: [{
|
|
279
309
|
readonly value: [];
|
|
280
310
|
}];
|
|
281
|
-
readonly description: "This option is read only and used as a workaround to support xml fragments";
|
|
311
|
+
readonly description: "This option is read only and is used internally as a workaround to support xml fragments";
|
|
282
312
|
};
|
|
283
313
|
readonly embeddedYamlIdentifiers: {
|
|
284
314
|
readonly category: "Embed";
|
|
@@ -287,7 +317,7 @@ export declare const options: {
|
|
|
287
317
|
readonly default: [{
|
|
288
318
|
readonly value: ["yaml", "yml"];
|
|
289
319
|
}];
|
|
290
|
-
readonly description: "
|
|
320
|
+
readonly description: "Tag or comment identifiers that make their subsequent template literals be identified as embedded YAML language.";
|
|
291
321
|
};
|
|
292
322
|
};
|
|
293
323
|
export interface PrettierPluginGlobalOptions {
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ 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
|
+
import { RemoveIndex } from "./utils.js";
|
|
5
6
|
declare module "estree" {
|
|
6
7
|
interface Comment {
|
|
7
8
|
leading: boolean;
|
|
@@ -29,6 +30,6 @@ export interface EmbedderPayload {
|
|
|
29
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>;
|
|
30
31
|
export interface EmbeddedOverride {
|
|
31
32
|
identifiers: AutocompleteStringList<EmbeddedDefaultIdentifier[]>;
|
|
32
|
-
options: Omit<Omit<Options
|
|
33
|
+
options: Omit<Omit<RemoveIndex<Options>, keyof PrettierPluginEmbedOptions> & Omit<PrettierPluginEmbedOptions, keyof PrettierPluginGlobalOptions | ReturnType<typeof makeIdentifiersOptionName<EmbeddedLanguage>>>, "printWidth" | "endOfLine" | "useTabs" | "tabWidth" | "parser" | "filepath" | "embeddedLanguageFormatting" | `__${string}`>;
|
|
33
34
|
}
|
|
34
35
|
export type EmbeddedOverrides = EmbeddedOverride[];
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Node } from "estree";
|
|
2
2
|
import { type AstPath, type Options } from "prettier";
|
|
3
|
-
export declare const resolveEmbeddedOverrideOptions: (embeddedOverridesString: string | undefined, identifier: string, sourceFilePath?: string) => Promise<Omit<Omit<Options
|
|
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
4
|
export declare function getIdentifierFromComment({ node, parent }: AstPath<Node>, comments: string[], options: Options): string | undefined;
|
|
5
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.
|
|
5
|
+
"version": "0.4.7",
|
|
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": "
|
|
25
|
+
"email": "zezhengwu@proton.me"
|
|
26
26
|
},
|
|
27
27
|
"keywords": [
|
|
28
28
|
"prettier",
|
|
@@ -67,18 +67,18 @@
|
|
|
67
67
|
"@prettier/plugin-ruby": "^4.0.4",
|
|
68
68
|
"@prettier/plugin-xml": "^3.2.2",
|
|
69
69
|
"@types/estree": "^1.0.5",
|
|
70
|
-
"@types/node": "^20.11.
|
|
71
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
72
|
-
"@typescript-eslint/parser": "^6.
|
|
73
|
-
"@vitest/coverage-istanbul": "^1.2.
|
|
74
|
-
"@vitest/ui": "^1.2.
|
|
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.2.
|
|
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",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"tsx": "^4.7.0",
|
|
93
93
|
"typescript": "^5.3.3",
|
|
94
94
|
"vite": "^5.0.11",
|
|
95
|
-
"vitest": "^1.2.
|
|
95
|
+
"vitest": "^1.2.1"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"dedent": "^1.5.1",
|