oxfmt 0.53.0 → 0.54.0
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 +2 -0
- package/configuration_schema.json +96 -96
- package/dist/{apis-DOCQy_NG.js → apis-CngUzqDq.js} +3 -3
- package/dist/{chunk-DSjvVL_1-CrjveNIv.js → chunk-DSjvVL_1-BUO3FyMh.js} +1 -1
- package/dist/cli-worker.js +1 -1
- package/dist/cli.js +13 -22
- package/dist/{dist-Cb-CB0nt.js → dist-ZI7w_ao-.js} +4 -4
- package/dist/index.d.ts +48 -4
- package/dist/index.js +11 -11
- package/dist/{jiti-Bb1dT6Cw-bfahw2Ut.js → jiti-Bb1dT6Cw-DPQUX1DC.js} +2 -2
- package/dist/{bindings-ChKdN0o7.js → napi-callbacks-C8y3J_xb.js} +56 -27
- package/dist/{plugin-DOvWpprN.js → plugin-CHUKsFCg.js} +21 -3
- package/dist/{sorter-BZkvDMjt-X7PZZf-k.js → sorter-BZkvDMjt-DCuU-7CM.js} +7 -7
- package/dist/{sorter-o4mwRTof.js → sorter-CharfNIQ.js} +1 -1
- package/dist/{v3-D-mr2VVh-BYLPgMY0.js → v3-D-mr2VVh-C7AdPwxy.js} +4 -4
- package/dist/{v4-C-HWEQJm-DbK_mluY.js → v4-C-HWEQJm-CJKqx13d.js} +4 -4
- package/package.json +20 -20
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as runCli, n as toNullable, t as toFormatFileResult } from "./napi-callbacks-C8y3J_xb.js";
|
|
2
2
|
import Tinypool from "tinypool";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import { extname } from "node:path";
|
|
@@ -17,38 +17,29 @@ async function disposeExternalFormatter() {
|
|
|
17
17
|
await pool?.destroy();
|
|
18
18
|
pool = null;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
return pool.run({
|
|
20
|
+
function formatFile(options, code) {
|
|
21
|
+
return toFormatFileResult(pool.run({
|
|
22
22
|
options,
|
|
23
23
|
code
|
|
24
|
-
}, { name: "formatFile" })
|
|
25
|
-
if (err instanceof Error) throw err;
|
|
26
|
-
if (err !== null && typeof err === "object") {
|
|
27
|
-
const obj = err;
|
|
28
|
-
const newErr = new Error(obj.message);
|
|
29
|
-
newErr.name = obj.name;
|
|
30
|
-
throw newErr;
|
|
31
|
-
}
|
|
32
|
-
throw new Error(String(err));
|
|
33
|
-
});
|
|
24
|
+
}, { name: "formatFile" }));
|
|
34
25
|
}
|
|
35
|
-
|
|
36
|
-
return pool.run({
|
|
26
|
+
function formatEmbeddedCode(options, code) {
|
|
27
|
+
return toNullable(pool.run({
|
|
37
28
|
options,
|
|
38
29
|
code
|
|
39
|
-
}, { name: "formatEmbeddedCode" })
|
|
30
|
+
}, { name: "formatEmbeddedCode" }));
|
|
40
31
|
}
|
|
41
|
-
|
|
42
|
-
return pool.run({
|
|
32
|
+
function formatEmbeddedDoc(options, texts) {
|
|
33
|
+
return toNullable(pool.run({
|
|
43
34
|
options,
|
|
44
35
|
texts
|
|
45
|
-
}, { name: "formatEmbeddedDoc" })
|
|
36
|
+
}, { name: "formatEmbeddedDoc" }));
|
|
46
37
|
}
|
|
47
|
-
|
|
48
|
-
return pool.run({
|
|
38
|
+
function sortTailwindClasses(options, classes) {
|
|
39
|
+
return toNullable(pool.run({
|
|
49
40
|
classes,
|
|
50
41
|
options
|
|
51
|
-
}, { name: "sortTailwindClasses" })
|
|
42
|
+
}, { name: "sortTailwindClasses" }));
|
|
52
43
|
}
|
|
53
44
|
//#endregion
|
|
54
45
|
//#region ../shared/src-js/utils.ts
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { o as __toESM } from "./chunk-CNf5ZN-e.js";
|
|
2
2
|
import { n as init_babel, parsers as ra, t as babel_exports } from "./babel-DjR61Wf3.js";
|
|
3
3
|
import index_exports, { t as init_prettier } from "./prettier-CttUn4xj.js";
|
|
4
|
-
import { a as __toESM$1, t as __commonJSMin } from "./chunk-DSjvVL_1-
|
|
5
|
-
import { a as sortClasses, c as cacheForDirs, d as expiringMap, f as loadIfExists, i as sortClassList, l as spliceChangesIntoString, n as error, o as warn, p as maybeResolve, r as getTailwindConfig$1, u as visit } from "./sorter-BZkvDMjt-
|
|
4
|
+
import { a as __toESM$1, t as __commonJSMin } from "./chunk-DSjvVL_1-BUO3FyMh.js";
|
|
5
|
+
import { a as sortClasses, c as cacheForDirs, d as expiringMap, f as loadIfExists, i as sortClassList, l as spliceChangesIntoString, n as error, o as warn, p as maybeResolve, r as getTailwindConfig$1, u as visit } from "./sorter-BZkvDMjt-DCuU-7CM.js";
|
|
6
6
|
import { parsers as fn, t as init_angular } from "./angular-4Mc0TmPv.js";
|
|
7
7
|
import { n as postcss_exports, parsers as en, t as init_postcss } from "./postcss-BFLfznNY.js";
|
|
8
8
|
import * as path from "node:path";
|
|
9
9
|
import { isAbsolute } from "path";
|
|
10
|
-
//#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.2b6f3c2_prettier-plugin-svelte@4.
|
|
10
|
+
//#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.2b6f3c2_prettier-plugin-svelte@4.1.0_prettie_e3345e2f5995e2d14d8ee5c58c9c043a/node_modules/prettier-plugin-tailwindcss/dist/index.mjs
|
|
11
11
|
init_angular();
|
|
12
12
|
init_babel();
|
|
13
13
|
init_postcss();
|
|
@@ -1160,7 +1160,7 @@ const { parsers, printers } = createPlugin([
|
|
|
1160
1160
|
staticAttrs: ["class"],
|
|
1161
1161
|
load: [{
|
|
1162
1162
|
name: "prettier-plugin-svelte",
|
|
1163
|
-
importer: () => import("./plugin-
|
|
1163
|
+
importer: () => import("./plugin-CHUKsFCg.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))
|
|
1164
1164
|
}],
|
|
1165
1165
|
parsers: { svelte: {} },
|
|
1166
1166
|
printers: { "svelte-ast": {} },
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ interface Oxfmtrc {
|
|
|
54
54
|
/**
|
|
55
55
|
* Include parentheses around a sole arrow function parameter.
|
|
56
56
|
*
|
|
57
|
+
* - Languages: JS, JSX, TS, TSX
|
|
57
58
|
* - Default: `"always"`
|
|
58
59
|
*/
|
|
59
60
|
arrowParens?: ArrowParensConfig;
|
|
@@ -61,20 +62,21 @@ interface Oxfmtrc {
|
|
|
61
62
|
* Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line,
|
|
62
63
|
* instead of being alone on the next line (does not apply to self closing elements).
|
|
63
64
|
*
|
|
65
|
+
* - Languages: JSX, TSX, HTML, Angular, Vue, MJML, Svelte
|
|
64
66
|
* - Default: `false`
|
|
65
67
|
*/
|
|
66
68
|
bracketSameLine?: boolean;
|
|
67
69
|
/**
|
|
68
70
|
* Print spaces between brackets in object literals.
|
|
69
71
|
*
|
|
72
|
+
* - Languages: JS, JSX, TS, TSX, JSON, JSONC, JSON5, GraphQL, YAML
|
|
70
73
|
* - Default: `true`
|
|
71
74
|
*/
|
|
72
75
|
bracketSpacing?: boolean;
|
|
73
76
|
/**
|
|
74
77
|
* Control whether to format embedded parts (For example, CSS-in-JS, or JS-in-Vue, etc.) in the file.
|
|
75
78
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
79
|
+
* - Languages: JS, JSX, TS, TSX, HTML, Vue, Angular, Svelte, Markdown, MDX (languages with embedded code)
|
|
78
80
|
* - Default: `"auto"`
|
|
79
81
|
*/
|
|
80
82
|
embeddedLanguageFormatting?: EmbeddedLanguageFormattingConfig;
|
|
@@ -83,6 +85,7 @@ interface Oxfmtrc {
|
|
|
83
85
|
*
|
|
84
86
|
* NOTE: `"auto"` is not supported.
|
|
85
87
|
*
|
|
88
|
+
* - Languages: All
|
|
86
89
|
* - Default: `"lf"`
|
|
87
90
|
* - Overrides `.editorconfig.end_of_line`
|
|
88
91
|
*/
|
|
@@ -90,6 +93,7 @@ interface Oxfmtrc {
|
|
|
90
93
|
/**
|
|
91
94
|
* Specify the global whitespace sensitivity for HTML, Vue, Angular, and Handlebars.
|
|
92
95
|
*
|
|
96
|
+
* - Languages: HTML, Angular, Vue, Handlebars, Svelte
|
|
93
97
|
* - Default: `"css"`
|
|
94
98
|
*/
|
|
95
99
|
htmlWhitespaceSensitivity?: HtmlWhitespaceSensitivityConfig;
|
|
@@ -103,6 +107,7 @@ interface Oxfmtrc {
|
|
|
103
107
|
/**
|
|
104
108
|
* Whether to insert a final newline at the end of the file.
|
|
105
109
|
*
|
|
110
|
+
* - Languages: All
|
|
106
111
|
* - Default: `true`
|
|
107
112
|
* - Overrides `.editorconfig.insert_final_newline`
|
|
108
113
|
*/
|
|
@@ -116,12 +121,14 @@ interface Oxfmtrc {
|
|
|
116
121
|
*
|
|
117
122
|
* Pass `true` or an object to enable with defaults, or omit/set `false` to disable.
|
|
118
123
|
*
|
|
124
|
+
* - Languages: JS, JSX, TS, TSX
|
|
119
125
|
* - Default: Disabled
|
|
120
126
|
*/
|
|
121
127
|
jsdoc?: JsdocUserConfig;
|
|
122
128
|
/**
|
|
123
129
|
* Use single quotes instead of double quotes in JSX.
|
|
124
130
|
*
|
|
131
|
+
* - Languages: JSX, TSX
|
|
125
132
|
* - Default: `false`
|
|
126
133
|
*/
|
|
127
134
|
jsxSingleQuote?: boolean;
|
|
@@ -131,6 +138,7 @@ interface Oxfmtrc {
|
|
|
131
138
|
* By default, formats objects as multi-line if there is a newline prior to the first property.
|
|
132
139
|
* Authors can use this heuristic to contextually improve readability, though it has some downsides.
|
|
133
140
|
*
|
|
141
|
+
* - Languages: JS, JSX, TS, TSX, JSON, JSONC, JSON5
|
|
134
142
|
* - Default: `"preserve"`
|
|
135
143
|
*/
|
|
136
144
|
objectWrap?: ObjectWrapConfig;
|
|
@@ -146,6 +154,7 @@ interface Oxfmtrc {
|
|
|
146
154
|
*
|
|
147
155
|
* If you don't want line wrapping when formatting Markdown, you can set the `proseWrap` option to disable it.
|
|
148
156
|
*
|
|
157
|
+
* - Languages: All
|
|
149
158
|
* - Default: `100`
|
|
150
159
|
* - Overrides `.editorconfig.max_line_length`
|
|
151
160
|
*/
|
|
@@ -157,24 +166,28 @@ interface Oxfmtrc {
|
|
|
157
166
|
* To wrap prose to the print width, change this option to "always".
|
|
158
167
|
* If you want to force all prose blocks to be on a single line and rely on editor/viewer soft wrapping instead, you can use "never".
|
|
159
168
|
*
|
|
169
|
+
* - Languages: Markdown, MDX, YAML
|
|
160
170
|
* - Default: `"preserve"`
|
|
161
171
|
*/
|
|
162
172
|
proseWrap?: ProseWrapConfig;
|
|
163
173
|
/**
|
|
164
174
|
* Change when properties in objects are quoted.
|
|
165
175
|
*
|
|
176
|
+
* - Languages: JS, JSX, TS, TSX
|
|
166
177
|
* - Default: `"as-needed"`
|
|
167
178
|
*/
|
|
168
179
|
quoteProps?: QuotePropsConfig;
|
|
169
180
|
/**
|
|
170
181
|
* Print semicolons at the ends of statements.
|
|
171
182
|
*
|
|
183
|
+
* - Languages: JS, JSX, TS, TSX
|
|
172
184
|
* - Default: `true`
|
|
173
185
|
*/
|
|
174
186
|
semi?: boolean;
|
|
175
187
|
/**
|
|
176
188
|
* Enforce single attribute per line in HTML, Vue, and JSX.
|
|
177
189
|
*
|
|
190
|
+
* - Languages: JSX, TSX, HTML, Angular, Vue, MJML, Svelte
|
|
178
191
|
* - Default: `false`
|
|
179
192
|
*/
|
|
180
193
|
singleAttributePerLine?: boolean;
|
|
@@ -183,6 +196,7 @@ interface Oxfmtrc {
|
|
|
183
196
|
*
|
|
184
197
|
* For JSX, you can set the `jsxSingleQuote` option.
|
|
185
198
|
*
|
|
199
|
+
* - Languages: JS, JSX, TS, TSX, CSS, Less, SCSS, Markdown, MDX, YAML, Handlebars, Svelte
|
|
186
200
|
* - Default: `false`
|
|
187
201
|
* - Overrides `.editorconfig.quote_type`
|
|
188
202
|
*/
|
|
@@ -195,6 +209,7 @@ interface Oxfmtrc {
|
|
|
195
209
|
*
|
|
196
210
|
* Pass `true` or an object to enable with defaults, or omit/set `false` to disable.
|
|
197
211
|
*
|
|
212
|
+
* - Languages: JS, JSX, TS, TSX
|
|
198
213
|
* - Default: Disabled
|
|
199
214
|
*/
|
|
200
215
|
sortImports?: SortImportsUserConfig;
|
|
@@ -205,6 +220,7 @@ interface Oxfmtrc {
|
|
|
205
220
|
* But we believe it is clearer and easier to navigate.
|
|
206
221
|
* For details, see each field's documentation.
|
|
207
222
|
*
|
|
223
|
+
* - Languages: JSON (`package.json` only)
|
|
208
224
|
* - Default: `true`
|
|
209
225
|
*/
|
|
210
226
|
sortPackageJson?: SortPackageJsonUserConfig;
|
|
@@ -217,6 +233,7 @@ interface Oxfmtrc {
|
|
|
217
233
|
*
|
|
218
234
|
* Pass `true` or an object to enable with defaults, or omit/set `false` to disable.
|
|
219
235
|
*
|
|
236
|
+
* - Languages: JS, JSX, TS, TSX, HTML, Vue, Angular, Handlebars, CSS, SCSS, Less, Svelte
|
|
220
237
|
* - Default: Disabled
|
|
221
238
|
*/
|
|
222
239
|
sortTailwindcss?: SortTailwindcssUserConfig;
|
|
@@ -231,12 +248,14 @@ interface Oxfmtrc {
|
|
|
231
248
|
* but Oxfmt does NOT bundle or auto-install it.
|
|
232
249
|
* You must install `svelte` yourself in your project, formatting will fail at runtime otherwise.
|
|
233
250
|
*
|
|
251
|
+
* - Languages: Svelte
|
|
234
252
|
* - Default: Disabled
|
|
235
253
|
*/
|
|
236
254
|
svelte?: SvelteUserConfig;
|
|
237
255
|
/**
|
|
238
256
|
* Specify the number of spaces per indentation-level.
|
|
239
257
|
*
|
|
258
|
+
* - Languages: All
|
|
240
259
|
* - Default: `2`
|
|
241
260
|
* - Overrides `.editorconfig.indent_size` (falls back to `.editorconfig.tab_width`)
|
|
242
261
|
*/
|
|
@@ -246,12 +265,14 @@ interface Oxfmtrc {
|
|
|
246
265
|
*
|
|
247
266
|
* A single-line array, for example, never gets trailing commas.
|
|
248
267
|
*
|
|
268
|
+
* - Languages: JS, JSX, TS, TSX, JSONC, JSON5, TOML, CSS, Less, SCSS, YAML
|
|
249
269
|
* - Default: `"all"`
|
|
250
270
|
*/
|
|
251
271
|
trailingComma?: TrailingCommaConfig;
|
|
252
272
|
/**
|
|
253
273
|
* Indent lines with tabs instead of spaces.
|
|
254
274
|
*
|
|
275
|
+
* - Languages: All
|
|
255
276
|
* - Default: `false`
|
|
256
277
|
* - Overrides `.editorconfig.indent_style`
|
|
257
278
|
*/
|
|
@@ -259,6 +280,7 @@ interface Oxfmtrc {
|
|
|
259
280
|
/**
|
|
260
281
|
* Whether or not to indent the code inside `<script>` and `<style>` tags in Vue files.
|
|
261
282
|
*
|
|
283
|
+
* - Languages: Vue
|
|
262
284
|
* - Default: `false`
|
|
263
285
|
*/
|
|
264
286
|
vueIndentScriptAndStyle?: boolean;
|
|
@@ -359,6 +381,7 @@ interface FormatConfig {
|
|
|
359
381
|
/**
|
|
360
382
|
* Include parentheses around a sole arrow function parameter.
|
|
361
383
|
*
|
|
384
|
+
* - Languages: JS, JSX, TS, TSX
|
|
362
385
|
* - Default: `"always"`
|
|
363
386
|
*/
|
|
364
387
|
arrowParens?: ArrowParensConfig;
|
|
@@ -366,20 +389,21 @@ interface FormatConfig {
|
|
|
366
389
|
* Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line,
|
|
367
390
|
* instead of being alone on the next line (does not apply to self closing elements).
|
|
368
391
|
*
|
|
392
|
+
* - Languages: JSX, TSX, HTML, Angular, Vue, MJML, Svelte
|
|
369
393
|
* - Default: `false`
|
|
370
394
|
*/
|
|
371
395
|
bracketSameLine?: boolean;
|
|
372
396
|
/**
|
|
373
397
|
* Print spaces between brackets in object literals.
|
|
374
398
|
*
|
|
399
|
+
* - Languages: JS, JSX, TS, TSX, JSON, JSONC, JSON5, GraphQL, YAML
|
|
375
400
|
* - Default: `true`
|
|
376
401
|
*/
|
|
377
402
|
bracketSpacing?: boolean;
|
|
378
403
|
/**
|
|
379
404
|
* Control whether to format embedded parts (For example, CSS-in-JS, or JS-in-Vue, etc.) in the file.
|
|
380
405
|
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
406
|
+
* - Languages: JS, JSX, TS, TSX, HTML, Vue, Angular, Svelte, Markdown, MDX (languages with embedded code)
|
|
383
407
|
* - Default: `"auto"`
|
|
384
408
|
*/
|
|
385
409
|
embeddedLanguageFormatting?: EmbeddedLanguageFormattingConfig;
|
|
@@ -388,6 +412,7 @@ interface FormatConfig {
|
|
|
388
412
|
*
|
|
389
413
|
* NOTE: `"auto"` is not supported.
|
|
390
414
|
*
|
|
415
|
+
* - Languages: All
|
|
391
416
|
* - Default: `"lf"`
|
|
392
417
|
* - Overrides `.editorconfig.end_of_line`
|
|
393
418
|
*/
|
|
@@ -395,12 +420,14 @@ interface FormatConfig {
|
|
|
395
420
|
/**
|
|
396
421
|
* Specify the global whitespace sensitivity for HTML, Vue, Angular, and Handlebars.
|
|
397
422
|
*
|
|
423
|
+
* - Languages: HTML, Angular, Vue, Handlebars, Svelte
|
|
398
424
|
* - Default: `"css"`
|
|
399
425
|
*/
|
|
400
426
|
htmlWhitespaceSensitivity?: HtmlWhitespaceSensitivityConfig;
|
|
401
427
|
/**
|
|
402
428
|
* Whether to insert a final newline at the end of the file.
|
|
403
429
|
*
|
|
430
|
+
* - Languages: All
|
|
404
431
|
* - Default: `true`
|
|
405
432
|
* - Overrides `.editorconfig.insert_final_newline`
|
|
406
433
|
*/
|
|
@@ -414,12 +441,14 @@ interface FormatConfig {
|
|
|
414
441
|
*
|
|
415
442
|
* Pass `true` or an object to enable with defaults, or omit/set `false` to disable.
|
|
416
443
|
*
|
|
444
|
+
* - Languages: JS, JSX, TS, TSX
|
|
417
445
|
* - Default: Disabled
|
|
418
446
|
*/
|
|
419
447
|
jsdoc?: JsdocUserConfig;
|
|
420
448
|
/**
|
|
421
449
|
* Use single quotes instead of double quotes in JSX.
|
|
422
450
|
*
|
|
451
|
+
* - Languages: JSX, TSX
|
|
423
452
|
* - Default: `false`
|
|
424
453
|
*/
|
|
425
454
|
jsxSingleQuote?: boolean;
|
|
@@ -429,6 +458,7 @@ interface FormatConfig {
|
|
|
429
458
|
* By default, formats objects as multi-line if there is a newline prior to the first property.
|
|
430
459
|
* Authors can use this heuristic to contextually improve readability, though it has some downsides.
|
|
431
460
|
*
|
|
461
|
+
* - Languages: JS, JSX, TS, TSX, JSON, JSONC, JSON5
|
|
432
462
|
* - Default: `"preserve"`
|
|
433
463
|
*/
|
|
434
464
|
objectWrap?: ObjectWrapConfig;
|
|
@@ -437,6 +467,7 @@ interface FormatConfig {
|
|
|
437
467
|
*
|
|
438
468
|
* If you don't want line wrapping when formatting Markdown, you can set the `proseWrap` option to disable it.
|
|
439
469
|
*
|
|
470
|
+
* - Languages: All
|
|
440
471
|
* - Default: `100`
|
|
441
472
|
* - Overrides `.editorconfig.max_line_length`
|
|
442
473
|
*/
|
|
@@ -448,24 +479,28 @@ interface FormatConfig {
|
|
|
448
479
|
* To wrap prose to the print width, change this option to "always".
|
|
449
480
|
* If you want to force all prose blocks to be on a single line and rely on editor/viewer soft wrapping instead, you can use "never".
|
|
450
481
|
*
|
|
482
|
+
* - Languages: Markdown, MDX, YAML
|
|
451
483
|
* - Default: `"preserve"`
|
|
452
484
|
*/
|
|
453
485
|
proseWrap?: ProseWrapConfig;
|
|
454
486
|
/**
|
|
455
487
|
* Change when properties in objects are quoted.
|
|
456
488
|
*
|
|
489
|
+
* - Languages: JS, JSX, TS, TSX
|
|
457
490
|
* - Default: `"as-needed"`
|
|
458
491
|
*/
|
|
459
492
|
quoteProps?: QuotePropsConfig;
|
|
460
493
|
/**
|
|
461
494
|
* Print semicolons at the ends of statements.
|
|
462
495
|
*
|
|
496
|
+
* - Languages: JS, JSX, TS, TSX
|
|
463
497
|
* - Default: `true`
|
|
464
498
|
*/
|
|
465
499
|
semi?: boolean;
|
|
466
500
|
/**
|
|
467
501
|
* Enforce single attribute per line in HTML, Vue, and JSX.
|
|
468
502
|
*
|
|
503
|
+
* - Languages: JSX, TSX, HTML, Angular, Vue, MJML, Svelte
|
|
469
504
|
* - Default: `false`
|
|
470
505
|
*/
|
|
471
506
|
singleAttributePerLine?: boolean;
|
|
@@ -474,6 +509,7 @@ interface FormatConfig {
|
|
|
474
509
|
*
|
|
475
510
|
* For JSX, you can set the `jsxSingleQuote` option.
|
|
476
511
|
*
|
|
512
|
+
* - Languages: JS, JSX, TS, TSX, CSS, Less, SCSS, Markdown, MDX, YAML, Handlebars, Svelte
|
|
477
513
|
* - Default: `false`
|
|
478
514
|
* - Overrides `.editorconfig.quote_type`
|
|
479
515
|
*/
|
|
@@ -486,6 +522,7 @@ interface FormatConfig {
|
|
|
486
522
|
*
|
|
487
523
|
* Pass `true` or an object to enable with defaults, or omit/set `false` to disable.
|
|
488
524
|
*
|
|
525
|
+
* - Languages: JS, JSX, TS, TSX
|
|
489
526
|
* - Default: Disabled
|
|
490
527
|
*/
|
|
491
528
|
sortImports?: SortImportsUserConfig;
|
|
@@ -496,6 +533,7 @@ interface FormatConfig {
|
|
|
496
533
|
* But we believe it is clearer and easier to navigate.
|
|
497
534
|
* For details, see each field's documentation.
|
|
498
535
|
*
|
|
536
|
+
* - Languages: JSON (`package.json` only)
|
|
499
537
|
* - Default: `true`
|
|
500
538
|
*/
|
|
501
539
|
sortPackageJson?: SortPackageJsonUserConfig;
|
|
@@ -508,6 +546,7 @@ interface FormatConfig {
|
|
|
508
546
|
*
|
|
509
547
|
* Pass `true` or an object to enable with defaults, or omit/set `false` to disable.
|
|
510
548
|
*
|
|
549
|
+
* - Languages: JS, JSX, TS, TSX, HTML, Vue, Angular, Handlebars, CSS, SCSS, Less, Svelte
|
|
511
550
|
* - Default: Disabled
|
|
512
551
|
*/
|
|
513
552
|
sortTailwindcss?: SortTailwindcssUserConfig;
|
|
@@ -522,12 +561,14 @@ interface FormatConfig {
|
|
|
522
561
|
* but Oxfmt does NOT bundle or auto-install it.
|
|
523
562
|
* You must install `svelte` yourself in your project, formatting will fail at runtime otherwise.
|
|
524
563
|
*
|
|
564
|
+
* - Languages: Svelte
|
|
525
565
|
* - Default: Disabled
|
|
526
566
|
*/
|
|
527
567
|
svelte?: SvelteUserConfig;
|
|
528
568
|
/**
|
|
529
569
|
* Specify the number of spaces per indentation-level.
|
|
530
570
|
*
|
|
571
|
+
* - Languages: All
|
|
531
572
|
* - Default: `2`
|
|
532
573
|
* - Overrides `.editorconfig.indent_size` (falls back to `.editorconfig.tab_width`)
|
|
533
574
|
*/
|
|
@@ -537,12 +578,14 @@ interface FormatConfig {
|
|
|
537
578
|
*
|
|
538
579
|
* A single-line array, for example, never gets trailing commas.
|
|
539
580
|
*
|
|
581
|
+
* - Languages: JS, JSX, TS, TSX, JSONC, JSON5, TOML, CSS, Less, SCSS, YAML
|
|
540
582
|
* - Default: `"all"`
|
|
541
583
|
*/
|
|
542
584
|
trailingComma?: TrailingCommaConfig;
|
|
543
585
|
/**
|
|
544
586
|
* Indent lines with tabs instead of spaces.
|
|
545
587
|
*
|
|
588
|
+
* - Languages: All
|
|
546
589
|
* - Default: `false`
|
|
547
590
|
* - Overrides `.editorconfig.indent_style`
|
|
548
591
|
*/
|
|
@@ -550,6 +593,7 @@ interface FormatConfig {
|
|
|
550
593
|
/**
|
|
551
594
|
* Whether or not to indent the code inside `<script>` and `<style>` tags in Vue files.
|
|
552
595
|
*
|
|
596
|
+
* - Languages: Vue
|
|
553
597
|
* - Default: `false`
|
|
554
598
|
*/
|
|
555
599
|
vueIndentScriptAndStyle?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as sortTailwindClasses, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-
|
|
1
|
+
import { i as jsTextToDoc$1, n as toNullable, r as format$1, t as toFormatFileResult } from "./napi-callbacks-C8y3J_xb.js";
|
|
2
|
+
import { i as sortTailwindClasses, n as formatEmbeddedDoc, r as formatFile, t as formatEmbeddedCode } from "./apis-CngUzqDq.js";
|
|
3
3
|
//#region src-js/index.ts
|
|
4
4
|
/**
|
|
5
5
|
* Define an oxfmt configuration with type inference.
|
|
@@ -13,34 +13,34 @@ function defineConfig(config) {
|
|
|
13
13
|
async function format(fileName, sourceText, options) {
|
|
14
14
|
if (typeof fileName !== "string") throw new TypeError("`fileName` must be a string");
|
|
15
15
|
if (typeof sourceText !== "string") throw new TypeError("`sourceText` must be a string");
|
|
16
|
-
return format$1(fileName, sourceText, options ?? {}, (options, code) => formatFile({
|
|
16
|
+
return format$1(fileName, sourceText, options ?? {}, (options, code) => toFormatFileResult(formatFile({
|
|
17
17
|
options,
|
|
18
18
|
code
|
|
19
|
-
}), (options, code) => formatEmbeddedCode({
|
|
19
|
+
})), (options, code) => toNullable(formatEmbeddedCode({
|
|
20
20
|
options,
|
|
21
21
|
code
|
|
22
|
-
}), (options, texts) => formatEmbeddedDoc({
|
|
22
|
+
})), (options, texts) => toNullable(formatEmbeddedDoc({
|
|
23
23
|
options,
|
|
24
24
|
texts
|
|
25
|
-
}), (options, classes) => sortTailwindClasses({
|
|
25
|
+
})), (options, classes) => toNullable(sortTailwindClasses({
|
|
26
26
|
options,
|
|
27
27
|
classes
|
|
28
|
-
}));
|
|
28
|
+
})));
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Format a JS/TS snippet for Prettier `textToDoc()` plugin flow.
|
|
32
32
|
*/
|
|
33
33
|
async function jsTextToDoc(sourceExt, sourceText, oxfmtPluginOptionsJson, parentContext) {
|
|
34
|
-
return jsTextToDoc$1(sourceExt, sourceText, oxfmtPluginOptionsJson, parentContext, (
|
|
34
|
+
return jsTextToDoc$1(sourceExt, sourceText, oxfmtPluginOptionsJson, parentContext, () => toFormatFileResult(Promise.reject("formatFile is unavailable for jsTextToDoc")), (options, code) => toNullable(formatEmbeddedCode({
|
|
35
35
|
options,
|
|
36
36
|
code
|
|
37
|
-
}), (options, texts) => formatEmbeddedDoc({
|
|
37
|
+
})), (options, texts) => toNullable(formatEmbeddedDoc({
|
|
38
38
|
options,
|
|
39
39
|
texts
|
|
40
|
-
}), (options, classes) => sortTailwindClasses({
|
|
40
|
+
})), (options, classes) => toNullable(sortTailwindClasses({
|
|
41
41
|
options,
|
|
42
42
|
classes
|
|
43
|
-
}));
|
|
43
|
+
})));
|
|
44
44
|
}
|
|
45
45
|
//#endregion
|
|
46
46
|
export { defineConfig, format, jsTextToDoc };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as __toESM, i as __require, t as __commonJSMin } from "./chunk-DSjvVL_1-
|
|
1
|
+
import { a as __toESM, i as __require, t as __commonJSMin } from "./chunk-DSjvVL_1-BUO3FyMh.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
//#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.2b6f3c2_prettier-plugin-svelte@4.
|
|
3
|
+
//#region ../../node_modules/.pnpm/prettier-plugin-tailwindcss@0.0.0-insiders.2b6f3c2_prettier-plugin-svelte@4.1.0_prettie_e3345e2f5995e2d14d8ee5c58c9c043a/node_modules/prettier-plugin-tailwindcss/dist/jiti-Bb1dT6Cw.mjs
|
|
4
4
|
var require_jiti = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5
5
|
(() => {
|
|
6
6
|
var e = { "./node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist lazy recursive": function(e) {
|