diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-15 21:42:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-15 21:42:56 +0100 |
commit | c67fe3100e015e8481631c7d4db18bceaed6b1a4 (patch) | |
tree | 9346f2963b83f0dd2e09e1c9852714168bea4ccb | |
parent | fafa29099b2f48d0c39633292a2907f22ced5a8d (diff) | |
parent | bf78bf80e4f45e38e3d052c28987621c907c9528 (diff) | |
download | rspamd-c67fe3100e015e8481631c7d4db18bceaed6b1a4.tar.gz rspamd-c67fe3100e015e8481631c7d4db18bceaed6b1a4.zip |
Merge pull request #2343 from moisseev/eslint
[Minor] Use consistent brace style for blocks (1tbs)
-rw-r--r-- | .eslintrc.json | 8 | ||||
-rw-r--r-- | interface/js/app/graph.js | 3 | ||||
-rw-r--r-- | interface/js/app/history.js | 9 | ||||
-rw-r--r-- | interface/js/app/rspamd.js | 21 | ||||
-rw-r--r-- | interface/js/app/stats.js | 3 | ||||
-rw-r--r-- | interface/js/app/symbols.js | 12 | ||||
-rw-r--r-- | interface/js/app/upload.js | 9 |
7 files changed, 21 insertions, 44 deletions
diff --git a/.eslintrc.json b/.eslintrc.json index 3e52ed7f8..28c31ce80 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,6 +8,7 @@ }, "rules": { "array-bracket-newline": ["error", "consistent"], + "brace-style": ["error", "1tbs", { "allowSingleLine": true }], "camelcase": "off", "capitalized-comments": "off", "comma-dangle": ["error", "only-multiline"], @@ -19,15 +20,16 @@ // "max-len": ["error", { "code": 120 }], "max-params": ["warn", 9], "max-statements": ["warn", 25], + "max-statements-per-line": ["error", { "max": 2 }], "multiline-comment-style": "off", "multiline-ternary": ["error", "always-multiline"], "newline-per-chained-call": ["error", { "ignoreChainWithDepth": 5 }], "no-extra-parens": ["error", "functions"], "no-implicit-globals": "off", "no-magic-numbers": "off", + "no-negated-condition": "off", "no-plusplus": "off", "no-ternary": "off", - // "no-use-before-define": ["error", { "functions": false }], "no-var": "off", "object-curly-newline": ["error", { "consistent": true }], "object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }], @@ -49,7 +51,6 @@ // Temporarily disabled rules "array-callback-return": "off", "array-element-newline": "off", - "brace-style": "off", "callback-return": "off", "consistent-return": "off", "consistent-this": "off", @@ -64,12 +65,9 @@ "max-len": "off", "max-lines": "off", "max-lines-per-function": "off", - "max-statements-per-line": "off", "new-cap": "off", - "no-else-return": "off", "no-inline-comments": "off", "no-invalid-this": "off", - "no-negated-condition": "off", "no-underscore-dangle": "off", "one-var-declaration-per-line": "off", "prefer-spread": "off", diff --git a/interface/js/app/graph.js b/interface/js/app/graph.js index c7e0041ea..bb6431056 100644 --- a/interface/js/app/graph.js +++ b/interface/js/app/graph.js @@ -241,8 +241,7 @@ define(["jquery", "d3evolution", "footable"], }); updateWidgets(data); }); - } - else { + } else { updateWidgets(neighbours_data[0]); } }, diff --git a/interface/js/app/history.js b/interface/js/app/history.js index def170334..bfbc83874 100644 --- a/interface/js/app/history.js +++ b/interface/js/app/history.js @@ -578,8 +578,7 @@ define(["jquery", "footable", "humanize"], return e.rows; })); data.version = neighbours_data[0].version; - } - else { + } else { // Legacy version data = [].concat.apply([], neighbours_data); } @@ -616,8 +615,7 @@ define(["jquery", "footable", "humanize"], delete ft.history; } }); - } - else { + } else { $.ajax({ dataType: "json", url: neighbours[checked_server].url + "history", @@ -688,8 +686,7 @@ define(["jquery", "footable", "humanize"], ui.getHistory(rspamd, tables, neighbours, checked_server); ui.getErrors(rspamd, tables, neighbours, checked_server); }); - } - else { + } else { $.ajax({ dataType: "json", type: "GET", diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 97fd4ebb7..5d2fd682a 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -247,8 +247,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, $("#learning_nav").hide(); $("#resetHistory").attr("disabled", true); $("#errors-history").hide(); - } - else { + } else { ui.read_only = false; $("#learning_nav").show(); $("#resetHistory").removeAttr("disabled", true); @@ -293,8 +292,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, $("#learning_nav").hide(); $("#resetHistory").attr("disabled", true); $("#errors-history").hide(); - } - else { + } else { ui.read_only = false; $("#learning_nav").show(); $("#resetHistory").removeAttr("disabled", true); @@ -332,16 +330,14 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, success: function (data) { if (on_success) { on_success(data); - } - else { + } else { alertMessage("alert-success", "Data saved"); } }, error: function (jqXHR, textStatus, errorThrown) { if (on_error) { on_error("local", jqXHR, textStatus, errorThrown); - } - else { + } else { alertMessage("alert-error", "Cannot receive data: " + errorThrown); } } @@ -412,8 +408,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, if (neighbours_status.every(function (elt) { return elt.checked; })) { if (on_success) { on_success(neighbours_status); - } - else { + } else { alertMessage("alert-success", "Request completed"); } } @@ -424,8 +419,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, if (on_error) { on_error(neighbours_status[ind], jqXHR, textStatus, errorThrown); - } - else { + } else { alertMessage("alert-error", "Cannot receive data from " + neighbours_status[ind].host + ": " + errorThrown); } @@ -433,8 +427,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, function (elt) { return elt.checked; })) { if (on_success) { on_success(neighbours_status); - } - else { + } else { alertMessage("alert-success", "Request completed"); } } diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js index 65e6f2772..c41934200 100644 --- a/interface/js/app/stats.js +++ b/interface/js/app/stats.js @@ -126,8 +126,7 @@ define(["jquery", "d3pie", "humanize"], if (checked_server === key) { $("#clusterTable tbody [value=\"" + key + "\"]").prop("checked", true); $("#selSrv [value=\"" + key + "\"]").prop("selected", true); - } - else if (!val.status) { + } else if (!val.status) { $("#clusterTable tbody [value=\"" + key + "\"]").prop("disabled", true); $("#selSrv [value=\"" + key + "\"]").prop("disabled", true); } diff --git a/interface/js/app/symbols.js b/interface/js/app/symbols.js index 71d577617..75234b09e 100644 --- a/interface/js/app/symbols.js +++ b/interface/js/app/symbols.js @@ -52,8 +52,7 @@ define(["jquery", "footable"], data: JSON.stringify(values), dataType: "json", }); - } - else { + } else { $.ajax({ data: JSON.stringify(values), dataType: "json", @@ -74,11 +73,7 @@ define(["jquery", "footable"], } function decimalStep(number) { var digits = ((Number(number)).toFixed(20)).replace(/^-?\d*\.?|0+$/g, "").length; - if (digits === 0 || digits > 4) { - return 0.1; - } else { - return 1.0 / (Math.pow(10, digits)); - } + return (digits === 0 || digits > 4) ? 0.1 : 1.0 / (Math.pow(10, digits)); } function process_symbols_data(data) { var items = []; @@ -148,8 +143,7 @@ define(["jquery", "footable"], if (exp > 0) { item.frequency = item.frequency.toFixed(2) + "e-" + exp; - } - else { + } else { item.frequency = item.frequency.toFixed(2); } }); diff --git a/interface/js/app/upload.js b/interface/js/app/upload.js index 3fcfc3aad..064cadc56 100644 --- a/interface/js/app/upload.js +++ b/interface/js/app/upload.js @@ -96,19 +96,16 @@ define(["jquery"], if (json.action === "clean" || "no action") { action = "label-success"; - } - else if (json.action === "rewrite subject" || "add header" || "probable spam") { + } else if (json.action === "rewrite subject" || "add header" || "probable spam") { action = "label-warning"; - } - else if (json.action === "spam") { + } else if (json.action === "spam") { action = "label-danger"; } var score = ""; if (json.score <= json.required_score) { score = "label-success"; - } - else if (json.score >= json.required_score) { + } else if (json.score >= json.required_score) { score = "label-danger"; } $("<tbody id=\"tmpBody\"><tr>" + |