Skip to content

Commit de97de7

Browse files
committed
feat: rename jsxElement.spaceBeforeSelfClosingTagSlash to jsx.spaceBeforeSelfClosingTagSlash
1 parent 479f7a8 commit de97de7

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

deployment/schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@
633633
"description": "Ex. `import {SomeExport, OtherExport} from \"my-module\";`"
634634
}]
635635
},
636-
"jsxElement.spaceBeforeSelfClosingTagSlash": {
636+
"jsx.spaceBeforeSelfClosingTagSlash": {
637637
"description": "Whether to add a space before a JSX element's slash when self closing.",
638638
"type": "boolean",
639639
"default": true,
@@ -916,8 +916,8 @@
916916
"importDeclaration.spaceSurroundingNamedImports": {
917917
"$ref": "#/definitions/importDeclaration.spaceSurroundingNamedImports"
918918
},
919-
"jsxElement.spaceBeforeSelfClosingTagSlash": {
920-
"$ref": "#/definitions/jsxElement.spaceBeforeSelfClosingTagSlash"
919+
"jsx.spaceBeforeSelfClosingTagSlash": {
920+
"$ref": "#/definitions/jsx.spaceBeforeSelfClosingTagSlash"
921921
},
922922
"jsxExpressionContainer.spaceSurroundingExpression": {
923923
"$ref": "#/definitions/jsxExpressionContainer.spaceSurroundingExpression"

src/configuration/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ impl ConfigurationBuilder {
357357
///
358358
/// * `true` (default) - Ex. `<Test />`
359359
/// * `false` - Ex. `<Test/>`
360-
pub fn jsx_element_space_before_self_closing_tag_slash(&mut self, value: bool) -> &mut Self {
361-
self.insert("jsxElement.spaceBeforeSelfClosingTagSlash", value.into())
360+
pub fn jsx_space_before_self_closing_tag_slash(&mut self, value: bool) -> &mut Self {
361+
self.insert("jsx.spaceBeforeSelfClosingTagSlash", value.into())
362362
}
363363

364364
/// Whether to add a space surrounding the properties of an object expression.
@@ -1202,7 +1202,7 @@ mod tests {
12021202
.if_statement_space_after_if_keyword(true)
12031203
.import_declaration_space_surrounding_named_imports(true)
12041204
.jsx_expression_container_space_surrounding_expression(true)
1205-
.jsx_element_space_before_self_closing_tag_slash(true)
1205+
.jsx_space_before_self_closing_tag_slash(true)
12061206
.method_space_before_parentheses(true)
12071207
.object_expression_space_surrounding_properties(false)
12081208
.object_pattern_space_surrounding_properties(false)

src/configuration/resolve_config.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ pub fn resolve_config(config: ConfigKeyMap, global_config: &GlobalConfiguration)
3232
fill_deno_config(&mut config);
3333
}
3434

35+
// show diagnostics for renaming this property
36+
handle_renamed_config_property(
37+
&mut config,
38+
"jsxElement.spaceBeforeSelfClosingTagSlash",
39+
"jsx.spaceBeforeSelfClosingTagSlash",
40+
&mut diagnostics,
41+
);
42+
3543
let semi_colons = get_value(&mut config, "semiColons", SemiColons::Prefer, &mut diagnostics);
3644
let brace_position = get_value(&mut config, "bracePosition", BracePosition::SameLineUnlessHanging, &mut diagnostics);
3745
let next_control_flow_position = get_value(&mut config, "nextControlFlowPosition", NextControlFlowPosition::SameLine, &mut diagnostics);
@@ -260,7 +268,7 @@ pub fn resolve_config(config: ConfigKeyMap, global_config: &GlobalConfiguration)
260268
if_statement_space_after_if_keyword: get_value(&mut config, "ifStatement.spaceAfterIfKeyword", true, &mut diagnostics),
261269
import_declaration_space_surrounding_named_imports: get_value(&mut config, "importDeclaration.spaceSurroundingNamedImports", true, &mut diagnostics),
262270
jsx_expression_container_space_surrounding_expression: get_value(&mut config, "jsxExpressionContainer.spaceSurroundingExpression", false, &mut diagnostics),
263-
jsx_element_space_before_self_closing_tag_slash: get_value(&mut config, "jsxElement.spaceBeforeSelfClosingTagSlash", true, &mut diagnostics),
271+
jsx_space_before_self_closing_tag_slash: get_value(&mut config, "jsx.spaceBeforeSelfClosingTagSlash", true, &mut diagnostics),
264272
method_space_before_parentheses: get_value(&mut config, "method.spaceBeforeParentheses", false, &mut diagnostics),
265273
object_expression_space_surrounding_properties: get_value(
266274
&mut config,

src/configuration/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,8 @@ pub struct Configuration {
559559
pub import_declaration_space_surrounding_named_imports: bool,
560560
#[serde(rename = "jsxExpressionContainer.spaceSurroundingExpression")]
561561
pub jsx_expression_container_space_surrounding_expression: bool,
562-
#[serde(rename = "jsxElement.spaceBeforeSelfClosingTagSlash")]
563-
pub jsx_element_space_before_self_closing_tag_slash: bool,
562+
#[serde(rename = "jsx.spaceBeforeSelfClosingTagSlash")]
563+
pub jsx_space_before_self_closing_tag_slash: bool,
564564
#[serde(rename = "method.spaceBeforeParentheses")]
565565
pub method_space_before_parentheses: bool,
566566
#[serde(rename = "objectExpression.spaceSurroundingProperties")]

src/generation/generate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3581,7 +3581,7 @@ fn gen_jsx_namespaced_name<'a>(node: &'a JSXNamespacedName, context: &mut Contex
35813581
}
35823582

35833583
fn gen_jsx_opening_element<'a>(node: &'a JSXOpeningElement, context: &mut Context<'a>) -> PrintItems {
3584-
let space_before_self_closing_tag_slash = context.config.jsx_element_space_before_self_closing_tag_slash;
3584+
let space_before_self_closing_tag_slash = context.config.jsx_space_before_self_closing_tag_slash;
35853585
let force_use_new_lines = get_force_is_multi_line(node, context);
35863586
let prefer_newline_before_close_bracket = get_should_prefer_newline_before_close_bracket(node, context);
35873587
let start_lsil = LineStartIndentLevel::new("openingElementStart");

tests/specs/jsx/JsxElement/JsxElement_SpaceBeforeSelfClosingTagSlash_False.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- file.tsx --
2-
~~ jsxElement.spaceBeforeSelfClosingTagSlash: false, lineWidth: 40 ~~
2+
~~ jsx.spaceBeforeSelfClosingTagSlash: false, lineWidth: 40 ~~
33
== should avoid space before self closing tag when there are no attributes ==
44
const t = <Test />;
55

0 commit comments

Comments
 (0)