mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 15:49:44 -05:00
fix(fmt): "singleQuote": true
should prefer single quote—not always use one (#21470)
This commit is contained in:
parent
bd7a6bb016
commit
65993e5efa
1 changed files with 20 additions and 1 deletions
|
@ -523,7 +523,7 @@ fn get_resolved_typescript_config(
|
|||
if let Some(single_quote) = options.single_quote {
|
||||
if single_quote {
|
||||
builder.quote_style(
|
||||
dprint_plugin_typescript::configuration::QuoteStyle::AlwaysSingle,
|
||||
dprint_plugin_typescript::configuration::QuoteStyle::PreferSingle,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -792,4 +792,23 @@ mod test {
|
|||
|
||||
assert_eq!(result, Some("11".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_single_quote_true_prefers_single_quote() {
|
||||
let file_text = format_file(
|
||||
&PathBuf::from("test.ts"),
|
||||
"console.log(\"there's\");\nconsole.log('hi');\nconsole.log(\"bye\")\n",
|
||||
&FmtOptionsConfig {
|
||||
single_quote: Some(true),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
file_text,
|
||||
// should use double quotes for the string with a single quote
|
||||
"console.log(\"there's\");\nconsole.log('hi');\nconsole.log('bye');\n",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue