mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
feat(oxfmt)!: improve --migrate prettier (#27444)
Fixes #18215 - Search Prettier config only in the CWD, in the same order as Prettier - Exit with an error if not found, instead of creating a blank `.oxfmtrc.json` - Nested configs should be migrated by running in each directory - Load the config without `prettier.resolveConfig()` - JS/TS configs: `import()` - `.json` and `package.json`: `import()` with `{ type: "json" }` - `.prettierrc`: `JSON.parse()` - Shareable config (e.g. `"prettier": "@company/prettier-config"`): `createRequire()` - ⚠️ YAML, JSON5 and TOML: not supported, exit with an error - Migrate `overrides` - Unsupported options like `parser` and `plugins` are skipped with a warning - Migrate only Prettier-compatible options, and warn about the others - Previously, unknown keys like `importOrder` were copied as-is - Warn that the logic in JS/TS configs is not preserved - Also check `oxfmt.config.ts` and `oxfmt.config.mts` as existing config - Suggest running `oxfmt` after migration, since the generated file may not be formatted
This commit is contained in:
1 parent
a6e882660d
commit
1ef2888e33
34 files changed
+1092
-274
No files matched your search
@@ -1,172 +1,110 @@
|
||||
/* oxlint-disable no-console */
|
||||
|
||||
import { join } from "node:path";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { basename, extname, join } from "node:path";
|
||||
import { readdir, readFile } from "node:fs/promises";
|
||||
import { createRequire } from "node:module";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { hasOxfmtrcFile, createBlankOxfmtrcFile, saveOxfmtrcFile, exitWithError } from "./shared";
|
||||
import { Options } from "prettier";
|
||||
|
||||
/**
|
||||
* Run the `--migrate prettier` command to migrate various Prettier's config to `.oxfmtrc.json` file.
|
||||
* Run the `--migrate prettier` command to migrate Prettier's config in the cwd to `.oxfmtrc.json` file.
|
||||
* https://prettier.io/docs/configuration
|
||||
*/
|
||||
export async function runMigratePrettier() {
|
||||
const cwd = process.cwd();
|
||||
|
||||
if (await hasOxfmtrcFile(cwd)) {
|
||||
return exitWithError("Oxfmt configuration file already exists.");
|
||||
return exitWithError("Oxfmt config file already exists.\nRemove it and re-run.");
|
||||
}
|
||||
|
||||
// XXX: If you statically import `prettier` here,
|
||||
// completely unsure why, but Prettier hangs forever when run via `napi`...
|
||||
const { resolveConfigFile, resolveConfig } = await import("prettier");
|
||||
|
||||
// TODO: Support nested config?
|
||||
// For now, we assume the config for a dummy file at the `cwd`.
|
||||
const prettierConfigPath = await resolveConfigFile(join(cwd, "dummy.js"));
|
||||
|
||||
// No Prettier config found, fallback with `--init` behavior
|
||||
// Only the cwd is searched, nested configs need to be migrated by running in each directory.
|
||||
const prettierConfigPath = await findPrettierConfigFile(cwd);
|
||||
if (!prettierConfigPath) {
|
||||
console.log("No Prettier configuration file found.");
|
||||
|
||||
const oxfmtrc = await createBlankOxfmtrcFile(cwd);
|
||||
const jsonStr = JSON.stringify(oxfmtrc, null, 2);
|
||||
|
||||
// TODO: Create napi `validateConfig()` and use to ensure validity?
|
||||
|
||||
try {
|
||||
await saveOxfmtrcFile(cwd, jsonStr);
|
||||
console.log("Created `.oxfmtrc.json` instead.");
|
||||
} catch {
|
||||
exitWithError("Failed to create `.oxfmtrc.json`.");
|
||||
}
|
||||
|
||||
return;
|
||||
return exitWithError(
|
||||
"No Prettier config file found in the current directory.\nRun `oxfmt --migrate prettier` in the directory where the Prettier config is, or use `--init` to create a blank `.oxfmtrc.json`.",
|
||||
);
|
||||
}
|
||||
|
||||
let prettierConfig;
|
||||
let prettierConfig: Record<string, unknown>;
|
||||
try {
|
||||
prettierConfig = await resolveConfig(prettierConfigPath, {
|
||||
// Avoid merging `.editorconfig` values
|
||||
editorconfig: false,
|
||||
});
|
||||
console.log("Found Prettier configuration at:", prettierConfigPath);
|
||||
} catch {
|
||||
return exitWithError(`Failed to parse: ${prettierConfigPath}`);
|
||||
prettierConfig = await loadPrettierConfig(prettierConfigPath);
|
||||
console.log("Found Prettier config at:", prettierConfigPath);
|
||||
} catch (err) {
|
||||
return exitWithError(
|
||||
`Failed to load Prettier config at: ${prettierConfigPath}\n${err instanceof Error ? err.message : String(err)}`,
|
||||
);
|
||||
}
|
||||
|
||||
// Start with blank, then fill in from `prettierConfig`.
|
||||
const oxfmtrc = await createBlankOxfmtrcFile(cwd);
|
||||
|
||||
let hasTailwindcssPlugin = false;
|
||||
let hasSortPackageJsonPlugin = false;
|
||||
let hasSveltePlugin = false;
|
||||
let hasAstroPlugin = false;
|
||||
for (const [key, value] of Object.entries(prettierConfig ?? {})) {
|
||||
// Handle plugins - check for known plugins and warn about others
|
||||
if (key === "plugins" && Array.isArray(value)) {
|
||||
for (const plugin of (value as Options["plugins"])!) {
|
||||
if (plugin === "prettier-plugin-tailwindcss") {
|
||||
hasTailwindcssPlugin = true;
|
||||
} else if (plugin === "prettier-plugin-packagejson") {
|
||||
hasSortPackageJsonPlugin = true;
|
||||
} else if (plugin === "prettier-plugin-svelte") {
|
||||
hasSveltePlugin = true;
|
||||
} else if (plugin === "prettier-plugin-astro") {
|
||||
hasAstroPlugin = true;
|
||||
} else if (typeof plugin === "string") {
|
||||
console.error(` - plugins: "${plugin}" is not supported, skipping...`);
|
||||
} else {
|
||||
console.error(` - plugins: custom plugin module is not supported, skipping...`);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Per-file options that should not appear in a shared config; drop if leaked in
|
||||
if (key === "parser" || key === "filepath") {
|
||||
continue;
|
||||
}
|
||||
// Prettier-only options without an Oxfmt equivalent
|
||||
if (key === "requirePragma" || key === "insertPragma") {
|
||||
console.error(` - "${key}" is not supported, skipping...`);
|
||||
continue;
|
||||
}
|
||||
// Oxfmt does not support this, fallback to default
|
||||
if (key === "endOfLine" && value === "auto") {
|
||||
console.error(` - "endOfLine: auto" is not supported, skipping...`);
|
||||
continue;
|
||||
}
|
||||
// Oxfmt does not support this experimental option yet
|
||||
if (key === "experimentalTernaries") {
|
||||
console.error(` - "${key}" is not supported yet`);
|
||||
continue;
|
||||
}
|
||||
const { plugins, overrides, $schema: _, ...options } = prettierConfig;
|
||||
|
||||
// Skip plugin-specific options - handled separately
|
||||
if (key.startsWith("tailwind") || key.startsWith("svelte") || key.startsWith("astro")) {
|
||||
continue;
|
||||
// Handle plugins - check for known plugins and warn about others
|
||||
const enabledPlugins = new Set<string>();
|
||||
for (const plugin of Array.isArray(plugins) ? plugins : []) {
|
||||
if (KNOWN_PLUGINS.has(plugin)) {
|
||||
enabledPlugins.add(plugin);
|
||||
} else if (typeof plugin === "string") {
|
||||
warnings.push(`plugins: "${plugin}" is not supported, skipping...`);
|
||||
} else {
|
||||
warnings.push(`plugins: custom plugin module is not supported, skipping...`);
|
||||
}
|
||||
|
||||
// Otherwise, copy the value.
|
||||
// This may include options that do not affect Oxfmt, like `vueIndentScriptAndStyle`.
|
||||
oxfmtrc[key] = value;
|
||||
}
|
||||
|
||||
Object.assign(oxfmtrc, migrateOptions(options, true));
|
||||
|
||||
// `printWidth` has different default between Prettier and Oxfmt.
|
||||
// Oxfmt default is 100, Prettier default is 80.
|
||||
if (typeof oxfmtrc.printWidth !== "number") {
|
||||
console.error(
|
||||
` - "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)`,
|
||||
warnings.push(
|
||||
`"printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)`,
|
||||
);
|
||||
oxfmtrc.printWidth = 80;
|
||||
}
|
||||
// `sortPackageJson` is enabled by default in Oxfmt, but Prettier does not have this.
|
||||
// Only enable if `prettier-plugin-packagejson` is used.
|
||||
if (hasSortPackageJsonPlugin) {
|
||||
if (enabledPlugins.has("prettier-plugin-packagejson")) {
|
||||
oxfmtrc.sortPackageJson = {};
|
||||
console.error(` - Migrated "prettier-plugin-packagejson" to "sortPackageJson"`);
|
||||
console.log(` - Migrated "prettier-plugin-packagejson" to "sortPackageJson"`);
|
||||
} else {
|
||||
oxfmtrc.sortPackageJson = false;
|
||||
}
|
||||
// Plugin options: only enable when the corresponding Prettier plugin is used.
|
||||
// Empty object means "enabled with defaults"; Tailwind, Svelte and Astro are disabled by default.
|
||||
if (hasTailwindcssPlugin) {
|
||||
oxfmtrc.sortTailwindcss = migrateMappedOptions(
|
||||
prettierConfig!,
|
||||
TAILWIND_OPTION_MAPPING,
|
||||
filterTailwindRegex,
|
||||
);
|
||||
console.log("Migrated prettier-plugin-tailwindcss options to sortTailwindcss");
|
||||
}
|
||||
if (hasSveltePlugin) {
|
||||
oxfmtrc.svelte = migrateMappedOptions(prettierConfig!, SVELTE_OPTION_MAPPING);
|
||||
console.log("Migrated prettier-plugin-svelte options to svelte");
|
||||
}
|
||||
if (hasAstroPlugin) {
|
||||
oxfmtrc.astro = migrateMappedOptions(
|
||||
prettierConfig!,
|
||||
ASTRO_OPTION_MAPPING,
|
||||
normalizeAstroCompressHTML,
|
||||
);
|
||||
console.log("Migrated prettier-plugin-astro options to astro");
|
||||
Object.assign(oxfmtrc, migratePluginOptions(options, enabledPlugins, true));
|
||||
|
||||
if (Array.isArray(overrides)) {
|
||||
const oxfmtOverrides = [];
|
||||
for (const { files, excludeFiles, options = {} } of overrides) {
|
||||
const migrated = {
|
||||
...migrateOptions(options, false),
|
||||
...migratePluginOptions(options, enabledPlugins, false),
|
||||
};
|
||||
// e.g. `{ files: "*.svg", options: { parser: "html" } }`
|
||||
if (Object.keys(migrated).length === 0) continue;
|
||||
oxfmtOverrides.push({
|
||||
files: [files].flat(),
|
||||
...(excludeFiles !== undefined && { excludeFiles: [excludeFiles].flat() }),
|
||||
options: migrated,
|
||||
});
|
||||
}
|
||||
if (oxfmtOverrides.length > 0) {
|
||||
oxfmtrc.overrides = oxfmtOverrides;
|
||||
console.log(` - Migrated "overrides"`);
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate `ignorePatterns` from `.prettierignore`
|
||||
const ignores = await resolvePrettierIgnore(cwd);
|
||||
if (ignores.length > 0) {
|
||||
console.log("Migrated ignore patterns from `.prettierignore`");
|
||||
console.log(" - Migrated ignore patterns from `.prettierignore`");
|
||||
}
|
||||
// Keep ignorePatterns at the bottom
|
||||
delete oxfmtrc.ignorePatterns;
|
||||
oxfmtrc.ignorePatterns = ignores;
|
||||
|
||||
// TODO: Oxfmt now supports `overrides`,
|
||||
// but `overrides` field is stripped from `resolveConfig()` result.
|
||||
// Automatic migration requires reading the raw config file and handling each format
|
||||
// (JSON, JSONC, YAML, JS/CJS/MJS, TOML, package.json).
|
||||
// See: https://github.com/oxc-project/oxc/issues/18215
|
||||
if (await rawConfigHasOverrides(prettierConfigPath)) {
|
||||
console.warn(
|
||||
` - "overrides" cannot be migrated automatically. See: https://github.com/oxc-project/oxc/issues/18215`,
|
||||
if (JS_EXTENSIONS.has(extname(prettierConfigPath))) {
|
||||
warnings.push(
|
||||
`\`${basename(prettierConfigPath)}\` was evaluated and migrated as static values, any logic in it is not preserved,\n port it to \`oxfmt.config.ts\` manually if needed`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -176,7 +114,10 @@ export async function runMigratePrettier() {
|
||||
|
||||
try {
|
||||
await saveOxfmtrcFile(cwd, jsonStr);
|
||||
console.log("Created `.oxfmtrc.json`.");
|
||||
console.log("Created `.oxfmtrc.json`.\nIt may not be formatted yet, run `oxfmt` to format it.");
|
||||
if (warnings.length > 0) {
|
||||
console.error(`\nPlease review:\n${warnings.map((w) => ` - ${w}`).join("\n")}`);
|
||||
}
|
||||
} catch {
|
||||
return exitWithError("Failed to create `.oxfmtrc.json`.");
|
||||
}
|
||||
@@ -184,6 +125,90 @@ export async function runMigratePrettier() {
|
||||
|
||||
// ---
|
||||
|
||||
// Collected and printed at the end, not to be mixed with progress logs
|
||||
const warnings: string[] = [];
|
||||
|
||||
// Same order as Prettier's config searcher.
|
||||
// https://github.com/prettier/prettier/blob/main/src/config/prettier-config/config-searcher.js
|
||||
const CONFIG_FILES = [
|
||||
"package.json",
|
||||
// ponytail: `package.yaml` is not searched, since checking its `prettier` field requires YAML parser
|
||||
".prettierrc",
|
||||
".prettierrc.json",
|
||||
".prettierrc.yml",
|
||||
".prettierrc.yaml",
|
||||
".prettierrc.json5",
|
||||
".prettierrc.js",
|
||||
"prettier.config.js",
|
||||
".prettierrc.ts",
|
||||
"prettier.config.ts",
|
||||
".prettierrc.mjs",
|
||||
"prettier.config.mjs",
|
||||
".prettierrc.mts",
|
||||
"prettier.config.mts",
|
||||
".prettierrc.cjs",
|
||||
"prettier.config.cjs",
|
||||
".prettierrc.cts",
|
||||
"prettier.config.cts",
|
||||
".prettierrc.toml",
|
||||
];
|
||||
|
||||
const JS_EXTENSIONS = new Set([".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]);
|
||||
|
||||
async function findPrettierConfigFile(cwd: string) {
|
||||
const names = new Set(await readdir(cwd));
|
||||
for (const name of CONFIG_FILES) {
|
||||
if (!names.has(name)) continue;
|
||||
const path = join(cwd, name);
|
||||
// oxlint-disable-next-line no-await-in-loop -- only for `package.json`
|
||||
if (name === "package.json" && (await importJson(path)).prettier === undefined) continue;
|
||||
return path;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Only the formats loadable without extra parsers are supported.
|
||||
async function loadPrettierConfig(path: string): Promise<Record<string, unknown>> {
|
||||
const name = basename(path);
|
||||
const ext = extname(path);
|
||||
|
||||
let config;
|
||||
if (name === "package.json") {
|
||||
config = (await importJson(path)).prettier;
|
||||
} else if (name === ".prettierrc") {
|
||||
try {
|
||||
config = JSON.parse(await readFile(path, "utf8"));
|
||||
} catch {
|
||||
throw new Error(
|
||||
"Only JSON format is supported for `.prettierrc`. Convert it to JSON and re-run.",
|
||||
);
|
||||
}
|
||||
} else if (ext === ".json") {
|
||||
config = await importJson(path);
|
||||
} else if (JS_EXTENSIONS.has(ext)) {
|
||||
config = (await import(pathToFileURL(path).href)).default;
|
||||
} else {
|
||||
throw new Error(
|
||||
"YAML, JSON5 and TOML formats are not supported. Convert it to JSON or JS and re-run.",
|
||||
);
|
||||
}
|
||||
|
||||
// Shareable config, e.g. `"prettier": "@company/prettier-config"`
|
||||
if (typeof config === "string") {
|
||||
const mod = createRequire(path)(config);
|
||||
config = mod?.__esModule ? mod.default : mod;
|
||||
}
|
||||
|
||||
if (typeof config !== "object" || config === null || Array.isArray(config)) {
|
||||
throw new Error("Config must be an object.");
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
async function importJson(path: string) {
|
||||
return (await import(pathToFileURL(path).href, { with: { type: "json" } })).default;
|
||||
}
|
||||
|
||||
async function resolvePrettierIgnore(cwd: string) {
|
||||
const ignores = [];
|
||||
|
||||
@@ -203,25 +228,81 @@ async function resolvePrettierIgnore(cwd: string) {
|
||||
return ignores;
|
||||
}
|
||||
|
||||
// Best-effort detection of a top-level `overrides` key in the raw config file.
|
||||
// Uses string matching to cover all config formats (JSON/JSONC/JSON5/YAML/JS/TOML)
|
||||
// Matches:
|
||||
// - JSON/JSONC/JSON5/JS: `"overrides":` / `overrides:`
|
||||
// - YAML: `overrides:`
|
||||
// - TOML: `[[overrides]]` / `overrides =`
|
||||
async function rawConfigHasOverrides(configPath: string): Promise<boolean> {
|
||||
try {
|
||||
const content = await readFile(configPath, "utf8");
|
||||
return /^\s*(?:\[\[\s*overrides\s*\]\]|["']?overrides["']?\s*[:=])/mv.test(content);
|
||||
} catch {
|
||||
return false;
|
||||
// ---
|
||||
|
||||
// Prettier options that Oxfmt supports as-is.
|
||||
const COMPATIBLE_OPTIONS = new Set([
|
||||
"arrowParens",
|
||||
"bracketSameLine",
|
||||
"bracketSpacing",
|
||||
"embeddedLanguageFormatting",
|
||||
"endOfLine",
|
||||
"experimentalOperatorPosition",
|
||||
"htmlWhitespaceSensitivity",
|
||||
"jsxSingleQuote",
|
||||
"objectWrap",
|
||||
"printWidth",
|
||||
"proseWrap",
|
||||
"quoteProps",
|
||||
"semi",
|
||||
"singleAttributePerLine",
|
||||
"singleQuote",
|
||||
"tabWidth",
|
||||
"trailingComma",
|
||||
"useTabs",
|
||||
"vueIndentScriptAndStyle",
|
||||
]);
|
||||
|
||||
// Migrate top-level or `overrides[].options` Prettier options, except plugin-specific ones.
|
||||
function migrateOptions(
|
||||
options: Record<string, unknown>,
|
||||
isTopLevel: boolean,
|
||||
): Record<string, unknown> {
|
||||
const result: Record<string, unknown> = {};
|
||||
const prefix = isTopLevel ? "" : "overrides: ";
|
||||
|
||||
for (const [key, value] of Object.entries(options)) {
|
||||
// Plugin-specific options - handled by `migratePluginOptions()`
|
||||
if (PLUGIN_OPTIONS.has(key)) continue;
|
||||
if (!COMPATIBLE_OPTIONS.has(key)) {
|
||||
warnings.push(`${prefix}"${key}" is not supported, skipping...`);
|
||||
continue;
|
||||
}
|
||||
// Oxfmt does not support this, fallback to default
|
||||
if (key === "endOfLine" && value === "auto") {
|
||||
warnings.push(`${prefix}"endOfLine": "auto" is not supported, skipping...`);
|
||||
continue;
|
||||
}
|
||||
result[key] = value;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Plugin options: only enable when the corresponding Prettier plugin is used.
|
||||
// Empty object means "enabled with defaults"; Tailwind, Svelte and Astro are disabled by default.
|
||||
// In overrides, namespaces are deep-merged with top-level, so only set ones are needed.
|
||||
function migratePluginOptions(
|
||||
options: Record<string, unknown>,
|
||||
enabledPlugins: Set<string>,
|
||||
isTopLevel: boolean,
|
||||
): Record<string, unknown> {
|
||||
const result: Record<string, unknown> = {};
|
||||
for (const [plugin, oxfmtKey, mapping, transform] of NAMESPACED_PLUGINS) {
|
||||
if (!enabledPlugins.has(plugin)) continue;
|
||||
const migrated = migrateMappedOptions(options, mapping, transform);
|
||||
if (!isTopLevel && Object.keys(migrated).length === 0) continue;
|
||||
result[oxfmtKey] = migrated;
|
||||
if (isTopLevel) console.log(` - Migrated "${plugin}" options to "${oxfmtKey}"`);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
// Map Oxfmt's namespaced option keys (left) to Prettier's flat option keys (right).
|
||||
// Used by `migrateMappedOptions` to copy values from Prettier's flat config
|
||||
// Used by `migrateMappedOptions` to copy values from Prettier's flat options
|
||||
// into a single Oxfmt namespace (e.g. `sortTailwindcss`, `svelte`, `astro`).
|
||||
const TAILWIND_OPTION_MAPPING: Record<string, string> = {
|
||||
config: "tailwindConfig",
|
||||
@@ -244,14 +325,29 @@ const ASTRO_OPTION_MAPPING: Record<string, string> = {
|
||||
compressHTML: "astroCompressHTML",
|
||||
};
|
||||
|
||||
const NAMESPACED_PLUGINS = [
|
||||
["prettier-plugin-tailwindcss", "sortTailwindcss", TAILWIND_OPTION_MAPPING, filterTailwindRegex],
|
||||
["prettier-plugin-svelte", "svelte", SVELTE_OPTION_MAPPING, undefined],
|
||||
["prettier-plugin-astro", "astro", ASTRO_OPTION_MAPPING, normalizeAstroCompressHTML],
|
||||
] as const;
|
||||
|
||||
const KNOWN_PLUGINS = new Set<unknown>([
|
||||
"prettier-plugin-packagejson",
|
||||
...NAMESPACED_PLUGINS.map(([plugin]) => plugin),
|
||||
]);
|
||||
|
||||
const PLUGIN_OPTIONS = new Set(
|
||||
NAMESPACED_PLUGINS.flatMap(([, , mapping]) => Object.values(mapping)),
|
||||
);
|
||||
|
||||
function migrateMappedOptions(
|
||||
prettierConfig: Record<string, unknown>,
|
||||
options: Record<string, unknown>,
|
||||
mapping: Record<string, string>,
|
||||
transform?: (prettierKey: string, value: unknown) => unknown,
|
||||
): Record<string, unknown> {
|
||||
const result: Record<string, unknown> = {};
|
||||
for (const [oxfmtKey, prettierKey] of Object.entries(mapping)) {
|
||||
const value = prettierConfig[prettierKey];
|
||||
const value = options[prettierKey];
|
||||
if (value === undefined) continue;
|
||||
result[oxfmtKey] = transform ? transform(prettierKey, value) : value;
|
||||
}
|
||||
@@ -271,7 +367,7 @@ function filterTailwindRegex(prettierKey: string, value: unknown): unknown {
|
||||
if (typeof item !== "string") return false;
|
||||
const isRegex = item.startsWith("/") && item.endsWith("/");
|
||||
if (isRegex) {
|
||||
console.warn(` - Regexp in "${prettierKey}" option is not supported, skipping: ${item}`);
|
||||
warnings.push(`Regexp in "${prettierKey}" option is not supported, skipping: "${item}"`);
|
||||
}
|
||||
return !isRegex;
|
||||
});
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
import { join } from "node:path";
|
||||
import { stat, writeFile } from "node:fs/promises";
|
||||
import { readdir, stat, writeFile } from "node:fs/promises";
|
||||
|
||||
// Keep in sync with `OXFMT_CONFIG_FILE_NAMES` in `crates/oxc_config/src/discovery.rs`
|
||||
const OXFMT_CONFIG_FILES = [
|
||||
".oxfmtrc.json",
|
||||
".oxfmtrc.jsonc",
|
||||
"oxfmt.config.ts",
|
||||
"oxfmt.config.mts",
|
||||
];
|
||||
|
||||
export async function hasOxfmtrcFile(cwd: string) {
|
||||
return (await isFile(join(cwd, ".oxfmtrc.json"))) || (await isFile(join(cwd, ".oxfmtrc.jsonc")));
|
||||
const names = new Set(await readdir(cwd));
|
||||
return OXFMT_CONFIG_FILES.some((name) => names.has(name));
|
||||
}
|
||||
|
||||
const SCHEMA_RELATIVE_PATH = "./node_modules/oxfmt/configuration_schema.json";
|
||||
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/ <CWD>
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,30 +51,27 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
|
||||
## Exit code
|
||||
0
|
||||
1
|
||||
|
||||
## stdout
|
||||
```
|
||||
No Prettier configuration file found.
|
||||
Created `.oxfmtrc.json` instead.
|
||||
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
No Prettier config file found in the current directory.
|
||||
Run `oxfmt --migrate prettier` in the directory where the Prettier config is, or use `--init` to create a blank `.oxfmtrc.json`.
|
||||
```
|
||||
|
||||
## File changes
|
||||
|
||||
### no_config/.oxfmtrc.json (created)
|
||||
```
|
||||
{
|
||||
"ignorePatterns": []
|
||||
}
|
||||
|
||||
```
|
||||
No changes
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/ <CWD>
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -55,7 +69,8 @@ oxfmt --migrate prettier
|
||||
|
||||
## stderr
|
||||
```
|
||||
Oxfmt configuration file already exists.
|
||||
Oxfmt config file already exists.
|
||||
Remove it and re-run.
|
||||
```
|
||||
|
||||
## File changes
|
||||
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -50,13 +64,16 @@ oxfmt --migrate prettier
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc
|
||||
Migrated prettier-plugin-svelte options to svelte
|
||||
Found Prettier config at: <cwd>/.prettierrc
|
||||
- Migrated "prettier-plugin-svelte" options to "svelte"
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
```
|
||||
|
||||
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -50,14 +64,19 @@ oxfmt --migrate prettier
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc
|
||||
Found Prettier config at: <cwd>/.prettierrc
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "requirePragma" is not supported, skipping...
|
||||
- "insertPragma" is not supported, skipping...
|
||||
- "parser" is not supported, skipping...
|
||||
- "filepath" is not supported, skipping...
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
```
|
||||
|
||||
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/ <CWD>
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -50,14 +64,17 @@ oxfmt --migrate prettier
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc.json
|
||||
Found Prettier config at: <cwd>/.prettierrc.json
|
||||
- Migrated "overrides"
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
- "overrides" cannot be migrated automatically. See: https://github.com/oxc-project/oxc/issues/18215
|
||||
```
|
||||
|
||||
## File changes
|
||||
@@ -68,6 +85,16 @@ Created `.oxfmtrc.json`.
|
||||
"semi": false,
|
||||
"printWidth": 80,
|
||||
"sortPackageJson": false,
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.md"
|
||||
],
|
||||
"options": {
|
||||
"tabWidth": 4
|
||||
}
|
||||
}
|
||||
],
|
||||
"ignorePatterns": []
|
||||
}
|
||||
|
||||
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/ <CWD>
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/ <CWD>
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,34 +51,27 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
|
||||
## Exit code
|
||||
0
|
||||
1
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc.json5
|
||||
Created `.oxfmtrc.json`.
|
||||
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
- "overrides" cannot be migrated automatically. See: https://github.com/oxc-project/oxc/issues/18215
|
||||
Failed to load Prettier config at: <cwd>/.prettierrc.json5
|
||||
YAML, JSON5 and TOML formats are not supported. Convert it to JSON or JS and re-run.
|
||||
```
|
||||
|
||||
## File changes
|
||||
|
||||
### overrides_jsonc/.oxfmtrc.json (created)
|
||||
```
|
||||
{
|
||||
"semi": true,
|
||||
"printWidth": 80,
|
||||
"sortPackageJson": false,
|
||||
"ignorePatterns": []
|
||||
}
|
||||
|
||||
```
|
||||
No changes
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/ <CWD>
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,34 +51,27 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/ <CWD>
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
|
||||
## Exit code
|
||||
0
|
||||
1
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc.yaml
|
||||
Created `.oxfmtrc.json`.
|
||||
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
- "overrides" cannot be migrated automatically. See: https://github.com/oxc-project/oxc/issues/18215
|
||||
Failed to load Prettier config at: <cwd>/.prettierrc.yaml
|
||||
YAML, JSON5 and TOML formats are not supported. Convert it to JSON or JS and re-run.
|
||||
```
|
||||
|
||||
## File changes
|
||||
|
||||
### overrides_yaml/.oxfmtrc.json (created)
|
||||
```
|
||||
{
|
||||
"semi": true,
|
||||
"printWidth": 80,
|
||||
"sortPackageJson": false,
|
||||
"ignorePatterns": []
|
||||
}
|
||||
|
||||
```
|
||||
No changes
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/ <CWD>
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -50,13 +64,16 @@ oxfmt --migrate prettier
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc
|
||||
Migrated prettier-plugin-astro options to astro
|
||||
Found Prettier config at: <cwd>/.prettierrc
|
||||
- Migrated "prettier-plugin-astro" options to "astro"
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
```
|
||||
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
# Input
|
||||
|
||||
## Command
|
||||
```
|
||||
oxfmt --migrate prettier
|
||||
```
|
||||
|
||||
## File tree
|
||||
```
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/ <CWD>
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
- .prettierrc
|
||||
- svelte_plugin/
|
||||
- .prettierrc
|
||||
- tailwind_empty/
|
||||
- .prettierrc
|
||||
- tailwind_options/
|
||||
- .prettierrc
|
||||
- tailwind_regex/
|
||||
- .prettierrc
|
||||
- unsupported_opts/
|
||||
- .prettierrc
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
|
||||
## Exit code
|
||||
0
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier config at: <cwd>/prettier.config.mjs
|
||||
- Migrated "prettier-plugin-tailwindcss" options to "sortTailwindcss"
|
||||
- Migrated "overrides"
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
- overrides: "parser" is not supported, skipping...
|
||||
- overrides: "plugins" is not supported, skipping...
|
||||
- `prettier.config.mjs` was evaluated and migrated as static values, any logic in it is not preserved,
|
||||
port it to `oxfmt.config.ts` manually if needed
|
||||
```
|
||||
|
||||
## File changes
|
||||
|
||||
### js_config/.oxfmtrc.json (created)
|
||||
```
|
||||
{
|
||||
"semi": false,
|
||||
"printWidth": 80,
|
||||
"sortPackageJson": false,
|
||||
"sortTailwindcss": {
|
||||
"functions": [
|
||||
"clsx"
|
||||
]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.md"
|
||||
],
|
||||
"excludeFiles": [
|
||||
"CHANGELOG.md"
|
||||
],
|
||||
"options": {
|
||||
"tabWidth": 4,
|
||||
"sortTailwindcss": {
|
||||
"functions": [
|
||||
"tw"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"ignorePatterns": []
|
||||
}
|
||||
|
||||
```
|
||||
@@ -0,0 +1,91 @@
|
||||
# Input
|
||||
|
||||
## Command
|
||||
```
|
||||
oxfmt --migrate prettier
|
||||
```
|
||||
|
||||
## File tree
|
||||
```
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- package_json_shared/ <CWD>
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
- .prettierrc
|
||||
- svelte_plugin/
|
||||
- .prettierrc
|
||||
- tailwind_empty/
|
||||
- .prettierrc
|
||||
- tailwind_options/
|
||||
- .prettierrc
|
||||
- tailwind_regex/
|
||||
- .prettierrc
|
||||
- unsupported_opts/
|
||||
- .prettierrc
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
|
||||
## Exit code
|
||||
0
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier config at: <cwd>/package.json
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "importOrder" is not supported, skipping...
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
```
|
||||
|
||||
## File changes
|
||||
|
||||
### package_json_shared/.oxfmtrc.json (created)
|
||||
```
|
||||
{
|
||||
"singleQuote": true,
|
||||
"printWidth": 80,
|
||||
"sortPackageJson": false,
|
||||
"ignorePatterns": []
|
||||
}
|
||||
|
||||
```
|
||||
@@ -0,0 +1,77 @@
|
||||
# Input
|
||||
|
||||
## Command
|
||||
```
|
||||
oxfmt --migrate prettier
|
||||
```
|
||||
|
||||
## File tree
|
||||
```
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
- .prettierrc
|
||||
- svelte_plugin/
|
||||
- .prettierrc
|
||||
- tailwind_empty/
|
||||
- .prettierrc
|
||||
- tailwind_options/
|
||||
- .prettierrc
|
||||
- tailwind_regex/
|
||||
- .prettierrc
|
||||
- unsupported_opts/
|
||||
- .prettierrc
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/ <CWD>
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
|
||||
## Exit code
|
||||
1
|
||||
|
||||
## stdout
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
Failed to load Prettier config at: <cwd>/.prettierrc
|
||||
Only JSON format is supported for `.prettierrc`. Convert it to JSON and re-run.
|
||||
```
|
||||
|
||||
## File changes
|
||||
No changes
|
||||
@@ -0,0 +1,77 @@
|
||||
# Input
|
||||
|
||||
## Command
|
||||
```
|
||||
oxfmt --migrate prettier
|
||||
```
|
||||
|
||||
## File tree
|
||||
```
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/ <CWD>
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
- .prettierrc
|
||||
- svelte_plugin/
|
||||
- .prettierrc
|
||||
- tailwind_empty/
|
||||
- .prettierrc
|
||||
- tailwind_options/
|
||||
- .prettierrc
|
||||
- tailwind_regex/
|
||||
- .prettierrc
|
||||
- unsupported_opts/
|
||||
- .prettierrc
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
|
||||
## Exit code
|
||||
1
|
||||
|
||||
## stdout
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
No Prettier config file found in the current directory.
|
||||
Run `oxfmt --migrate prettier` in the directory where the Prettier config is, or use `--init` to create a blank `.oxfmtrc.json`.
|
||||
```
|
||||
|
||||
## File changes
|
||||
No changes
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/ <CWD>
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -50,8 +64,9 @@ oxfmt --migrate prettier
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc
|
||||
Found Prettier config at: <cwd>/.prettierrc
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
# Input
|
||||
|
||||
## Command
|
||||
```
|
||||
oxfmt --migrate prettier
|
||||
```
|
||||
|
||||
## File tree
|
||||
```
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/ <CWD>
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
- .prettierrc
|
||||
- svelte_plugin/
|
||||
- .prettierrc
|
||||
- tailwind_empty/
|
||||
- .prettierrc
|
||||
- tailwind_options/
|
||||
- .prettierrc
|
||||
- tailwind_regex/
|
||||
- .prettierrc
|
||||
- unsupported_opts/
|
||||
- .prettierrc
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
|
||||
## Exit code
|
||||
1
|
||||
|
||||
## stdout
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
Oxfmt config file already exists.
|
||||
Remove it and re-run.
|
||||
```
|
||||
|
||||
## File changes
|
||||
No changes
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/ <CWD>
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -50,12 +64,15 @@ oxfmt --migrate prettier
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc
|
||||
Found Prettier config at: <cwd>/.prettierrc
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
```
|
||||
|
||||
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/ <CWD>
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -50,13 +64,16 @@ oxfmt --migrate prettier
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc
|
||||
Migrated ignore patterns from `.prettierignore`
|
||||
Found Prettier config at: <cwd>/.prettierrc
|
||||
- Migrated ignore patterns from `.prettierignore`
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
```
|
||||
|
||||
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -50,13 +64,16 @@ oxfmt --migrate prettier
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc
|
||||
Migrated prettier-plugin-tailwindcss options to sortTailwindcss
|
||||
Found Prettier config at: <cwd>/.prettierrc
|
||||
- Migrated "prettier-plugin-tailwindcss" options to "sortTailwindcss"
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
```
|
||||
|
||||
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -50,13 +64,16 @@ oxfmt --migrate prettier
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc
|
||||
Migrated prettier-plugin-tailwindcss options to sortTailwindcss
|
||||
Found Prettier config at: <cwd>/.prettierrc
|
||||
- Migrated "prettier-plugin-tailwindcss" options to "sortTailwindcss"
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
```
|
||||
|
||||
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -50,16 +64,19 @@ oxfmt --migrate prettier
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc
|
||||
Migrated prettier-plugin-tailwindcss options to sortTailwindcss
|
||||
Found Prettier config at: <cwd>/.prettierrc
|
||||
- Migrated "prettier-plugin-tailwindcss" options to "sortTailwindcss"
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
- Regexp in "tailwindFunctions" option is not supported, skipping: /^tw-/
|
||||
- Regexp in "tailwindAttributes" option is not supported, skipping: /^data-tw-/
|
||||
- Regexp in "tailwindFunctions" option is not supported, skipping: "/^tw-/"
|
||||
- Regexp in "tailwindAttributes" option is not supported, skipping: "/^data-tw-/"
|
||||
```
|
||||
|
||||
## File changes
|
||||
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/ <CWD>
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -50,12 +64,15 @@ oxfmt --migrate prettier
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc
|
||||
Found Prettier config at: <cwd>/.prettierrc
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
```
|
||||
|
||||
|
||||
@@ -10,20 +10,30 @@ oxfmt --migrate prettier
|
||||
- fixtures/
|
||||
- already_exists/
|
||||
- .oxfmtrc.json
|
||||
- already_exists_ts/
|
||||
- .prettierrc
|
||||
- oxfmt.config.ts
|
||||
- astro_plugin/
|
||||
- .prettierrc
|
||||
- basic_config/
|
||||
- .prettierrc
|
||||
- default_printwidth/
|
||||
- .prettierrc
|
||||
- js_config/
|
||||
- prettier.config.mjs
|
||||
- json5_config/
|
||||
- .prettierrc.json5
|
||||
- no_config/
|
||||
- .gitkeep
|
||||
- overrides_json/
|
||||
- .prettierrc.json
|
||||
- overrides_jsonc/
|
||||
- .prettierrc.json5
|
||||
- overrides_yaml/
|
||||
- .prettierrc.yaml
|
||||
- package_json_shared/
|
||||
- package.json
|
||||
- shared.json
|
||||
- parent_config/
|
||||
- .prettierrc
|
||||
- sub/
|
||||
- .gitkeep
|
||||
- sort_pkg_disabled/
|
||||
- .prettierrc
|
||||
- sort_pkg_enabled/ <CWD>
|
||||
@@ -41,6 +51,10 @@ oxfmt --migrate prettier
|
||||
- with_ignore/
|
||||
- .prettierignore
|
||||
- .prettierrc
|
||||
- yaml_config/
|
||||
- .prettierrc.yaml
|
||||
- yaml_prettierrc/
|
||||
- .prettierrc
|
||||
```
|
||||
|
||||
# Result
|
||||
@@ -50,14 +64,17 @@ oxfmt --migrate prettier
|
||||
|
||||
## stdout
|
||||
```
|
||||
Found Prettier configuration at: <cwd>/.prettierrc
|
||||
Found Prettier config at: <cwd>/.prettierrc
|
||||
- Migrated "prettier-plugin-packagejson" to "sortPackageJson"
|
||||
Created `.oxfmtrc.json`.
|
||||
It may not be formatted yet, run `oxfmt` to format it.
|
||||
```
|
||||
|
||||
## stderr
|
||||
```
|
||||
|
||||
Please review:
|
||||
- "printWidth" is not set in Prettier config, defaulting to 80 (Oxfmt default: 100)
|
||||
- Migrated "prettier-plugin-packagejson" to "sortPackageJson"
|
||||
```
|
||||
|
||||
## File changes
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"semi":false}
|
||||
@@ -0,0 +1 @@
|
||||
export default {};
|
||||
@@ -0,0 +1,13 @@
|
||||
export default {
|
||||
semi: process.env.NEVER_SET === "1",
|
||||
plugins: ["prettier-plugin-tailwindcss"],
|
||||
tailwindFunctions: ["clsx"],
|
||||
overrides: [
|
||||
{ files: "*.svg", options: { parser: "html" } },
|
||||
{
|
||||
files: ["*.md"],
|
||||
excludeFiles: "CHANGELOG.md",
|
||||
options: { tabWidth: 4, tailwindFunctions: ["tw"], plugins: ["prettier-plugin-foo"] },
|
||||
},
|
||||
],
|
||||
};
|
||||
File renamed without changes.
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "package-json-shared",
|
||||
"prettier": "./shared.json"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"importOrder": ["^@/"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"semi":false}
|
||||
Whitespace-only changes.
File renamed without changes.
@@ -0,0 +1 @@
|
||||
semi: false
|
||||
@@ -12,7 +12,12 @@
|
||||
{ "cwd": "svelte_plugin", "args": ["--migrate", "prettier"] },
|
||||
{ "cwd": "unsupported_opts", "args": ["--migrate", "prettier"] },
|
||||
{ "cwd": "overrides_json", "args": ["--migrate", "prettier"] },
|
||||
{ "cwd": "overrides_jsonc", "args": ["--migrate", "prettier"] },
|
||||
{ "cwd": "overrides_yaml", "args": ["--migrate", "prettier"] },
|
||||
{ "cwd": "astro_plugin", "args": ["--migrate", "prettier"] }
|
||||
{ "cwd": "json5_config", "args": ["--migrate", "prettier"] },
|
||||
{ "cwd": "yaml_config", "args": ["--migrate", "prettier"] },
|
||||
{ "cwd": "astro_plugin", "args": ["--migrate", "prettier"] },
|
||||
{ "cwd": "js_config", "args": ["--migrate", "prettier"] },
|
||||
{ "cwd": "package_json_shared", "args": ["--migrate", "prettier"] },
|
||||
{ "cwd": "yaml_prettierrc", "args": ["--migrate", "prettier"] },
|
||||
{ "cwd": "parent_config/sub", "args": ["--migrate", "prettier"] },
|
||||
{ "cwd": "already_exists_ts", "args": ["--migrate", "prettier"] }
|
||||
]
|
||||
Reference in new issue
Block a user