oxfmt 0.57.0 → 0.58.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/dist/{acorn-LGWopQvF.js → acorn-CZllRq2x.js} +1893 -1803
- package/dist/{angular-BbAuvH72.js → angular-CsoDKqo4.js} +1587 -995
- package/dist/{apis-CvFX8LhR.js → apis-DLO0lBDu.js} +4 -4
- package/dist/babel-DZD6u90w.js +9896 -0
- package/dist/{bindings-Cj_GMsoO.js → bindings-DTiEua0g.js} +26 -26
- package/dist/{chunk-DSjvVL_1-DllBg9tc.js → chunk-DSjvVL_1-DX2STy_I.js} +1 -1
- package/dist/cli-worker.d.ts +5 -5
- package/dist/cli-worker.js +1 -1
- package/dist/cli.js +3 -2
- package/dist/{dist-BKyxiMdj.js → dist-YOS4M6hk.js} +17 -17
- package/dist/estree-ChnhgzGg.js +7885 -0
- package/dist/flow-C6LkWPPl.js +9149 -0
- package/dist/{glimmer-Ba_8Z2bG.js → glimmer-YnkKK2a7.js} +204 -187
- package/dist/{graphql-CZ7EPWgo.js → graphql-BNiwkZTo.js} +905 -820
- package/dist/{html-DblM11Xw.js → html-DMHXIbrM.js} +1416 -1305
- package/dist/index.js +3 -3
- package/dist/{jiti-Bb1dT6Cw-0c6As3U-.js → jiti-Bb1dT6Cw-B61jQmj-.js} +2 -2
- package/dist/markdown-BjyDFyaO.js +14010 -0
- package/dist/{meriyah-DafjRZfO.js → meriyah-zDNCk2o1.js} +1501 -1429
- package/dist/{migrate-prettier-DrYAkU3F.js → migrate-prettier-BmSsy164.js} +49 -42
- package/dist/{plugin-BuVceHGR.js → plugin-B4cguZ1l.js} +16 -12
- package/dist/{postcss-CkhtwsAS.js → postcss-CwPwODg8.js} +2153 -2002
- package/dist/{prettier-DKAx5A83.js → prettier-BByt4AhK.js} +5674 -5038
- package/dist/{sorter-BZkvDMjt-C8qUPUh2.js → sorter-BZkvDMjt-B8ihSEiX.js} +7 -7
- package/dist/{sorter-DSVZH4kF.js → sorter-BcGkkjyR.js} +1 -1
- package/dist/{typescript-DaxiA0nr.js → typescript-Bq_S3kyC.js} +10499 -10252
- package/dist/{v3-D-mr2VVh-Ch8a-2Ce.js → v3-D-mr2VVh-p01OHBjH.js} +4 -4
- package/dist/{v4-C-HWEQJm-DheWK34Z.js → v4-C-HWEQJm-BbuYNtSW.js} +4 -4
- package/dist/yaml-DlyuuZmC.js +6121 -0
- package/package.json +20 -20
- package/dist/babel-DLjwvkt5.js +0 -9884
- package/dist/estree-DbmUPhmV.js +0 -7269
- package/dist/flow-CJbpv7JL.js +0 -52916
- package/dist/markdown-B5hFVJKQ.js +0 -6880
- package/dist/yaml-BC7gw7un.js +0 -5280
|
@@ -9,7 +9,7 @@ import { readFile } from "node:fs/promises";
|
|
|
9
9
|
async function runMigratePrettier() {
|
|
10
10
|
const cwd = process.cwd();
|
|
11
11
|
if (await hasOxfmtrcFile(cwd)) return exitWithError("Oxfmt configuration file already exists.");
|
|
12
|
-
const { resolveConfigFile, resolveConfig } = await import("./prettier-
|
|
12
|
+
const { resolveConfigFile, resolveConfig } = await import("./prettier-BByt4AhK.js");
|
|
13
13
|
const prettierConfigPath = await resolveConfigFile(join(cwd, "dummy.js"));
|
|
14
14
|
if (!prettierConfigPath) {
|
|
15
15
|
console.log("No Prettier configuration file found.");
|
|
@@ -31,24 +31,32 @@ async function runMigratePrettier() {
|
|
|
31
31
|
return exitWithError(`Failed to parse: ${prettierConfigPath}`);
|
|
32
32
|
}
|
|
33
33
|
const oxfmtrc = await createBlankOxfmtrcFile(cwd);
|
|
34
|
+
let hasTailwindcssPlugin = false;
|
|
34
35
|
let hasSortPackageJsonPlugin = false;
|
|
36
|
+
let hasSveltePlugin = false;
|
|
35
37
|
for (const [key, value] of Object.entries(prettierConfig ?? {})) {
|
|
36
38
|
if (key === "plugins" && Array.isArray(value)) {
|
|
37
|
-
for (const plugin of value) if (plugin === "prettier-plugin-tailwindcss")
|
|
39
|
+
for (const plugin of value) if (plugin === "prettier-plugin-tailwindcss") hasTailwindcssPlugin = true;
|
|
38
40
|
else if (plugin === "prettier-plugin-packagejson") hasSortPackageJsonPlugin = true;
|
|
41
|
+
else if (plugin === "prettier-plugin-svelte") hasSveltePlugin = true;
|
|
39
42
|
else if (typeof plugin === "string") console.error(` - plugins: "${plugin}" is not supported, skipping...`);
|
|
40
43
|
else console.error(` - plugins: custom plugin module is not supported, skipping...`);
|
|
41
44
|
continue;
|
|
42
45
|
}
|
|
46
|
+
if (key === "parser" || key === "filepath") continue;
|
|
47
|
+
if (key === "requirePragma" || key === "insertPragma") {
|
|
48
|
+
console.error(` - "${key}" is not supported, skipping...`);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
43
51
|
if (key === "endOfLine" && value === "auto") {
|
|
44
52
|
console.error(` - "endOfLine: auto" is not supported, skipping...`);
|
|
45
53
|
continue;
|
|
46
54
|
}
|
|
47
55
|
if (key === "experimentalTernaries" || key === "experimentalOperatorPosition") {
|
|
48
|
-
console.error(` - "${key}" is not supported
|
|
56
|
+
console.error(` - "${key}" is not supported yet`);
|
|
49
57
|
continue;
|
|
50
58
|
}
|
|
51
|
-
if (key.startsWith("tailwind")) continue;
|
|
59
|
+
if (key.startsWith("tailwind") || key.startsWith("svelte")) continue;
|
|
52
60
|
oxfmtrc[key] = value;
|
|
53
61
|
}
|
|
54
62
|
if (typeof oxfmtrc.printWidth !== "number") {
|
|
@@ -59,12 +67,19 @@ async function runMigratePrettier() {
|
|
|
59
67
|
oxfmtrc.sortPackageJson = {};
|
|
60
68
|
console.error(` - Migrated "prettier-plugin-packagejson" to "sortPackageJson"`);
|
|
61
69
|
} else oxfmtrc.sortPackageJson = false;
|
|
62
|
-
if (
|
|
70
|
+
if (hasTailwindcssPlugin) {
|
|
71
|
+
oxfmtrc.sortTailwindcss = migrateMappedOptions(prettierConfig, TAILWIND_OPTION_MAPPING, filterTailwindRegex);
|
|
72
|
+
console.log("Migrated prettier-plugin-tailwindcss options to sortTailwindcss");
|
|
73
|
+
}
|
|
74
|
+
if (hasSveltePlugin) {
|
|
75
|
+
oxfmtrc.svelte = migrateMappedOptions(prettierConfig, SVELTE_OPTION_MAPPING);
|
|
76
|
+
console.log("Migrated prettier-plugin-svelte options to svelte");
|
|
77
|
+
}
|
|
63
78
|
const ignores = await resolvePrettierIgnore(cwd);
|
|
64
79
|
if (ignores.length > 0) console.log("Migrated ignore patterns from `.prettierignore`");
|
|
65
80
|
delete oxfmtrc.ignorePatterns;
|
|
66
81
|
oxfmtrc.ignorePatterns = ignores;
|
|
67
|
-
if (
|
|
82
|
+
if (await rawConfigHasOverrides(prettierConfigPath)) console.warn(` - "overrides" cannot be migrated automatically. See: https://github.com/oxc-project/oxc/issues/18215`);
|
|
68
83
|
const jsonStr = JSON.stringify(oxfmtrc, null, 2);
|
|
69
84
|
try {
|
|
70
85
|
await saveOxfmtrcFile(cwd, jsonStr);
|
|
@@ -85,6 +100,14 @@ async function resolvePrettierIgnore(cwd) {
|
|
|
85
100
|
} catch {}
|
|
86
101
|
return ignores;
|
|
87
102
|
}
|
|
103
|
+
async function rawConfigHasOverrides(configPath) {
|
|
104
|
+
try {
|
|
105
|
+
const content = await readFile(configPath, "utf8");
|
|
106
|
+
return /^\s*(?:\[\[\s*overrides\s*\]\]|["']?overrides["']?\s*[:=])/mv.test(content);
|
|
107
|
+
} catch {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
88
111
|
const TAILWIND_OPTION_MAPPING = {
|
|
89
112
|
config: "tailwindConfig",
|
|
90
113
|
stylesheet: "tailwindStylesheet",
|
|
@@ -93,44 +116,28 @@ const TAILWIND_OPTION_MAPPING = {
|
|
|
93
116
|
preserveWhitespace: "tailwindPreserveWhitespace",
|
|
94
117
|
preserveDuplicates: "tailwindPreserveDuplicates"
|
|
95
118
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* "tailwindFunctions": ["clsx", "cn"]
|
|
105
|
-
* }
|
|
106
|
-
* ```
|
|
107
|
-
*
|
|
108
|
-
* Oxfmt format:
|
|
109
|
-
* ```json
|
|
110
|
-
* {
|
|
111
|
-
* "sortTailwindcss": {
|
|
112
|
-
* "config": "./tailwind.config.js",
|
|
113
|
-
* "functions": ["clsx", "cn"]
|
|
114
|
-
* }
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
function migrateTailwindOptions(prettierConfig, oxfmtrc) {
|
|
119
|
-
const tailwindOptions = {};
|
|
120
|
-
for (const [oxfmtKey, prettierKey] of Object.entries(TAILWIND_OPTION_MAPPING)) {
|
|
119
|
+
const SVELTE_OPTION_MAPPING = {
|
|
120
|
+
allowShorthand: "svelteAllowShorthand",
|
|
121
|
+
indentScriptAndStyle: "svelteIndentScriptAndStyle",
|
|
122
|
+
sortOrder: "svelteSortOrder"
|
|
123
|
+
};
|
|
124
|
+
function migrateMappedOptions(prettierConfig, mapping, transform) {
|
|
125
|
+
const result = {};
|
|
126
|
+
for (const [oxfmtKey, prettierKey] of Object.entries(mapping)) {
|
|
121
127
|
const value = prettierConfig[prettierKey];
|
|
122
|
-
if (value
|
|
123
|
-
|
|
124
|
-
for (const item of value) if (typeof item === "string" && item.startsWith("/") && item.endsWith("/")) {
|
|
125
|
-
console.warn(` - Do not support regex in "${prettierKey}" option yet, skipping: ${item}`);
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
tailwindOptions[oxfmtKey] = value;
|
|
130
|
-
}
|
|
128
|
+
if (value === void 0) continue;
|
|
129
|
+
result[oxfmtKey] = transform ? transform(prettierKey, value) : value;
|
|
131
130
|
}
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
function filterTailwindRegex(prettierKey, value) {
|
|
134
|
+
if (prettierKey !== "tailwindFunctions" && prettierKey !== "tailwindAttributes" || !Array.isArray(value)) return value;
|
|
135
|
+
return value.filter((item) => {
|
|
136
|
+
if (typeof item !== "string") return false;
|
|
137
|
+
const isRegex = item.startsWith("/") && item.endsWith("/");
|
|
138
|
+
if (isRegex) console.warn(` - Regexp in "${prettierKey}" option is not supported, skipping: ${item}`);
|
|
139
|
+
return !isRegex;
|
|
140
|
+
});
|
|
134
141
|
}
|
|
135
142
|
//#endregion
|
|
136
143
|
export { runMigratePrettier };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as __toCommonJS, i as __require, t as __commonJSMin } from "./rolldown-runtime-CE-6LUnI.js";
|
|
2
|
-
import { n as init_babel, t as babel_exports } from "./babel-
|
|
3
|
-
import { n as prettier_exports, t as init_prettier } from "./prettier-
|
|
4
|
-
//#region ../../node_modules/.pnpm/prettier-plugin-svelte@4.1.1_prettier@3.
|
|
2
|
+
import { n as init_babel, t as babel_exports } from "./babel-DZD6u90w.js";
|
|
3
|
+
import { n as prettier_exports, t as init_prettier } from "./prettier-BByt4AhK.js";
|
|
4
|
+
//#region ../../node_modules/.pnpm/prettier-plugin-svelte@4.1.1_prettier@3.9.4_svelte@5.56.4_@typescript-eslint+types@8.62.0_/node_modules/prettier-plugin-svelte/plugin.js
|
|
5
5
|
var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
var prettierPluginBabel = (init_babel(), __toCommonJS(babel_exports));
|
|
@@ -148,7 +148,8 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
148
148
|
const newSource = _source.replace(regex, (match, attributes, content, index) => {
|
|
149
149
|
if (match.startsWith("<!--") || withinOtherSpan(index)) return match;
|
|
150
150
|
if (langTsRegex.test(attributes)) isTypescript = true;
|
|
151
|
-
const
|
|
151
|
+
const encodedContent = stringToBase64(content);
|
|
152
|
+
const newContent = `<${tagName}${attributes} ${snippedTagContentAttribute}="${encodedContent}">${placeholder}</${tagName}>`;
|
|
152
153
|
const lengthDiff = match.length - newContent.length;
|
|
153
154
|
newScriptMatchSpans = adjustSpans(scriptMatchSpans, newScriptMatchSpans);
|
|
154
155
|
newStyleMatchSpans = adjustSpans(styleMatchSpans, newStyleMatchSpans);
|
|
@@ -1565,7 +1566,8 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
1565
1566
|
*/
|
|
1566
1567
|
function splitTextToDocs(node) {
|
|
1567
1568
|
const text = getUnencodedText(node);
|
|
1568
|
-
|
|
1569
|
+
const lines = text.split(/[\t\n\f\r ]+/);
|
|
1570
|
+
let docs = join(line, lines).filter((doc) => doc !== "");
|
|
1569
1571
|
if (startsWithLinebreak(text)) docs[0] = hardline;
|
|
1570
1572
|
if (startsWithLinebreak(text, 2)) docs = [hardline, ...docs];
|
|
1571
1573
|
if (endsWithLinebreak(text)) docs[docs.length - 1] = hardline;
|
|
@@ -1795,7 +1797,8 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
1795
1797
|
const body = yield textToDoc(content, { parser });
|
|
1796
1798
|
if (parser === "pug" && typeof body === "string") {
|
|
1797
1799
|
const whitespace = options.useTabs ? " " : " ".repeat(options.pugTabWidth && options.pugTabWidth > 0 ? options.pugTabWidth : options.tabWidth);
|
|
1798
|
-
|
|
1800
|
+
const pugBody = body.split("\n").map((line) => line ? whitespace + line : line).join("\n");
|
|
1801
|
+
return [hardline$1, pugBody];
|
|
1799
1802
|
}
|
|
1800
1803
|
const indentIfDesired = (doc) => options.svelteIndentScriptAndStyle ? indent$1(doc) : doc;
|
|
1801
1804
|
trimRight([body], isLine);
|
|
@@ -1817,13 +1820,14 @@ var require_plugin = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
1817
1820
|
emptyLineAfter: false
|
|
1818
1821
|
}));
|
|
1819
1822
|
const body = isNodeSupportedLanguage(node) && !isIgnoreDirective((_b = previousComments[previousComments.length - 1]) === null || _b === void 0 ? void 0 : _b.comment) && (tag !== "template" || options.plugins.some((plugin) => typeof plugin !== "string" && !(plugin instanceof URL) && plugin.name === "prettier-plugin-svelte" && plugin.parsers && plugin.parsers.pug)) ? content.trim() !== "" ? yield formatBodyContent(content) : content === "" ? "" : hardline$1 : preformattedBody(content);
|
|
1823
|
+
const openingTag = group$1([
|
|
1824
|
+
"<",
|
|
1825
|
+
tag,
|
|
1826
|
+
indent$1(group$1([...path.map(printWithPrependedAttributeLine(node, options, print), "attributes"), isBracketSameLine(options) ? "" : dedent$1(softline$1)])),
|
|
1827
|
+
">"
|
|
1828
|
+
]);
|
|
1820
1829
|
let result = group$1([
|
|
1821
|
-
|
|
1822
|
-
"<",
|
|
1823
|
-
tag,
|
|
1824
|
-
indent$1(group$1([...path.map(printWithPrependedAttributeLine(node, options, print), "attributes"), isBracketSameLine(options) ? "" : dedent$1(softline$1)])),
|
|
1825
|
-
">"
|
|
1826
|
-
]),
|
|
1830
|
+
openingTag,
|
|
1827
1831
|
body,
|
|
1828
1832
|
"</",
|
|
1829
1833
|
tag,
|