Skip to content

Commit afd6c44

Browse files
committed
feat(oxfmt): Support quoteProps: consistent in Oxfmtrc (#16721)
Follow up #16677, fixes #16247.
1 parent 559eff1 commit afd6c44

6 files changed

Lines changed: 7 additions & 5 deletions

File tree

crates/oxc_formatter/src/service/oxfmtrc.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ pub enum EndOfLineConfig {
106106
pub enum QuotePropsConfig {
107107
#[default]
108108
AsNeeded,
109+
Consistent,
109110
Preserve,
110111
}
111112

@@ -324,10 +325,10 @@ impl Oxfmtrc {
324325
}
325326

326327
// [Prettier] quoteProps: "as-needed" | "consistent" | "preserve"
327-
// NOTE: "consistent" is not supported
328328
if let Some(props) = self.quote_props {
329329
format_options.quote_properties = match props {
330330
QuotePropsConfig::AsNeeded => QuoteProperties::AsNeeded,
331+
QuotePropsConfig::Consistent => QuoteProperties::Consistent,
331332
QuotePropsConfig::Preserve => QuoteProperties::Preserve,
332333
};
333334
}
@@ -482,8 +483,8 @@ impl Oxfmtrc {
482483
"quoteProps".to_string(),
483484
Value::from(match options.quote_properties {
484485
QuoteProperties::AsNeeded => "as-needed",
485-
QuoteProperties::Preserve => "preserve",
486486
QuoteProperties::Consistent => "consistent",
487+
QuoteProperties::Preserve => "preserve",
487488
}),
488489
);
489490

crates/oxc_formatter/tests/snapshots/schema_json.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ expression: json
4040
"QuotePropsConfig": {
4141
"enum": [
4242
"as-needed",
43+
"consistent",
4344
"preserve"
4445
],
4546
"type": "string"

napi/playground/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export interface OxcFormatterOptions {
8181
singleQuote?: boolean
8282
/** Use single quotes in JSX (default: false) */
8383
jsxSingleQuote?: boolean
84-
/** When to add quotes around object properties: "as-needed" | "preserve" (default: "as-needed") */
84+
/** When to add quotes around object properties: "as-needed" | "consistent" | "preserve" (default: "as-needed") */
8585
quoteProps?: string
8686
/** Print trailing commas: "all" | "es5" | "none" (default: "all") */
8787
trailingComma?: string

napi/playground/src/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub struct OxcFormatterOptions {
128128
pub single_quote: Option<bool>,
129129
/// Use single quotes in JSX (default: false)
130130
pub jsx_single_quote: Option<bool>,
131-
/// When to add quotes around object properties: "as-needed" | "preserve" (default: "as-needed")
131+
/// When to add quotes around object properties: "as-needed" | "consistent" | "preserve" (default: "as-needed")
132132
pub quote_props: Option<String>,
133133
/// Print trailing commas: "all" | "es5" | "none" (default: "all")
134134
pub trailing_comma: Option<String>,

npm/oxfmt/configuration_schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"QuotePropsConfig": {
3737
"enum": [
3838
"as-needed",
39+
"consistent",
3940
"preserve"
4041
],
4142
"type": "string"

tasks/coverage/acorn-test262

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)