prettier-plugin-embed 0.0.1 → 0.0.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/dist/embedded/index.d.ts +6 -0
- package/dist/embedded/sql/index.d.ts +4 -0
- package/dist/embedded/sql/name.d.ts +1 -0
- package/dist/embedded/sql/option.d.ts +2 -0
- package/dist/embedded/sql/printer.d.ts +3 -0
- package/dist/embedded/sql/types.d.ts +13 -0
- package/dist/embedded/types.d.ts +1 -0
- package/dist/embedded/utils.d.ts +8 -0
- package/dist/embedded/xml/index.d.ts +5 -0
- package/dist/embedded/xml/name.d.ts +1 -0
- package/dist/embedded/xml/option.d.ts +2 -0
- package/dist/embedded/xml/parser.d.ts +5 -0
- package/dist/embedded/xml/printer.d.ts +3 -0
- package/dist/embedded/xml/types.d.ts +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +287 -114
- package/dist/options.d.ts +0 -8
- package/dist/printers.d.ts +1 -1
- package/dist/types.d.ts +12 -0
- package/package.json +8 -6
- package/dist/embedders/index.d.ts +0 -3
- package/dist/embedders/types.d.ts +0 -4
- package/dist/embedders/xml.d.ts +0 -11
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Parser, SupportOptions } from "prettier";
|
|
2
|
+
import type { EmbeddedPrinter } from "../types.js";
|
|
3
|
+
export declare const embeddedLanguageNames: readonly ["embeddedXml", "embeddedSql"];
|
|
4
|
+
export declare const embeddedParsers: Record<string, Parser>;
|
|
5
|
+
export declare const embeddedPrinters: Record<string, EmbeddedPrinter>;
|
|
6
|
+
export declare const embeddedOptions: SupportOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const name = "embeddedSql";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { name } from "./name.js";
|
|
2
|
+
import { SqlBaseOptions as PrettierPluginSqlOptions } from "prettier-plugin-sql";
|
|
3
|
+
export declare const SQL_FORMATTER_LANGUAGES: readonly ["sql", "bigquery", "hive", "mariadb", "mysql", "postgresql", "db2", "plsql", "n1ql", "redshift", "singlestoredb", "spark", "sqlite", "transactsql", "tsql", "trino"];
|
|
4
|
+
export declare const NODE_SQL_PARSER_DATABASES: readonly ["bigquery", "db2", "hive", "mariadb", "mysql", "postgresql", "transactsql", "flinksql"];
|
|
5
|
+
export type SqlFormatterLanguage = (typeof SQL_FORMATTER_LANGUAGES)[number];
|
|
6
|
+
export type NodeSqlParserDataBase = (typeof NODE_SQL_PARSER_DATABASES)[number];
|
|
7
|
+
export interface PrettierPluginEmbedSqlOptions {
|
|
8
|
+
[name]?: SqlFormatterLanguage[] | NodeSqlParserDataBase[];
|
|
9
|
+
}
|
|
10
|
+
declare module "prettier" {
|
|
11
|
+
interface Options extends PrettierPluginSqlOptions, PrettierPluginEmbedSqlOptions {
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./xml/types.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Expression, Comment, TemplateLiteral } from "estree";
|
|
2
|
+
import { AstPath } from "prettier";
|
|
3
|
+
import { builders } from "prettier/doc";
|
|
4
|
+
import { InternalPrintFun } from "../types.js";
|
|
5
|
+
export declare function printTemplateExpression(path: AstPath<Expression & {
|
|
6
|
+
comments?: Comment[];
|
|
7
|
+
}>, print: InternalPrintFun): builders.Doc[];
|
|
8
|
+
export declare function printTemplateExpressions(path: AstPath<TemplateLiteral>, print: InternalPrintFun): builders.Doc[][];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const name = "embeddedXml";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { name } from "./name.js";
|
|
2
|
+
export interface PrettierPluginXmlOptions {
|
|
3
|
+
xmlSelfClosingSpace?: boolean;
|
|
4
|
+
xmlWhitespaceSensitivity?: "strict" | "preserve" | "ignore";
|
|
5
|
+
xmlSortAttributesByKey?: boolean;
|
|
6
|
+
xmlQuoteAttributes?: "preserve" | "single" | "double";
|
|
7
|
+
}
|
|
8
|
+
export interface PrettierPluginEmbedXmlOptions {
|
|
9
|
+
[name]?: string[];
|
|
10
|
+
}
|
|
11
|
+
declare module "prettier" {
|
|
12
|
+
interface Options extends PrettierPluginXmlOptions, PrettierPluginEmbedXmlOptions {
|
|
13
|
+
}
|
|
14
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,146 +1,319 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { builders as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import P from "prettier/parser-babel";
|
|
2
|
+
import F from "prettier/parser-espree";
|
|
3
|
+
import W from "prettier/parser-flow";
|
|
4
|
+
import _ from "prettier/parser-typescript";
|
|
5
|
+
import { parse as j } from "@xml-tools/parser";
|
|
6
|
+
import { builders as S, utils as I } from "prettier/doc";
|
|
7
|
+
import { printers as B } from "prettier/plugins/estree.mjs";
|
|
8
|
+
const q = "embeddedXml";
|
|
9
|
+
function L(e, t) {
|
|
10
|
+
const r = new SyntaxError(
|
|
11
|
+
e + " (" + t.loc.start.line + ":" + t.loc.start.column + ")"
|
|
12
|
+
);
|
|
13
|
+
return Object.assign(r, t);
|
|
14
|
+
}
|
|
15
|
+
const G = {
|
|
16
|
+
parse(e) {
|
|
17
|
+
const { lexErrors: t, parseErrors: r, cst: o } = j(e);
|
|
18
|
+
if (t.length > 0) {
|
|
19
|
+
const n = t[0];
|
|
20
|
+
throw L(n.message, {
|
|
21
|
+
loc: {
|
|
22
|
+
start: { line: n.line, column: n.column },
|
|
23
|
+
end: {
|
|
24
|
+
line: n.line,
|
|
25
|
+
column: n.column + n.length
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (r.length > 0) {
|
|
31
|
+
const n = r[0];
|
|
32
|
+
throw L(n.message, {
|
|
33
|
+
loc: {
|
|
34
|
+
start: {
|
|
35
|
+
line: n.token.startLine ?? NaN,
|
|
36
|
+
column: n.token.startColumn ?? NaN
|
|
37
|
+
},
|
|
38
|
+
end: {
|
|
39
|
+
line: n.token.endLine ?? NaN,
|
|
40
|
+
column: n.token.endColumn ?? NaN
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return o;
|
|
46
|
+
},
|
|
47
|
+
astFormat: "xml",
|
|
48
|
+
locStart(e) {
|
|
49
|
+
return e.location.startOffset;
|
|
50
|
+
},
|
|
51
|
+
locEnd(e) {
|
|
52
|
+
return e.location.endOffset ?? NaN;
|
|
53
|
+
}
|
|
12
54
|
};
|
|
13
|
-
let
|
|
14
|
-
const
|
|
15
|
-
function
|
|
16
|
-
if (
|
|
55
|
+
let $;
|
|
56
|
+
const V = new Uint8Array(16);
|
|
57
|
+
function Q() {
|
|
58
|
+
if (!$ && ($ = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !$))
|
|
17
59
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
18
|
-
return
|
|
60
|
+
return $(V);
|
|
19
61
|
}
|
|
20
|
-
const
|
|
62
|
+
const s = [];
|
|
21
63
|
for (let e = 0; e < 256; ++e)
|
|
22
|
-
|
|
23
|
-
function
|
|
24
|
-
return
|
|
64
|
+
s.push((e + 256).toString(16).slice(1));
|
|
65
|
+
function z(e, t = 0) {
|
|
66
|
+
return s[e[t + 0]] + s[e[t + 1]] + s[e[t + 2]] + s[e[t + 3]] + "-" + s[e[t + 4]] + s[e[t + 5]] + "-" + s[e[t + 6]] + s[e[t + 7]] + "-" + s[e[t + 8]] + s[e[t + 9]] + "-" + s[e[t + 10]] + s[e[t + 11]] + s[e[t + 12]] + s[e[t + 13]] + s[e[t + 14]] + s[e[t + 15]];
|
|
25
67
|
}
|
|
26
|
-
const
|
|
27
|
-
randomUUID:
|
|
68
|
+
const M = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), U = {
|
|
69
|
+
randomUUID: M
|
|
28
70
|
};
|
|
29
|
-
function
|
|
30
|
-
if (
|
|
31
|
-
return
|
|
71
|
+
function O(e, t, r) {
|
|
72
|
+
if (U.randomUUID && !t && !e)
|
|
73
|
+
return U.randomUUID();
|
|
32
74
|
e = e || {};
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
75
|
+
const o = e.random || (e.rng || Q)();
|
|
76
|
+
if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, t) {
|
|
35
77
|
r = r || 0;
|
|
36
|
-
for (let
|
|
37
|
-
|
|
38
|
-
return
|
|
78
|
+
for (let n = 0; n < 16; ++n)
|
|
79
|
+
t[r + n] = o[n];
|
|
80
|
+
return t;
|
|
39
81
|
}
|
|
40
|
-
return
|
|
82
|
+
return z(o);
|
|
41
83
|
}
|
|
42
|
-
const {
|
|
43
|
-
|
|
84
|
+
const { group: X, indent: H, softline: k, lineSuffixBoundary: J } = S;
|
|
85
|
+
function K(e, t) {
|
|
86
|
+
var n;
|
|
87
|
+
const { node: r } = e;
|
|
88
|
+
let o = t();
|
|
89
|
+
return (n = r == null ? void 0 : r.comments) != null && n.length && (o = X([H([k, o]), k])), ["${", o, J, "}"];
|
|
90
|
+
}
|
|
91
|
+
function C(e, t) {
|
|
92
|
+
return e.map(
|
|
93
|
+
(r) => K(r, t),
|
|
94
|
+
"expressions"
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
const { label: Y, hardline: Z, line: ee, group: E, indent: te } = S, { mapDoc: ne } = I, re = async (e, t, r, o) => {
|
|
44
98
|
try {
|
|
45
|
-
const { node:
|
|
46
|
-
(
|
|
47
|
-
).join("")
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
99
|
+
const n = O(), { node: i } = r, p = i.quasis.map(
|
|
100
|
+
(l, c, { length: u }) => c === u - 1 ? l.value.cooked : l.value.cooked + `${n}-${c}`
|
|
101
|
+
).join("");
|
|
102
|
+
let d = "", g = 0;
|
|
103
|
+
const f = /^\s+/.exec(p);
|
|
104
|
+
f && (g = f.index + f[0].length, d = " ");
|
|
105
|
+
const y = /\s$/.test(p) ? " " : "", b = C(r, t), N = await e(p.slice(g), {
|
|
106
|
+
parser: q
|
|
107
|
+
}), x = ne(N, (l) => {
|
|
108
|
+
if (typeof l != "string")
|
|
109
|
+
return l;
|
|
110
|
+
const c = [], u = l.split(new RegExp(n + "-(\\d+)", "g"));
|
|
111
|
+
for (let m = 0; m < u.length; m++) {
|
|
112
|
+
let a = u[m];
|
|
113
|
+
if (m % 2 == 0) {
|
|
114
|
+
if (!a)
|
|
115
|
+
continue;
|
|
116
|
+
a = a.replaceAll(/([\\`]|\${)/g, "\\$1"), c.push(a);
|
|
117
|
+
} else {
|
|
118
|
+
const T = Number(a);
|
|
119
|
+
c.push(b[T]);
|
|
58
120
|
}
|
|
59
|
-
const w = Number(c);
|
|
60
|
-
p.push(d[w]);
|
|
61
121
|
}
|
|
62
|
-
return
|
|
63
|
-
}),
|
|
64
|
-
return
|
|
122
|
+
return c;
|
|
123
|
+
}), h = o.xmlWhitespaceSensitivity === "ignore" ? Z : d && y ? ee : null;
|
|
124
|
+
return h ? E([
|
|
65
125
|
"`",
|
|
66
|
-
|
|
67
|
-
|
|
126
|
+
te([h, E(x)]),
|
|
127
|
+
h,
|
|
68
128
|
"`"
|
|
69
|
-
]) :
|
|
129
|
+
]) : Y(
|
|
70
130
|
{ hug: !1 },
|
|
71
|
-
|
|
131
|
+
E([
|
|
72
132
|
"`",
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
133
|
+
d,
|
|
134
|
+
E(x),
|
|
135
|
+
y,
|
|
76
136
|
"`"
|
|
77
137
|
])
|
|
78
138
|
);
|
|
79
|
-
} catch (
|
|
80
|
-
throw console.error(
|
|
139
|
+
} catch (n) {
|
|
140
|
+
throw console.error(n), n;
|
|
81
141
|
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
142
|
+
}, oe = {
|
|
143
|
+
category: "Global",
|
|
144
|
+
type: "string",
|
|
145
|
+
array: !0,
|
|
146
|
+
default: [{ value: ["xml", "svg"] }],
|
|
147
|
+
description: "Config embedded XML formatting. This requires @prettier/plugin-xml"
|
|
148
|
+
}, D = "embeddedSql", A = [
|
|
149
|
+
"sql",
|
|
150
|
+
"bigquery",
|
|
151
|
+
"hive",
|
|
152
|
+
"mariadb",
|
|
153
|
+
"mysql",
|
|
154
|
+
"postgresql",
|
|
155
|
+
"db2",
|
|
156
|
+
"plsql",
|
|
157
|
+
"n1ql",
|
|
158
|
+
"redshift",
|
|
159
|
+
"singlestoredb",
|
|
160
|
+
"spark",
|
|
161
|
+
"sqlite",
|
|
162
|
+
"transactsql",
|
|
163
|
+
"tsql",
|
|
164
|
+
"trino"
|
|
165
|
+
], R = [
|
|
166
|
+
"bigquery",
|
|
167
|
+
"db2",
|
|
168
|
+
"hive",
|
|
169
|
+
"mariadb",
|
|
170
|
+
"mysql",
|
|
171
|
+
"postgresql",
|
|
172
|
+
"transactsql",
|
|
173
|
+
"flinksql"
|
|
174
|
+
], { label: se, hardline: ie, group: w } = S, { mapDoc: le } = I, ce = async (e, t, r, o, n) => {
|
|
175
|
+
try {
|
|
176
|
+
const i = "p" + O().replaceAll("-", ""), { node: p } = r, d = p.quasis.map(
|
|
177
|
+
(l, c, { length: u }) => c === u - 1 ? l.value.cooked : l.value.cooked + `${i}${c}`
|
|
178
|
+
).join(""), g = /^\s/.test(d) ? " " : "", f = /\s$/.test(d) ? " " : "", y = C(r, t);
|
|
179
|
+
n = n.toLowerCase();
|
|
180
|
+
let b = {};
|
|
181
|
+
if (o.formatter === "sql-formatter")
|
|
182
|
+
if (A.includes(n))
|
|
183
|
+
b = {
|
|
184
|
+
formatter: "sql-formatter",
|
|
185
|
+
language: n
|
|
186
|
+
};
|
|
187
|
+
else if (R.includes(n))
|
|
188
|
+
b = {
|
|
189
|
+
formatter: "node-sql-parser",
|
|
190
|
+
database: n
|
|
191
|
+
};
|
|
192
|
+
else
|
|
193
|
+
throw new SyntaxError(`Unrecognized language: ${n}`);
|
|
194
|
+
else if (R.includes(n))
|
|
195
|
+
b = {
|
|
196
|
+
formatter: "node-sql-parser",
|
|
197
|
+
database: n
|
|
198
|
+
};
|
|
199
|
+
else if (A.includes(n))
|
|
200
|
+
b = {
|
|
201
|
+
formatter: "sql-formatter",
|
|
202
|
+
language: n
|
|
203
|
+
};
|
|
204
|
+
else
|
|
205
|
+
throw new SyntaxError(`Unrecognized language: ${n}`);
|
|
206
|
+
const N = await e(d, {
|
|
207
|
+
parser: "sql",
|
|
208
|
+
...b
|
|
209
|
+
}), x = le(N, (l) => {
|
|
210
|
+
if (typeof l != "string")
|
|
211
|
+
return l;
|
|
212
|
+
const c = [], u = l.split(new RegExp(i + "(\\d+)", "g"));
|
|
213
|
+
for (let m = 0; m < u.length; m++) {
|
|
214
|
+
let a = u[m];
|
|
215
|
+
if (m % 2 == 0) {
|
|
216
|
+
if (!a)
|
|
217
|
+
continue;
|
|
218
|
+
a = a.replaceAll(/([\\`]|\${)/g, "\\$1"), c.push(a);
|
|
219
|
+
} else {
|
|
220
|
+
const T = Number(a);
|
|
221
|
+
c.push(y[T]);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return c;
|
|
225
|
+
}), h = ie;
|
|
226
|
+
return h ? w(["`", h, w(x), h, "`"]) : se(
|
|
227
|
+
{ hug: !1 },
|
|
228
|
+
w([
|
|
229
|
+
"`",
|
|
230
|
+
g,
|
|
231
|
+
w(x),
|
|
232
|
+
f,
|
|
233
|
+
"`"
|
|
234
|
+
])
|
|
235
|
+
);
|
|
236
|
+
} catch (i) {
|
|
237
|
+
throw console.error(i), i;
|
|
238
|
+
}
|
|
239
|
+
}, ae = {
|
|
240
|
+
category: "Global",
|
|
241
|
+
type: "string",
|
|
242
|
+
array: !0,
|
|
243
|
+
default: [{ value: ["sql"] }],
|
|
244
|
+
description: "Config embedded SQL formatting. This requires prettier-plugin-sql"
|
|
245
|
+
}, de = [
|
|
246
|
+
q,
|
|
247
|
+
D
|
|
248
|
+
], ue = {
|
|
249
|
+
[q]: G
|
|
250
|
+
}, me = {
|
|
251
|
+
[q]: re,
|
|
252
|
+
[D]: ce
|
|
253
|
+
}, pe = {
|
|
254
|
+
[q]: oe,
|
|
255
|
+
[D]: ae
|
|
256
|
+
}, ve = {
|
|
257
|
+
// parsers from internal
|
|
258
|
+
...P.parsers,
|
|
259
|
+
...F.parsers,
|
|
260
|
+
...W.parsers,
|
|
261
|
+
..._.parsers,
|
|
262
|
+
// parsers from plugin
|
|
263
|
+
...ue
|
|
264
|
+
}, { estree: v } = B, ge = function(e, t) {
|
|
265
|
+
var o;
|
|
102
266
|
const { node: r } = e;
|
|
103
|
-
if (r.type !== "TemplateLiteral" || r.quasis.some(({ value: { cooked:
|
|
267
|
+
if (r.type !== "TemplateLiteral" || r.quasis.some(({ value: { cooked: n } }) => n === null))
|
|
104
268
|
return null;
|
|
105
|
-
for (const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
269
|
+
for (const n of de) {
|
|
270
|
+
const i = t[n];
|
|
271
|
+
if (!i)
|
|
272
|
+
continue;
|
|
273
|
+
const p = fe(e, i) ?? ye(e, i);
|
|
274
|
+
if (p === void 0)
|
|
109
275
|
continue;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return m;
|
|
276
|
+
const d = me[n], g = e.node;
|
|
277
|
+
return g.quasis.length === 1 && g.quasis[0].value.raw.trim() === "" ? "``" : async (...f) => {
|
|
278
|
+
const y = await d(...f, p);
|
|
279
|
+
return S.label(
|
|
280
|
+
{ embed: !0, ...y.label },
|
|
281
|
+
y
|
|
282
|
+
);
|
|
283
|
+
};
|
|
119
284
|
}
|
|
120
|
-
return ((
|
|
285
|
+
return ((o = v.embed) == null ? void 0 : o.call(v, e, t)) ?? null;
|
|
121
286
|
};
|
|
122
|
-
function
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
287
|
+
function fe({ node: e, parent: t }, r) {
|
|
288
|
+
if (r.length === 0 || e.type !== "TemplateLiteral")
|
|
289
|
+
return;
|
|
290
|
+
const o = e.comments ?? (t == null ? void 0 : t.comments);
|
|
291
|
+
if (!o)
|
|
292
|
+
return;
|
|
293
|
+
const n = o[o.length - 1];
|
|
294
|
+
if (!(n.type !== "Block" || !n.leading)) {
|
|
295
|
+
for (const i of r)
|
|
296
|
+
if (` ${i} ` === n.value)
|
|
297
|
+
return i;
|
|
298
|
+
}
|
|
127
299
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
300
|
+
function ye({ node: e, parent: t }, r) {
|
|
301
|
+
if (r.length !== 0 && !(e.type !== "TemplateLiteral" || (t == null ? void 0 : t.type) !== "TaggedTemplateExpression" || t.tag.type !== "Identifier")) {
|
|
302
|
+
for (const o of r)
|
|
303
|
+
if (t.tag.name === o)
|
|
304
|
+
return o;
|
|
132
305
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
default: "[]",
|
|
139
|
-
description: "Config embedded languages formatting supported by this plugin."
|
|
306
|
+
}
|
|
307
|
+
const Se = {
|
|
308
|
+
estree: {
|
|
309
|
+
...v,
|
|
310
|
+
embed: ge
|
|
140
311
|
}
|
|
312
|
+
}, Ne = {
|
|
313
|
+
...pe
|
|
141
314
|
};
|
|
142
315
|
export {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
316
|
+
Ne as options,
|
|
317
|
+
ve as parsers,
|
|
318
|
+
Se as printers
|
|
146
319
|
};
|
package/dist/options.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
1
|
import type { SupportOptions } from "prettier";
|
|
2
2
|
export declare const options: SupportOptions;
|
|
3
|
-
export interface EmbeddedLanguage {
|
|
4
|
-
tag: string | string[];
|
|
5
|
-
comment: string | string[];
|
|
6
|
-
embedder?: string | null;
|
|
7
|
-
}
|
|
8
|
-
export interface PrettierPluginEmbedOptions {
|
|
9
|
-
embeddedLanguages?: string;
|
|
10
|
-
}
|
package/dist/printers.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Plugin } from "prettier";
|
|
2
2
|
export declare const printers: Plugin["printers"];
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Options, Doc, AstPath } from "prettier";
|
|
2
|
+
import type { Node as EsTreeNode, TemplateLiteral, Comment } from "estree";
|
|
3
|
+
export * from "./embedded/types.js";
|
|
4
|
+
export type PrettierNode = EsTreeNode & {
|
|
5
|
+
comments?: (Comment & {
|
|
6
|
+
leading: boolean;
|
|
7
|
+
trailing: boolean;
|
|
8
|
+
nodeDescription: string;
|
|
9
|
+
})[];
|
|
10
|
+
};
|
|
11
|
+
export type InternalPrintFun = (selector?: string | number | (string | number)[] | AstPath<TemplateLiteral>) => Doc;
|
|
12
|
+
export type EmbeddedPrinter<T extends Options = Options> = (textToDoc: (text: string, options: T) => Promise<Doc>, print: InternalPrintFun, path: AstPath<TemplateLiteral>, options: T, lang: string) => Promise<Doc>;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "prettier-plugin-embed",
|
|
3
3
|
"description": "A prettier plugin to format embedded languages in js/ts files.",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.2",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"./dist"
|
|
@@ -55,17 +55,19 @@
|
|
|
55
55
|
"postncu": "npm i"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"
|
|
58
|
+
"@xml-tools/parser": "^1.0.11",
|
|
59
|
+
"prettier": "^3.0.3",
|
|
60
|
+
"@prettier/plugin-xml": "^3.2.1",
|
|
61
|
+
"prettier-plugin-sql": "^0.15.1"
|
|
59
62
|
},
|
|
60
63
|
"devDependencies": {
|
|
61
64
|
"@commitlint/cli": "^17.7.2",
|
|
62
65
|
"@commitlint/config-conventional": "^17.7.0",
|
|
63
|
-
"@prettier/plugin-xml": "^3.2.1",
|
|
64
66
|
"@semantic-release/git": "^10.0.1",
|
|
65
67
|
"@types/estree": "^1.0.2",
|
|
66
68
|
"@types/uuid": "^9.0.4",
|
|
67
|
-
"@typescript-eslint/eslint-plugin": "^6.7.
|
|
68
|
-
"@typescript-eslint/parser": "^6.7.
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
|
70
|
+
"@typescript-eslint/parser": "^6.7.4",
|
|
69
71
|
"@vitest/browser": "^0.34.6",
|
|
70
72
|
"@vitest/coverage-istanbul": "^0.34.6",
|
|
71
73
|
"@vitest/ui": "^0.34.6",
|
|
@@ -75,7 +77,7 @@
|
|
|
75
77
|
"playwright": "^1.38.1",
|
|
76
78
|
"semantic-release": "^22.0.5",
|
|
77
79
|
"typescript": "^5.2.2",
|
|
78
|
-
"vite": "^4.4.
|
|
80
|
+
"vite": "^4.4.10",
|
|
79
81
|
"vitest": "^0.34.6"
|
|
80
82
|
},
|
|
81
83
|
"dependencies": {
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Options, Doc, AstPath } from "prettier";
|
|
2
|
-
import type { TemplateLiteral } from "estree";
|
|
3
|
-
export type InternalPrintFun = (selector?: string | number | (string | number)[] | AstPath<TemplateLiteral>) => Doc;
|
|
4
|
-
export type Embedder = (textToDoc: (text: string, options: Options) => Promise<Doc>, print: InternalPrintFun, path: AstPath<TemplateLiteral>, options: Options) => Promise<Doc>;
|
package/dist/embedders/xml.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { AstPath, Options, Doc } from "prettier";
|
|
2
|
-
import type { TemplateLiteral } from "estree";
|
|
3
|
-
import type { InternalPrintFun } from "./types.js";
|
|
4
|
-
interface PrettierPluginXmlOptions extends Options {
|
|
5
|
-
xmlSelfClosingSpace?: boolean;
|
|
6
|
-
xmlWhitespaceSensitivity?: "strict" | "preserve" | "ignore";
|
|
7
|
-
xmlSortAttributesByKey?: boolean;
|
|
8
|
-
xmlQuoteAttributes?: "preserve" | "single" | "double";
|
|
9
|
-
}
|
|
10
|
-
declare function printEmbedXml(textToDoc: (text: string, options: Options) => Promise<Doc>, print: InternalPrintFun, path: AstPath<TemplateLiteral>, options: PrettierPluginXmlOptions): Promise<Doc>;
|
|
11
|
-
export default printEmbedXml;
|