Skip to content

Commit bd75087

Browse files
committed
refaactor: #11 - typeLiteral.separatorKind should be singular
1 parent 0b5e67f commit bd75087

10 files changed

+24
-24
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "dprint-plugin-typescript"
33
description = "TypeScript code formatting plugin for dprint."
44
keywords = ["formatting", "formatter", "typescript"]
5-
version = "0.28.1"
5+
version = "0.29.0"
66
authors = ["David Sherret <[email protected]>"]
77
edition = "2018"
88
license = "MIT"

src/configuration/builder.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,17 +387,17 @@ impl ConfigurationBuilder {
387387
}
388388

389389
/// The kind of separator to use in type literals.
390-
pub fn type_literal_separator_kind(&mut self, value: SemiColonsOrCommas) -> &mut Self {
390+
pub fn type_literal_separator_kind(&mut self, value: SemiColonOrComma) -> &mut Self {
391391
self.insert("typeLiteral.separatorKind", value.to_string().into())
392392
}
393393

394394
/// The kind of separator to use in type literals when single line.
395-
pub fn type_literal_separator_kind_single_line(&mut self, value: SemiColonsOrCommas) -> &mut Self {
395+
pub fn type_literal_separator_kind_single_line(&mut self, value: SemiColonOrComma) -> &mut Self {
396396
self.insert("typeLiteral.separatorKind.singleLine", value.to_string().into())
397397
}
398398

399399
/// The kind of separator to use in type literals when multi-line.
400-
pub fn type_literal_separator_kind_multi_line(&mut self, value: SemiColonsOrCommas) -> &mut Self {
400+
pub fn type_literal_separator_kind_multi_line(&mut self, value: SemiColonOrComma) -> &mut Self {
401401
self.insert("typeLiteral.separatorKind.multiLine", value.to_string().into())
402402
}
403403

@@ -856,9 +856,9 @@ mod tests {
856856
.arrow_function_use_parentheses(UseParentheses::Maintain)
857857
.binary_expression_line_per_expression(false)
858858
.member_expression_line_per_expression(false)
859-
.type_literal_separator_kind(SemiColonsOrCommas::Commas)
860-
.type_literal_separator_kind_single_line(SemiColonsOrCommas::Commas)
861-
.type_literal_separator_kind_multi_line(SemiColonsOrCommas::Commas)
859+
.type_literal_separator_kind(SemiColonOrComma::Comma)
860+
.type_literal_separator_kind_single_line(SemiColonOrComma::Comma)
861+
.type_literal_separator_kind_multi_line(SemiColonOrComma::Comma)
862862
/* ignore comments */
863863
.ignore_node_comment_text("ignore")
864864
.ignore_file_comment_text("ignore-file")

src/configuration/resolve_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn resolve_config(config: ConfigKeyMap, global_config: &GlobalConfiguration)
4141
let use_braces = get_value(&mut config, "useBraces", UseBraces::WhenNotSingleLine, &mut diagnostics);
4242
let prefer_hanging = get_value(&mut config, "preferHanging", false, &mut diagnostics);
4343
let prefer_single_line = get_value(&mut config, "preferSingleLine", false, &mut diagnostics);
44-
let type_literal_separator_kind = get_value(&mut config, "typeLiteral.separatorKind", SemiColonsOrCommas::SemiColons, &mut diagnostics);
44+
let type_literal_separator_kind = get_value(&mut config, "typeLiteral.separatorKind", SemiColonOrComma::SemiColon, &mut diagnostics);
4545

4646
let resolved_config = Configuration {
4747
line_width: get_value(&mut config, "lineWidth", global_config.line_width.unwrap_or(DEFAULT_GLOBAL_CONFIGURATION.line_width), &mut diagnostics),

src/configuration/types.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,17 @@ generate_str_to_from![
220220
/// Whether to use semi-colons or commas.
221221
#[derive(Clone, PartialEq, Copy, Serialize, Deserialize)]
222222
#[serde(rename_all = "camelCase")]
223-
pub enum SemiColonsOrCommas {
223+
pub enum SemiColonOrComma {
224224
/// Use semi colons (default).
225-
SemiColons,
225+
SemiColon,
226226
/// Use commas.
227-
Commas,
227+
Comma,
228228
}
229229

230230
generate_str_to_from![
231-
SemiColonsOrCommas,
232-
[SemiColons, "semiColons"],
233-
[Commas, "commas"]
231+
SemiColonOrComma,
232+
[SemiColon, "semiColon"],
233+
[Comma, "comma"]
234234
];
235235

236236
#[derive(Clone, Serialize, Deserialize)]
@@ -250,9 +250,9 @@ pub struct Configuration {
250250
#[serde(rename = "memberExpression.linePerExpression")]
251251
pub member_expression_line_per_expression: bool,
252252
#[serde(rename = "typeLiteral.separatorKind.singleLine")]
253-
pub type_literal_separator_kind_single_line: SemiColonsOrCommas,
253+
pub type_literal_separator_kind_single_line: SemiColonOrComma,
254254
#[serde(rename = "typeLiteral.separatorKind.multiLine")]
255-
pub type_literal_separator_kind_multi_line: SemiColonsOrCommas,
255+
pub type_literal_separator_kind_multi_line: SemiColonOrComma,
256256
/* ignore comments */
257257
pub ignore_node_comment_text: String,
258258
pub ignore_file_comment_text: String,

src/parsing/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,10 +2430,10 @@ fn parse_type_lit<'a>(node: &'a TsTypeLit, context: &mut Context<'a>) -> PrintIt
24302430
surround_single_line_with_spaces: true,
24312431
}, context);
24322432

2433-
fn semi_colon_or_comma_to_separator_value(value: SemiColonsOrCommas, context: &mut Context) -> SeparatorValue {
2433+
fn semi_colon_or_comma_to_separator_value(value: SemiColonOrComma, context: &mut Context) -> SeparatorValue {
24342434
match value {
2435-
SemiColonsOrCommas::Commas => SeparatorValue::Comma(context.config.type_literal_trailing_commas),
2436-
SemiColonsOrCommas::SemiColons => SeparatorValue::SemiColon(context.config.semi_colons),
2435+
SemiColonOrComma::Comma => SeparatorValue::Comma(context.config.type_literal_trailing_commas),
2436+
SemiColonOrComma::SemiColon => SeparatorValue::SemiColon(context.config.semi_colons),
24372437
}
24382438
}
24392439
}

tests/specs/issues/issue0011.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
~~ semiColons: asi, typeLiteral.separatorKind.singleLine: commas ~~
1+
~~ semiColons: asi, typeLiteral.separatorKind.singleLine: comma ~~
22
== should use commas when single line ==
33
type Test = { p: string, u: number };
44

tests/specs/types/TypeLiteral/TypeLiteral_SeparatorKind_Commas.txt renamed to tests/specs/types/TypeLiteral/TypeLiteral_SeparatorKind_Comma.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
~~ typeLiteral.separatorKind: commas ~~
1+
~~ typeLiteral.separatorKind: comma ~~
22
== should use commas when single line ==
33
type Test = { p: string, u: number };
44

tests/specs/types/TypeLiteral/TypeLiteral_SeparatorKind_CommasSingle_SemiColonsMulti.txt renamed to tests/specs/types/TypeLiteral/TypeLiteral_SeparatorKind_CommaSingle_SemiColonMulti.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
~~ typeLiteral.separatorKind.singleLine: commas, typeLiteral.separatorKind.multiLine: semiColons, lineWidth: 40 ~~
1+
~~ typeLiteral.separatorKind.singleLine: comma, typeLiteral.separatorKind.multiLine: semiColon, lineWidth: 40 ~~
22
== should use commas when single line ==
33
type Test = { p: string, u: number };
44

tests/specs/types/TypeLiteral/TypeLiteral_SeparatorKind_SemiColonsSingle_CommasMulti.txt renamed to tests/specs/types/TypeLiteral/TypeLiteral_SeparatorKind_SemiColonSingle_CommaMulti.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
~~ typeLiteral.separatorKind.singleLine: semiColons, typeLiteral.separatorKind.multiLine: commas, lineWidth: 40 ~~
1+
~~ typeLiteral.separatorKind.singleLine: semiColon, typeLiteral.separatorKind.multiLine: comma, lineWidth: 40 ~~
22
== should use commas when single line ==
33
type Test = { p: string, u: number };
44

0 commit comments

Comments
 (0)