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

Commit

Permalink
chore: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Jan 25, 2022
1 parent ebf352c commit 577cf56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
26 changes: 4 additions & 22 deletions crates/rome_formatter/src/ts/directives.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
use crate::{
empty_element, format_elements, hard_line_break, join_elements_hard_line, token, FormatElement,
FormatResult, Formatter, ToFormatElement,
empty_element, format_elements, hard_line_break, token, FormatElement, FormatResult, Formatter,
ToFormatElement,
};
use rslint_parser::ast::{AstNode, AstNodeList, JsDirective, JsDirectiveList};

fn format_directives(directives: JsDirectiveList, formatter: &Formatter) -> FormatElement {
join_elements_hard_line(directives.iter().map(|directive| {
let snapshot = formatter.snapshot();
let elem = match formatter.format_node(directive.clone()) {
Ok(result) => result,
Err(_) => {
formatter.restore(snapshot);
formatter
.format_verbatim(directive.syntax())
.trim_start()
.trim_end()
}
};

(directive, elem)
}))
}
use rslint_parser::ast::{AstNodeList, JsDirective, JsDirectiveList};

pub fn format_directives_list(directives: JsDirectiveList, formatter: &Formatter) -> FormatElement {
if directives.len() > 0 {
format_elements![format_directives(directives, formatter), hard_line_break()]
format_elements![formatter.format_list(directives), hard_line_break()]
} else {
empty_element()
}
Expand Down
1 change: 0 additions & 1 deletion crates/rslint_parser/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import a, * as b from "foo"

let module = parse_module(src, 0);

dbg!(&module.syntax());
assert_errors_are_absent(
module.errors(),
Path::new("parser_smoke_test"),
Expand Down

0 comments on commit 577cf56

Please sign in to comment.