From 7f0800537e8268dcbc4fce19f38fcbaa3d78a1cd Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 12 Feb 2021 19:02:09 +0300 Subject: [PATCH] silence (or fix) a bunch of eslint warnings --- js/App.js | 1 + js/Article.js | 65 ++++++++++++++++++----------------- js/FeedTree.js | 14 ++++---- js/Headlines.js | 2 ++ js/PrefFeedTree.js | 1 + js/PrefFilterTree.js | 6 ++-- js/PrefHelpers.js | 3 +- js/PrefLabelTree.js | 2 ++ js/common.js | 8 ++--- js/form/ComboButton.js | 3 +- js/form/DropDownButton.js | 3 +- js/form/Select.js | 2 +- js/form/ValidationTextArea.js | 3 ++ js/tt-rss.js | 2 +- 14 files changed, 65 insertions(+), 50 deletions(-) diff --git a/js/App.js b/js/App.js index 483d22211..514a6d4b7 100644 --- a/js/App.js +++ b/js/App.js @@ -1,5 +1,6 @@ 'use strict'; +/* eslint-disable new-cap */ /* global __, Article, Ajax, Headlines, Filters, fox */ /* global xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Feeds, Cookie */ /* global CommonDialogs, Plugins, Effect */ diff --git a/js/Article.js b/js/Article.js index d6e7bbad9..61368dfed 100644 --- a/js/Article.js +++ b/js/Article.js @@ -1,5 +1,6 @@ 'use strict' +/* eslint-disable no-new */ /* global __, ngettext, App, Headlines, xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Ajax, fox */ const Article = { @@ -250,52 +251,52 @@ const Article = { return false; }, editTags: function (id) { - xhrPost("backend.php", {op: "article", method: "editarticletags", param: id}, (transport) => { + const dialog = new fox.SingleUseDialog({ + id: "editTagsDlg", + title: __("Edit article Tags"), + content: __("Loading, please wait..."), + execute: function () { + if (this.validate()) { + Notify.progress("Saving article tags...", true); - const dialog = new fox.SingleUseDialog({ - id: "editTagsDlg", - title: __("Edit article Tags"), - content: transport.responseText, - execute: function () { - if (this.validate()) { - Notify.progress("Saving article tags...", true); + xhrPost("backend.php", this.attr('value'), (transport) => { + try { + Notify.close(); + dialog.hide(); - xhrPost("backend.php", this.attr('value'), (transport) => { - try { - Notify.close(); - dialog.hide(); + const data = JSON.parse(transport.responseText); - const data = JSON.parse(transport.responseText); + if (data) { + const id = data.id; - if (data) { - const id = data.id; + const tags = $("ATSTR-" + id); + const tooltip = dijit.byId("ATSTRTIP-" + id); - const tags = $("ATSTR-" + id); - const tooltip = dijit.byId("ATSTRTIP-" + id); - - if (tags) tags.innerHTML = data.content; - if (tooltip) tooltip.attr('label', data.content_full); - } - } catch (e) { - App.Error.report(e); + if (tags) tags.innerHTML = data.content; + if (tooltip) tooltip.attr('label', data.content_full); } - }); - } - }, - }); + } catch (e) { + App.Error.report(e); + } + }); + } + }, + }); - const tmph = dojo.connect(dialog, 'onShow', function () { - dojo.disconnect(tmph); + const tmph = dojo.connect(dialog, 'onShow', function () { + dojo.disconnect(tmph); + + xhrPost("backend.php", {op: "article", method: "editarticletags", param: id}, (transport) => { + dialog.attr('content', transport.responseText); new Ajax.Autocompleter('tags_str', 'tags_choices', "backend.php?op=article&method=completeTags", {tokens: ',', paramName: "search"}); }); - - dialog.show(); - }); + dialog.show(); + }, cdmMoveToId: function (id, params) { params = params || {}; diff --git a/js/FeedTree.js b/js/FeedTree.js index c61d8a50f..26c1c916c 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -7,9 +7,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co // save state in localStorage instead of cookies // reference: https://stackoverflow.com/a/27968996 _saveExpandedNodes: function(){ - if(this.persist && this.cookieName){ - var ary = []; - for(var id in this._openedNodes){ + if (this.persist && this.cookieName){ + const ary = []; + for (const id in this._openedNodes){ ary.push(id); } // Was: @@ -21,16 +21,16 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co // summary: // Load in which nodes should be opened automatically this._openedNodes = {}; - if(this.persist && this.cookieName){ + if (this.persist && this.cookieName){ // Was: // var oreo = cookie(this.cookieName); - var oreo = localStorage.getItem(this.cookieName); + let oreo = localStorage.getItem(this.cookieName); // migrate old data if nothing in localStorage - if(oreo == null || oreo === '') { + if (oreo == null || oreo === '') { oreo = cookie(this.cookieName); cookie(this.cookieName, null, { expires: -1 }); } - if(oreo){ + if (oreo){ array.forEach(oreo.split(','), function(item){ this._openedNodes[item] = true; }, this); diff --git a/js/Headlines.js b/js/Headlines.js index 3b4498430..ea4c81a6a 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -199,6 +199,7 @@ const Headlines = { } else if (event.ctrlKey) { Headlines.select('invert', id); } else { + // eslint-disable-next-line no-lonely-if if (App.isCombinedMode()) { if (event.altKey && !in_body) { @@ -237,6 +238,7 @@ const Headlines = { return in_body; } else { + // eslint-disable-next-line no-lonely-if if (event.altKey) { Article.openInNewWindow(id); Headlines.toggleUnread(id, 0); diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index df8cbfd1d..89195e616 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -1,3 +1,4 @@ +/* eslint-disable prefer-rest-params */ /* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhrPost, fox, App */ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index b16fcb4c9..abfdbb3b0 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -1,4 +1,5 @@ -/* global __, $$, define, lib, dijit, dojo, xhrPost, Notify, Filters, Lists */ +/* eslint-disable prefer-rest-params */ +/* global __, define, lib, dijit, dojo, xhrPost, Notify */ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { @@ -54,6 +55,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio return label; }, getIconClass: function (item, opened) { + // eslint-disable-next-line no-nested-ternary return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible"; }, getRowClass: function (item, opened) { @@ -62,7 +64,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio return enabled ? "dijitTreeRow" : "dijitTreeRow filterDisabled"; }, checkItemAcceptance: function(target, source, position) { - const item = dijit.getEnclosingWidget(target).item; + //const item = dijit.getEnclosingWidget(target).item; // disable copying items source.copyState = function() { return false; }; diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index 4e0161625..5bb76d179 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -1,6 +1,7 @@ 'use strict'; -/* global __, dijit, dojo, Tables, xhrPost, Notify, xhrJson, App, fox */ +/* eslint-disable no-new */ +/* global __, dijit, dojo, Tables, xhrPost, Notify, xhrJson, App, fox, Effect */ const Helpers = { AppPasswords: { diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index eab1a643b..73f375f2d 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -1,3 +1,4 @@ +/* eslint-disable prefer-rest-params */ /* global __, define, lib, dijit, dojo, xhrPost, Notify, fox */ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare, domConstruct) { @@ -39,6 +40,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f return tnode; }, getIconClass: function (item, opened) { + // eslint-disable-next-line no-nested-ternary return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible"; }, getSelectedLabels: function() { diff --git a/js/common.js b/js/common.js index c17e8bc45..fb5cc6531 100755 --- a/js/common.js +++ b/js/common.js @@ -1,6 +1,7 @@ 'use strict'; /* global dijit, __, App, Ajax */ +/* eslint-disable no-new */ /* error reporting shim */ // TODO: deprecated; remove @@ -31,8 +32,8 @@ function xhrPost(url, params, complete) { /* exported xhrJson */ function xhrJson(url, params, complete) { - return new Promise((resolve, reject) => { - return xhrPost(url, params).then((reply) => { + return new Promise((resolve, reject) => + xhrPost(url, params).then((reply) => { let obj = null; try { @@ -44,8 +45,7 @@ function xhrJson(url, params, complete) { if (complete != undefined) complete(obj); resolve(obj); - }); - }); + })); } /* add method to remove element from array */ diff --git a/js/form/ComboButton.js b/js/form/ComboButton.js index 1084cda9c..2ad4bf123 100755 --- a/js/form/ComboButton.js +++ b/js/form/ComboButton.js @@ -1,4 +1,5 @@ -/* global dijit */ +/* eslint-disable prefer-rest-params */ +/* global dijit, define */ define(["dojo/_base/declare", "dijit/form/ComboButton"], function (declare) { return declare("fox.form.ComboButton", dijit.form.ComboButton, { startup: function() { diff --git a/js/form/DropDownButton.js b/js/form/DropDownButton.js index 0c182772a..d5ea39726 100755 --- a/js/form/DropDownButton.js +++ b/js/form/DropDownButton.js @@ -1,4 +1,5 @@ -/* global dijit */ +/* eslint-disable prefer-rest-params */ +/* global dijit, define */ define(["dojo/_base/declare", "dijit/form/DropDownButton"], function (declare) { return declare("fox.form.DropDownButton", dijit.form.DropDownButton, { startup: function() { diff --git a/js/form/Select.js b/js/form/Select.js index c62db1821..530880e2d 100755 --- a/js/form/Select.js +++ b/js/form/Select.js @@ -1,4 +1,4 @@ -/* global dijit */ +/* global dijit, define */ define(["dojo/_base/declare", "dijit/form/Select"], function (declare) { return declare("fox.form.Select", dijit.form.Select, { focus: function() { diff --git a/js/form/ValidationTextArea.js b/js/form/ValidationTextArea.js index a7993f716..c53260f40 100644 --- a/js/form/ValidationTextArea.js +++ b/js/form/ValidationTextArea.js @@ -1,4 +1,6 @@ // https://stackoverflow.com/questions/19317258/how-to-use-dijit-textarea-validation-dojo-1-9 +/* eslint-disable no-new */ +/* global define */ define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/SimpleTextarea", "dijit/form/ValidationTextBox"], function(declare, lang, SimpleTextarea, ValidationTextBox) { @@ -8,6 +10,7 @@ define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/SimpleTextarea", "d this.constraints = {}; this.baseClass += ' dijitValidationTextArea'; }, + // eslint-disable-next-line no-template-curly-in-string templateString: "", validator: function(value, constraints) { //console.log(this, value, constraints); diff --git a/js/tt-rss.js b/js/tt-rss.js index 7bf166b51..764667a0d 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -1,6 +1,6 @@ 'use strict' -/* global require, App */ +/* global require, App, $H */ /* exported Plugins */ const Plugins = {};