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

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Jan 28, 2022
1 parent 271f691 commit 82fd15f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions crates/rome_formatter/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl Formatter {
where
List: AstNodeList<Node>,
{
join_elements_hard_line(list.iter().map(|module_item| {
let formatted_list = list.iter().map(|module_item| {
let snapshot = self.snapshot();
let elem = match self.format_node(module_item.clone()) {
Ok(result) => result,
Expand All @@ -291,7 +291,8 @@ impl Formatter {
};

(module_item, elem)
}))
});
join_elements_hard_line(formatted_list)
}

fn print_leading_trivia(&self, token: &SyntaxToken) -> FormatElement {
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_formatter/src/ts/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
use rslint_parser::ast::{AstNodeList, JsDirective, JsDirectiveList};

pub fn format_directives_list(directives: JsDirectiveList, formatter: &Formatter) -> FormatElement {
if directives.len() > 0 {
if !directives.is_empty() {
format_elements![formatter.format_list(directives), hard_line_break()]
} else {
empty_element()
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_formatter/src/ts/import/assertion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl ToFormatElement for JsImportAssertion {
let assert_token = formatter.format_token(&self.assert_token()?)?;
let assertions = self.assertions();

let space = if assertions.len() == 0 {
let space = if assertions.is_empty() {
empty_element()
} else {
if_group_fits_on_single_line(space_token())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ import {
} from "test";

import {loooooooooooooooooooong3,loooooooooooooooooooong5,loooooooooooooooooooong6 } from "boo"
import { f as x, default as w, "a-b-c" as y } from "b";
import { f as x, default as w, "a-b-c" as y } from "b";

import loooooooooooooooooooong7, { loooooooooooooooooooong8, loooooooooooooooooooong9, loooooooooooooooooooong10} from "module"
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {

import {loooooooooooooooooooong3,loooooooooooooooooooong5,loooooooooooooooooooong6 } from "boo"
import { f as x, default as w, "a-b-c" as y } from "b";

import loooooooooooooooooooong7, { loooooooooooooooooooong8, loooooooooooooooooooong9, loooooooooooooooooooong10} from "module"
---
# Output
import { hey } from "hey";
Expand Down Expand Up @@ -49,3 +51,9 @@ import {
} from "boo";
import { f as x, default as w, "a-b-c" as y } from "b";

import loooooooooooooooooooong7, {
loooooooooooooooooooong8,
loooooooooooooooooooong9,
loooooooooooooooooooong10,
} from "module";

0 comments on commit 82fd15f

Please sign in to comment.