]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Use destructuring 4712/head
authormoisseev <moiseev@mezonplus.ru>
Mon, 20 Nov 2023 12:58:06 +0000 (15:58 +0300)
committermoisseev <moiseev@mezonplus.ru>
Mon, 20 Nov 2023 12:58:06 +0000 (15:58 +0300)
.eslintrc.json
interface/js/app/config.js
interface/js/app/graph.js
interface/js/app/history.js
interface/js/app/rspamd.js
interface/js/app/stats.js
interface/js/app/symbols.js
interface/js/app/upload.js

index 5e72d5e43047e62edb19d63b264a8f3ed1597be4..5ae3238eae9aa87322e571602cef5e69cd6bf8b0 100644 (file)
@@ -34,7 +34,6 @@
         "object-shorthand": "off",
         "one-var": ["error", { "initialized": "never" }],
         "prefer-arrow-callback": "off",
-        "prefer-destructuring": "off",
         "prefer-named-capture-group": "off",
         "prefer-object-has-own": "off",
         "prefer-spread": "off",
index e0adb365b132d9ae5490ee180de513bfa80c0fa7..9f62c97dbc9812420c800bf23aea9a2aaca1427e 100644 (file)
@@ -120,7 +120,7 @@ define(["jquery", "app/rspamd"],
             $listmaps.closest(".card").hide();
             rspamd.query("maps", {
                 success: function (json) {
-                    const data = json[0].data;
+                    const [{data}] = json;
                     $listmaps.empty();
                     $("#modalBody").empty();
                     const $tbody = $("<tbody>");
index ea330aef699b0617044718380accd1594cde8062..a661d4a19df0f76e7fadf4e7dedebf3d227102fd 100644 (file)
@@ -209,7 +209,7 @@ define(["jquery", "app/rspamd", "d3evolution", "d3pie", "d3", "footable"],
                         .map(function (d) { return d.data; });
 
                     if (neighbours_data.length === 1) {
-                        data = neighbours_data[0];
+                        [data] = neighbours_data;
                     } else {
                         let time_match = true;
                         neighbours_data.reduce(function (res, curr, _, arr) {
index 3d06f667c9e880f5304b7240a856878add9ffd7e..568c697634966b03b4ff53e9730a98ec718b78e1 100644 (file)
@@ -340,7 +340,7 @@ define(["jquery", "app/rspamd", "d3", "footable"],
                         .map(function (d) { return d.data; });
                     if (neighbours_data.length && !differentVersions(neighbours_data)) {
                         let data = {};
-                        const version = neighbours_data[0].version;
+                        const [{version}] = neighbours_data;
                         if (version) {
                             data.rows = [].concat.apply([], neighbours_data
                                 .map(function (e) {
@@ -354,7 +354,7 @@ define(["jquery", "app/rspamd", "d3", "footable"],
                             $("#legacy-history-badge").show();
                         }
                         const o = process_history_data(data);
-                        const items = o.items;
+                        const {items} = o;
                         rspamd.symbols.history = o.symbols;
 
                         if (Object.prototype.hasOwnProperty.call(rspamd.tables, "history") &&
index 26bd6c40db5456705ef43e2ec18b59ad61eed01f..64eab27a03c88b408c3094f806fba6f836d106ec 100644 (file)
@@ -492,7 +492,7 @@ function ($, NProgress) {
                             Password: password
                         },
                         success: function (json) {
-                            const data = json[0].data;
+                            const [{data}] = json;
                             $("#connectPassword").val("");
                             if (data.auth === "ok") {
                                 sessionStorage.setItem("read_only", data.read_only);
@@ -563,7 +563,7 @@ function ($, NProgress) {
         if (o.server === "All SERVERS") {
             queryServer(neighbours_status, 0, "neighbours", {
                 success: function (json) {
-                    const data = json[0].data;
+                    const [{data}] = json;
                     if (jQuery.isEmptyObject(data)) {
                         neighbours = {
                             local: {
@@ -695,7 +695,7 @@ function ($, NProgress) {
                 });
             },
             _onStatusDropdownChanged: function (e) {
-                const self = e.data.self;
+                const {self} = e.data;
                 const selected = self.$action.val();
                 if (selected !== self.def) {
                     const not = self.$not.is(":checked");
@@ -1054,7 +1054,7 @@ function ($, NProgress) {
     $(".dropdown-menu a").click(function (e) {
         e.preventDefault();
         const classList = $(this).attr("class");
-        const menuClass = (/\b(?:dynamic|history|preset)\b/).exec(classList)[0];
+        const [menuClass] = (/\b(?:dynamic|history|preset)\b/).exec(classList);
         $(".dropdown-menu a.active." + menuClass).removeClass("active");
         $(this).addClass("active");
         tabClick("#autoRefresh");
index 8fa58042182cb64fa1d58c9cffd03f9f27701fb1..c445793d90e8511be869f0ed532eef1d52b9961f 100644 (file)
@@ -58,7 +58,7 @@ define(["jquery", "app/rspamd", "d3pie", "d3"],
             const servers = JSON.parse(sessionStorage.getItem("Credentials"));
             let data = {};
             if (servers && servers[checked_server]) {
-                data = servers[checked_server].data;
+                ({data} = servers[checked_server]);
             }
 
             const stat_w = [];
@@ -122,7 +122,7 @@ define(["jquery", "app/rspamd", "d3pie", "d3"],
                         uptime = msToTime(val.data.uptime);
                     }
                     if ("version" in val.data) {
-                        version = val.data.version;
+                        ({version} = val.data);
                     }
                     if (key === "All SERVERS") {
                         short_id = "";
@@ -249,7 +249,7 @@ define(["jquery", "app/rspamd", "d3pie", "d3"],
             const creds = JSON.parse(sessionStorage.getItem("Credentials"));
             // Controller doesn't return the 'actions' object until at least one message is scanned
             if (creds && creds[checked_server] && creds[checked_server].data.scanned) {
-                const actions = creds[checked_server].data.actions;
+                const {actions} = creds[checked_server].data;
 
                 ["no action", "soft reject", "add header", "rewrite subject", "greylist", "reject"]
                     .forEach(function (action) {
@@ -295,7 +295,7 @@ define(["jquery", "app/rspamd", "d3pie", "d3"],
                         };
 
                         function process_node_stat(e) {
-                            const data = neighbours_status[e].data;
+                            const {data} = neighbours_status[e];
                             // Controller doesn't return the 'actions' object until at least one message is scanned
                             if (data.scanned) {
                                 for (const action in neighbours_sum.actions) {
index ab6e8c10152d7d94bec931f43dd4f1473cb617f1..be6ad8d81cebaa3fd04dc0afb2e3a5b0361db46f 100644 (file)
@@ -141,14 +141,14 @@ define(["jquery", "app/rspamd", "footable"],
         ui.getSymbols = function (checked_server) {
             rspamd.query("symbols", {
                 success: function (json) {
-                    const data = json[0].data;
+                    const [{data}] = json;
                     const items = process_symbols_data(data);
 
                     /* eslint-disable consistent-this, no-underscore-dangle, one-var-declaration-per-line */
                     FooTable.groupFilter = FooTable.Filtering.extend({
                         construct: function (instance) {
                             this._super(instance);
-                            this.groups = items[1];
+                            [,this.groups] = items;
                             this.def = "Any group";
                             this.$group = null;
                         },
@@ -176,7 +176,7 @@ define(["jquery", "app/rspamd", "footable"],
                             });
                         },
                         _onStatusDropdownChanged: function (e) {
-                            const self = e.data.self;
+                            const {self} = e.data;
                             const selected = $(this).val();
                             if (selected !== self.def) {
                                 self.addFilter("group", selected, ["group"]);
@@ -254,7 +254,7 @@ define(["jquery", "app/rspamd", "footable"],
             const checked_server = rspamd.getSelector("selSrv");
             rspamd.query("symbols", {
                 success: function (data) {
-                    const items = process_symbols_data(data[0].data)[0];
+                    const [items] = process_symbols_data(data[0].data);
                     rspamd.tables.symbols.rows.load(items);
                 },
                 server: (checked_server === "All SERVERS") ? "local" : checked_server
index 01031c4a0ba03d194f179c96d24aaace21d5d6b8..9893477f1d7e240235933f2bb593e643a904caaa 100644 (file)
@@ -172,7 +172,7 @@ define(["jquery", "app/rspamd"],
 
                         const rows_total = $("#historyTable_scan > tbody > tr:not(.footable-detail-row)").length + 1;
                         const o = rspamd.process_history_v2({rows: [json]}, "scan");
-                        const items = o.items;
+                        const {items} = o;
                         rspamd.symbols.scan.push(o.symbols[0]);
 
                         if (Object.prototype.hasOwnProperty.call(rspamd.tables, "scan")) {