Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust dprint configuration to be closer to prettier #3824

Merged
merged 3 commits into from
Jan 30, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions cli/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
//! the future it can be easily extended to provide
//! the same functions as ops available in JS runtime.

use dprint_plugin_typescript::format_text;
use dprint_plugin_typescript::Configuration;
use dprint_plugin_typescript::ConfigurationBuilder;
use dprint_plugin_typescript as dprint;
use glob;
use regex::Regex;
use std::fs;
Expand All @@ -29,10 +27,11 @@ fn is_supported(path: &Path) -> bool {
&& (TYPESCRIPT.is_match(&path_str) || JAVASCRIPT.is_match(&path_str))
}

fn get_config() -> Configuration {
ConfigurationBuilder::new()
fn get_config() -> dprint::Configuration {
dprint::ConfigurationBuilder::new()
.line_width(80)
.indent_width(2)
.next_control_flow_position(dprint::NextControlFlowPosition::SameLine)
ry marked this conversation as resolved.
Show resolved Hide resolved
.build()
}

Expand All @@ -48,14 +47,14 @@ fn get_supported_files(paths: Vec<PathBuf>) -> Vec<PathBuf> {
files_to_check
}

fn check_source_files(config: Configuration, paths: Vec<PathBuf>) {
fn check_source_files(config: dprint::Configuration, paths: Vec<PathBuf>) {
let start = Instant::now();
let mut not_formatted_files = vec![];

for file_path in paths {
let file_path_str = file_path.to_string_lossy();
let file_contents = fs::read_to_string(&file_path).unwrap();
match format_text(&file_path_str, &file_contents, &config) {
match dprint::format_text(&file_path_str, &file_contents, &config) {
Ok(None) => {
// nothing to format, pass
}
Expand Down Expand Up @@ -91,14 +90,14 @@ fn check_source_files(config: Configuration, paths: Vec<PathBuf>) {
}
}

fn format_source_files(config: Configuration, paths: Vec<PathBuf>) {
fn format_source_files(config: dprint::Configuration, paths: Vec<PathBuf>) {
let start = Instant::now();
let mut not_formatted_files = vec![];

for file_path in paths {
let file_path_str = file_path.to_string_lossy();
let file_contents = fs::read_to_string(&file_path).unwrap();
match format_text(&file_path_str, &file_contents, &config) {
match dprint::format_text(&file_path_str, &file_contents, &config) {
Ok(None) => {
// nothing to format, pass
}
Expand Down