Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
Revert a bunch of changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer committed Apr 22, 2022
1 parent af9fae6 commit 861a683
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 157 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use crate::{
utils::has_leading_newline, Format, FormatElement, FormatNode, FormatResult, Formatter,
};
use crate::{Format, FormatElement, FormatNode, FormatResult, Formatter};

use rome_js_syntax::JsObjectAssignmentPattern;
use rome_js_syntax::JsObjectAssignmentPatternFields;
use rome_rowan::AstNode;

impl FormatNode for JsObjectAssignmentPattern {
fn format_fields(&self, formatter: &Formatter) -> FormatResult<FormatElement> {
Expand All @@ -14,18 +11,10 @@ impl FormatNode for JsObjectAssignmentPattern {
r_curly_token,
} = self.as_fields();

if has_leading_newline(properties.syntax()) {
formatter.format_delimited_block_indent(
&l_curly_token?,
properties.format(formatter)?,
&r_curly_token?,
)
} else {
formatter.format_delimited_soft_block_spaces(
&l_curly_token?,
properties.format(formatter)?,
&r_curly_token?,
)
}
formatter.format_delimited_soft_block_spaces(
&l_curly_token?,
properties.format(formatter)?,
&r_curly_token?,
)
}
}
23 changes: 6 additions & 17 deletions crates/rome_js_formatter/src/js/bindings/object_binding_pattern.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use crate::{
utils::has_leading_newline, Format, FormatElement, FormatNode, FormatResult, Formatter,
};
use crate::{Format, FormatElement, FormatNode, FormatResult, Formatter};

use rome_js_syntax::JsObjectBindingPattern;
use rome_js_syntax::JsObjectBindingPatternFields;
use rome_rowan::AstNode;

impl FormatNode for JsObjectBindingPattern {
fn format_fields(&self, formatter: &Formatter) -> FormatResult<FormatElement> {
Expand All @@ -14,18 +11,10 @@ impl FormatNode for JsObjectBindingPattern {
r_curly_token,
} = self.as_fields();

if has_leading_newline(properties.syntax()) {
formatter.format_delimited_block_indent(
&l_curly_token?,
properties.format(formatter)?,
&r_curly_token?,
)
} else {
formatter.format_delimited_soft_block_spaces(
&l_curly_token?,
properties.format(formatter)?,
&r_curly_token?,
)
}
formatter.format_delimited_soft_block_spaces(
&l_curly_token?,
properties.format(formatter)?,
&r_curly_token?,
)
}
}
19 changes: 6 additions & 13 deletions crates/rome_js_formatter/src/js/module/export_named_clause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ use crate::format_traits::FormatOptional;

use crate::utils::format_with_semicolon;
use crate::{
format_elements, space_token, utils::has_leading_newline, Format, FormatElement, FormatNode,
FormatResult, Formatter,
format_elements, space_token, Format, FormatElement, FormatNode, FormatResult, Formatter,
};

use rome_js_syntax::JsExportNamedClause;
use rome_js_syntax::JsExportNamedClauseFields;
use rome_rowan::AstNode;

