From 713b85b59a3e0bbfa4ee0d53dad255080b61fdb4 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Thu, 5 Sep 2019 11:19:56 -0600 Subject: [PATCH] lint: automated lint --- build.rs | 7 ++++--- src/frontend/rest/services/mod.rs | 2 +- src/frontend/ui/mod.rs | 2 +- src/main.rs | 4 ++-- src/native/mod.rs | 2 +- ui/src/main.js | 17 +++++++++-------- ui/src/views/ErrorView.vue | 12 ++++++------ 7 files changed, 24 insertions(+), 22 deletions(-) diff --git a/build.rs b/build.rs index ce5e1a2..07cdb42 100644 --- a/build.rs +++ b/build.rs @@ -87,8 +87,8 @@ fn main() { // Copy for the main build copy(&target_config, output_dir.join("bootstrap.toml")).expect("Unable to copy config file"); - let yarn_binary = which::which("yarn") - .expect("Failed to find yarn - please go ahead and install it!"); + let yarn_binary = + which::which("yarn").expect("Failed to find yarn - please go ahead and install it!"); // Build and deploy frontend files Command::new(&yarn_binary) @@ -100,7 +100,8 @@ fn main() { .arg(ui_dir.to_str().expect("Unable to covert path")) .spawn() .unwrap() - .wait().expect("Unable to install Node.JS dependencies using Yarn"); + .wait() + .expect("Unable to install Node.JS dependencies using Yarn"); let return_code = Command::new(&yarn_binary) .args(&[ "--cwd", diff --git a/src/frontend/rest/services/mod.rs b/src/frontend/rest/services/mod.rs index df9ea28..a51c817 100644 --- a/src/frontend/rest/services/mod.rs +++ b/src/frontend/rest/services/mod.rs @@ -22,8 +22,8 @@ use futures::sink::Sink; mod attributes; mod config; -mod default_path; mod dark_mode; +mod default_path; mod exit; mod install; mod installation_status; diff --git a/src/frontend/ui/mod.rs b/src/frontend/ui/mod.rs index 149a67b..7750690 100644 --- a/src/frontend/ui/mod.rs +++ b/src/frontend/ui/mod.rs @@ -12,7 +12,7 @@ use log::Level; enum CallbackType { SelectInstallDir { callback_name: String }, Log { msg: String, kind: String }, - Test {} + Test {}, } /// Starts the main web UI. Will return when UI is closed. diff --git a/src/main.rs b/src/main.rs index 454ef24..41132ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,9 +38,9 @@ extern crate chrono; extern crate clap; #[cfg(windows)] -extern crate winapi; -#[cfg(windows)] extern crate widestring; +#[cfg(windows)] +extern crate winapi; #[cfg(not(windows))] extern crate slug; diff --git a/src/native/mod.rs b/src/native/mod.rs index 0a1e9b5..6290bb2 100644 --- a/src/native/mod.rs +++ b/src/native/mod.rs @@ -300,7 +300,7 @@ mod natives { Ok(file) => file, Err(e) => return Err(format!("Unable to create desktop file: {}", e)), }; - let mut desktop_f = desktop_f.write_all(desktop_file.as_bytes()); + let desktop_f = desktop_f.write_all(desktop_file.as_bytes()); match desktop_f { Ok(_) => Ok("".to_string()), Err(e) => Err(format!("Unable to write desktop file: {}", e)), diff --git a/ui/src/main.js b/ui/src/main.js index 076dafa..3ad8a42 100644 --- a/ui/src/main.js +++ b/ui/src/main.js @@ -24,14 +24,14 @@ function intercept (method) { } // See if we have access to the JSON interface -var has_external_interface = false; +var has_external_interface = false try { window.external.invoke(JSON.stringify({ Test: {} })) - has_external_interface = true; + has_external_interface = true } catch (e) { - console.warn("Running without JSON interface - unexpected behaviour may occur!") + console.warn('Running without JSON interface - unexpected behaviour may occur!') } // Overwrite loggers with the logging backend @@ -101,13 +101,14 @@ var app = new Vue({ '/api/exit', function () {}, function (msg) { - var search_location = app.metadata.install_path.length > 0 ? app.metadata.install_path : - "the location where this installer is"; + var search_location = app.metadata.install_path.length > 0 ? app.metadata.install_path + : 'the location where this installer is' - app.$router.replace({ name: 'showerr', params: { msg: msg + + app.$router.replace({ name: 'showerr', + params: { msg: msg + '\n\nPlease upload the log file (in ' + search_location + ') to ' + 'the ' + app.attrs.name + ' team' - }}); + } }) } ) }, @@ -116,4 +117,4 @@ var app = new Vue({ } }).$mount('#app') -console.log("Vue started") +console.log('Vue started') diff --git a/ui/src/views/ErrorView.vue b/ui/src/views/ErrorView.vue index d8313ce..1c6e861 100644 --- a/ui/src/views/ErrorView.vue +++ b/ui/src/views/ErrorView.vue @@ -38,12 +38,12 @@ export default { return { // https://stackoverflow.com/questions/6234773/can-i-escape-html-special-chars-in-javascript msg: this.$route.params.msg - .replace(/&/g, "&") - .replace(//g, ">") - .replace(/"/g, """) - .replace(/'/g, "'") - .replace(/\n/g, "
"), + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\n/g, '
'), remaining: window.history.length > 1 } },