`.trimStart(),
);
diff --git a/apps/oxfmt/test/embedded_languages.test.ts b/apps/oxfmt/test/embedded_languages.test.ts
index bf41ec3dd0b91..e0a7f1cc2a70a 100644
--- a/apps/oxfmt/test/embedded_languages.test.ts
+++ b/apps/oxfmt/test/embedded_languages.test.ts
@@ -5,7 +5,12 @@ import { runWriteModeAndSnapshot } from "./utils";
const fixturesDir = join(__dirname, "fixtures", "embedded_languages");
describe("embedded_languages", () => {
- it("should format embedded languages (CSS, GraphQL, HTML, Markdown)", async () => {
+ it("should format embedded languages by default", async () => {
+ const snapshot = await runWriteModeAndSnapshot(fixturesDir, ["embedded_languages.js"]);
+ expect(snapshot).toMatchSnapshot();
+ });
+
+ it("should format embedded languages when embeddedLanguageFormatting is auto", async () => {
const snapshot = await runWriteModeAndSnapshot(
fixturesDir,
["embedded_languages.js"],
@@ -22,9 +27,4 @@ describe("embedded_languages", () => {
);
expect(snapshot).toMatchSnapshot();
});
-
- it("should not format embedded languages by default (at alpha release)", async () => {
- const snapshot = await runWriteModeAndSnapshot(fixturesDir, ["embedded_languages.js"]);
- expect(snapshot).toMatchSnapshot();
- });
});
diff --git a/crates/oxc_formatter/src/options.rs b/crates/oxc_formatter/src/options.rs
index e3fbd19f43f02..a8358bc00e90e 100644
--- a/crates/oxc_formatter/src/options.rs
+++ b/crates/oxc_formatter/src/options.rs
@@ -947,10 +947,9 @@ impl fmt::Display for OperatorPosition {
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub enum EmbeddedLanguageFormatting {
/// Enable formatting for embedded languages.
+ #[default]
Auto,
- // Disable by default at alpha release, synced with `oxfmtrc.rs`
/// Disable formatting for embedded languages.
- #[default]
Off,
}
diff --git a/crates/oxc_formatter/src/oxfmtrc.rs b/crates/oxc_formatter/src/oxfmtrc.rs
index 0c7282383fb10..2bc23e4aa7b31 100644
--- a/crates/oxc_formatter/src/oxfmtrc.rs
+++ b/crates/oxc_formatter/src/oxfmtrc.rs
@@ -80,7 +80,8 @@ pub struct Oxfmtrc {
#[schemars(skip)]
pub experimental_ternaries: Option,
- /// Control whether to format embedded parts in the file. (Default: `"off"`)
+ /// Control whether to format embedded parts in the file.
+ /// e.g. JS-in-Vue, CSS-in-JS, etc. (Default: `"auto"`)
#[serde(skip_serializing_if = "Option::is_none")]
pub embedded_language_formatting: Option,
diff --git a/crates/oxc_formatter/tests/snapshots/schema_json.snap b/crates/oxc_formatter/tests/snapshots/schema_json.snap
index 5d5e573eefa09..cbf34d162bd63 100644
--- a/crates/oxc_formatter/tests/snapshots/schema_json.snap
+++ b/crates/oxc_formatter/tests/snapshots/schema_json.snap
@@ -183,8 +183,8 @@ expression: json
"type": "null"
}
],
- "description": "Control whether to format embedded parts in the file. (Default: `\"off\"`)",
- "markdownDescription": "Control whether to format embedded parts in the file. (Default: `\"off\"`)"
+ "description": "Control whether to format embedded parts in the file.\ne.g. JS-in-Vue, CSS-in-JS, etc. (Default: `\"auto\"`)",
+ "markdownDescription": "Control whether to format embedded parts in the file.\ne.g. JS-in-Vue, CSS-in-JS, etc. (Default: `\"auto\"`)"
},
"endOfLine": {
"anyOf": [
diff --git a/npm/oxfmt/configuration_schema.json b/npm/oxfmt/configuration_schema.json
index 7e3d699ca1120..c6f1563ba751f 100644
--- a/npm/oxfmt/configuration_schema.json
+++ b/npm/oxfmt/configuration_schema.json
@@ -179,8 +179,8 @@
"type": "null"
}
],
- "description": "Control whether to format embedded parts in the file. (Default: `\"off\"`)",
- "markdownDescription": "Control whether to format embedded parts in the file. (Default: `\"off\"`)"
+ "description": "Control whether to format embedded parts in the file.\ne.g. JS-in-Vue, CSS-in-JS, etc. (Default: `\"auto\"`)",
+ "markdownDescription": "Control whether to format embedded parts in the file.\ne.g. JS-in-Vue, CSS-in-JS, etc. (Default: `\"auto\"`)"
},
"endOfLine": {
"anyOf": [
diff --git a/tasks/website_formatter/src/snapshots/schema_markdown.snap b/tasks/website_formatter/src/snapshots/schema_markdown.snap
index 7eb80f43334a8..56bec50bb7fa2 100644
--- a/tasks/website_formatter/src/snapshots/schema_markdown.snap
+++ b/tasks/website_formatter/src/snapshots/schema_markdown.snap
@@ -44,7 +44,8 @@ Print spaces between brackets in object literals. (Default: `true`)
type: `string | null`
-Control whether to format embedded parts in the file. (Default: `"off"`)
+Control whether to format embedded parts in the file.
+e.g. JS-in-Vue, CSS-in-JS, etc. (Default: `"auto"`)
## endOfLine