impl FormatNode for JsExportNamedClause {
fn format_fields(&self, formatter: &Formatter) -> FormatResult<FormatElement> {
Expand All @@ -23,18 +21,13 @@ impl FormatNode for JsExportNamedClause {
let type_token = type_token
.format_with_or_empty(formatter, |token| format_elements![token, space_token()])?;

let has_newline = has_leading_newline(specifiers.syntax());
let specifiers = specifiers.format(formatter)?;

let list = if has_newline {
formatter.format_delimited_block_indent(&l_curly_token?, specifiers, &r_curly_token?)?
} else {
formatter.format_delimited_soft_block_spaces(
&l_curly_token?,
specifiers,
&r_curly_token?,
)?
};
let list = formatter.format_delimited_soft_block_spaces(
&l_curly_token?,
specifiers,
&r_curly_token?,
)?;

format_with_semicolon(
formatter,
Expand Down
19 changes: 6 additions & 13 deletions crates/rome_js_formatter/src/js/module/import_assertion.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use crate::{
format_elements, space_token, utils::has_leading_newline, Format, FormatElement, FormatNode,
FormatResult, Formatter,
format_elements, space_token, Format, FormatElement, FormatNode, FormatResult, Formatter,
};

use rome_js_syntax::JsImportAssertion;
use rome_js_syntax::JsImportAssertionFields;
use rome_rowan::AstNode;

impl FormatNode for JsImportAssertion {
fn format_fields(&self, formatter: &Formatter) -> FormatResult<FormatElement> {
Expand All @@ -16,19 +14,14 @@ impl FormatNode for JsImportAssertion {
r_curly_token,
} = self.as_fields();

let has_newline = has_leading_newline(assertions.syntax());
let assert_token = assert_token.format(formatter)?;
let assertions = assertions.format(formatter)?;

let result = if has_newline {
formatter.format_delimited_block_indent(&l_curly_token?, assertions, &r_curly_token?)?
} else {
formatter.format_delimited_soft_block_spaces(
&l_curly_token?,
assertions,
&r_curly_token?,
)?
};
let result = formatter.format_delimited_soft_block_spaces(
&l_curly_token?,
assertions,
&r_curly_token?,
)?;

Ok(format_elements![assert_token, space_token(), result])
}
Expand Down
16 changes: 2 additions & 14 deletions crates/rome_js_formatter/src/js/module/named_import_specifiers.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use crate::{
utils::has_leading_newline, Format, FormatElement, FormatNode, FormatResult, Formatter,
};
use crate::{Format, FormatElement, FormatNode, FormatResult, Formatter};

use rome_js_syntax::JsNamedImportSpecifiers;
use rome_js_syntax::JsNamedImportSpecifiersFields;
use rome_rowan::AstNode;

impl FormatNode for JsNamedImportSpecifiers {
fn format_fields(&self, formatter: &Formatter) -> FormatResult<FormatElement> {
Expand All @@ -14,17 +11,8 @@ impl FormatNode for JsNamedImportSpecifiers {
r_curly_token,
} = self.as_fields();

let has_newline = has_leading_newline(specifiers.syntax());
let specifiers = specifiers.format(formatter)?;

if has_newline {
formatter.format_delimited_block_indent(&l_curly_token?, specifiers, &r_curly_token?)
} else {
formatter.format_delimited_soft_block_spaces(
&l_curly_token?,
specifiers,
&r_curly_token?,
)
}
formatter.format_delimited_soft_block_spaces(&l_curly_token?, specifiers, &r_curly_token?)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,27 @@ expression: destructuring-heuristic.js
```js
{
{
const {
id,
static: isStatic,
method: isMethod,
methodId,
getId,
setId,
} = privateNamesMap.get(name);
const { id, static: isStatic, method: isMethod, methodId, getId, setId } = privateNamesMap.get(
name,
);
const {
id1,
method: isMethod1,
methodId1,
} = privateNamesMap.get(name);
const { id1, method: isMethod1, methodId1 } = privateNamesMap.get(name);
const {
id2,
method: isMethod2,
methodId2,
} = privateNamesMap.get(bifornCringerMoshedPerplexSawder);
const { id2, method: isMethod2, methodId2 } = privateNamesMap.get(
bifornCringerMoshedPerplexSawder,
);
const {
id3,
method: isMethod3,
methodId3,
} = anodyneCondosMalateOverateRetinol.get(bifornCringerMoshedPerplexSawder);
const { id3, method: isMethod3, methodId3 } = anodyneCondosMalateOverateRetinol.get(
bifornCringerMoshedPerplexSawder,
);
}
}
```

# Lines exceeding max width of 80 characters
```
3: const { id, static: isStatic, method: isMethod, methodId, getId, setId } = privateNamesMap.get(
13: const { id3, method: isMethod3, methodId3 } = anodyneCondosMalateOverateRetinol.get(
```

Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ const {

# Output
```js
const {
imStore,
showChat,
customerServiceAccount,
} = store[config.reduxStoreName];
const { imStore, showChat, customerServiceAccount } = store[config.reduxStoreName];
```

# Lines exceeding max width of 80 characters
```
1: const { imStore, showChat, customerServiceAccount } = store[config.reduxStoreName];
```

Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,7 @@ const AspectRatioBox = styled.div`
`;
*/

const AspectRatioBox = (
{
aspectRatio,
children,
...props
},
) => (
const AspectRatioBox = ({ aspectRatio, children, ...props }) => (
<div
className={`height: 0;
overflow: hidden;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ const Component2 = ({
```js
const Component1 = ({ props }) => (<Text>Test</Text>);
const Component2 = (
{
props,
},
) => (<Text>Test</Text>);
const Component2 = ({ props }) => (<Text>Test</Text>);
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,38 +173,12 @@ call((one, two, three, four, five, six, seven, eight, nine, ten, eleven) => {});
call((one, two, three, four, five, six, seven, eight, nine, ten, eleven) => {});
function test(
{
one,
two,
three,
four,
five,
six,
seven,
eight,
nine,
ten,
eleven,
},
{ one, two, three, four, five, six, seven, eight, nine, ten, eleven },
) {}
function test(
{
one,
two,
three,
four,
},
) {}
function test({ one, two, three, four }) {}
function test(
{
one,
two,
three,
four,
},
) {}
function test({ one, two, three, four }) {}
function test({ one, two, three, four }, $a) {}
Expand Down Expand Up @@ -234,6 +208,6 @@ it(
```
2: constructor(one, two, three, four, five, six, seven, eight, nine, ten, eleven) {}
5: function foo(one, two, three, four, five, six, seven, eight, nine, ten, eleven) {}
63: "does something really long and complicated so I have to write a very long name for the test",
37: "does something really long and complicated so I have to write a very long name for the test",
```

Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ export type WrappedFormUtils = {
# Output
```js
function x(
{
x,
y,
}: {
{ x, y }: {
// Hello world.
x: string;
// Yoyo.
Expand Down Expand Up @@ -91,7 +88,7 @@ export type WrappedFormUtils = {

# Lines exceeding max width of 80 characters
```
32: /** 可以把 onChange 的参数转化为控件的值,例如 DatePicker 可设为:(date, dateString) => dateString */
36: /** 校验规则,参见 [async-validator](https://github.com/yiminghe/async-validator) */
29: /** 可以把 onChange 的参数转化为控件的值,例如 DatePicker 可设为:(date, dateString) => dateString */
33: /** 校验规则,参见 [async-validator](https://github.com/yiminghe/async-validator) */
```

Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ class X {
# Output
```js
function onDidInsertSuggestion(
{
editor,
triggerPosition,
re,
},
): Promise<void> {}
function onDidInsertSuggestion({ editor, triggerPosition, re }): Promise<void> {}
class X {
async onDidInsertSuggestion({ editor, triggerPosition, suggestion }): Promise<
Expand All @@ -38,4 +32,8 @@ class X {
```
# Lines exceeding max width of 80 characters
```
1: function onDidInsertSuggestion({ editor, triggerPosition, re }): Promise<void> {}
```

0 comments on commit 861a683

Please sign in to comment.