fix various minor issues reported by eslint

This commit is contained in:
Andrew Dolgov 2020-06-04 23:27:22 +03:00
parent 755662a9d7
commit 88027d7a39
20 changed files with 115 additions and 74 deletions

View File

@ -88,7 +88,7 @@ module.exports = {
"max-nested-callbacks": "error", "max-nested-callbacks": "error",
"max-params": "off", "max-params": "off",
"max-statements": "off", "max-statements": "off",
"max-statements-per-line": "error", "max-statements-per-line": [ "warn", { "max" : 2 } ],
"multiline-comment-style": "off", "multiline-comment-style": "off",
"multiline-ternary": "off", "multiline-ternary": "off",
"new-cap": "error", "new-cap": "error",

View File

@ -1,3 +1,9 @@
'use strict';
/* global __, ngettext, Article, Headlines, Filters */
/* global xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Feeds, Cookie */
/* global CommonDialogs, CommonFilters, Plugins */
const App = { const App = {
_initParams: [], _initParams: [],
_rpc_seq: 0, _rpc_seq: 0,
@ -505,12 +511,12 @@ const App = {
stack_msg += `<div><b>Additional information:</b></div> stack_msg += `<div><b>Additional information:</b></div>
<textarea name="stack" readonly="1">${params.info}</textarea>`; <textarea name="stack" readonly="1">${params.info}</textarea>`;
let content = `<div class="error-contents"> const content = `<div class="error-contents">
<p class="message">${message}</p> <p class="message">${message}</p>
${stack_msg} ${stack_msg}
<div class="dlgButtons"> <div class="dlgButtons">
<button dojoType="dijit.form.Button" <button dojoType="dijit.form.Button"
onclick=\"dijit.byId('exceptionDlg').hide()">${__('Close this window')}</button> onclick="dijit.byId('exceptionDlg').hide()">${__('Close this window')}</button>
</div> </div>
</div>`; </div>`;
@ -579,7 +585,7 @@ const App = {
let errorMsg = ""; let errorMsg = "";
['MutationObserver'].each(function(wf) { ['MutationObserver'].each(function(wf) {
if (! (wf in window)) { if (!(wf in window)) {
errorMsg = `Browser feature check failed: <code>window.${wf}</code> not found.`; errorMsg = `Browser feature check failed: <code>window.${wf}</code> not found.`;
throw $break; throw $break;
} }
@ -611,7 +617,7 @@ const App = {
switch (this.urlParam('method')) { switch (this.urlParam('method')) {
case "editfeed": case "editfeed":
window.setTimeout(function () { window.setTimeout(() => {
CommonDialogs.editFeed(this.urlParam('methodparam')) CommonDialogs.editFeed(this.urlParam('methodparam'))
}, 100); }, 100);
break; break;
@ -1099,6 +1105,7 @@ const App = {
CommonDialogs.editFeed(Feeds.getActive()); CommonDialogs.editFeed(Feeds.getActive());
break; break;
case "qmcRemoveFeed": case "qmcRemoveFeed":
{
const actid = Feeds.getActive(); const actid = Feeds.getActive();
if (!actid) { if (!actid) {
@ -1116,6 +1123,7 @@ const App = {
if (confirm(__("Unsubscribe from %s?").replace("%s", fn))) { if (confirm(__("Unsubscribe from %s?").replace("%s", fn))) {
CommonDialogs.unsubscribeFeed(actid); CommonDialogs.unsubscribeFeed(actid);
} }
}
break; break;
case "qmcCatchupAll": case "qmcCatchupAll":
Feeds.catchupAll(); Feeds.catchupAll();

View File

@ -1,5 +1,7 @@
'use strict' 'use strict'
/* global __, ngettext */
/* global __, ngettext, App, Headlines, xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, escapeHtml */
const Article = { const Article = {
_scroll_reset_timeout: false, _scroll_reset_timeout: false,
getScoreClass: function (score) { getScoreClass: function (score) {
@ -342,7 +344,7 @@ const Article = {
mouseIn: function (id) { mouseIn: function (id) {
this.post_under_pointer = id; this.post_under_pointer = id;
}, },
mouseOut: function (id) { mouseOut: function (/* id */) {
this.post_under_pointer = false; this.post_under_pointer = false;
}, },
getUnderPointer: function () { getUnderPointer: function () {

View File

@ -1,6 +1,8 @@
'use strict' 'use strict'
/* global __, ngettext */
// noinspection JSUnusedGlobalSymbols /* global __, ngettext, dojo, dijit, Notify, App, Feeds, $$, xhrPost, xhrJson, Tables, Effect */
/* exported CommonDialogs */
const CommonDialogs = { const CommonDialogs = {
closeInfoBox: function() { closeInfoBox: function() {
const dialog = dijit.byId("infoBox"); const dialog = dijit.byId("infoBox");
@ -102,8 +104,10 @@ const CommonDialogs = {
xhrPost("backend.php", this.attr('value'), (transport) => { xhrPost("backend.php", this.attr('value'), (transport) => {
try { try {
let reply;
try { try {
var reply = JSON.parse(transport.responseText); reply = JSON.parse(transport.responseText);
} catch (e) { } catch (e) {
Element.hide("feed_add_spinner"); Element.hide("feed_add_spinner");
alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console.")); alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console."));
@ -136,6 +140,7 @@ const CommonDialogs = {
dialog.show_error(__("Specified URL doesn't seem to contain any feeds.")); dialog.show_error(__("Specified URL doesn't seem to contain any feeds."));
break; break;
case 4: case 4:
{
const feeds = rc['feeds']; const feeds = rc['feeds'];
Element.show("fadd_multiple_notify"); Element.show("fadd_multiple_notify");
@ -147,16 +152,14 @@ const CommonDialogs = {
select.addOption({value: '', label: __("Expand to select feed")}); select.addOption({value: '', label: __("Expand to select feed")});
let count = 0;
for (const feedUrl in feeds) { for (const feedUrl in feeds) {
if (feeds.hasOwnProperty(feedUrl)) { if (feeds.hasOwnProperty(feedUrl)) {
select.addOption({value: feedUrl, label: feeds[feedUrl]}); select.addOption({value: feedUrl, label: feeds[feedUrl]});
count++;
} }
} }
Effect.Appear('feedDlg_feedsContainer', {duration: 0.5}); Effect.Appear('feedDlg_feedsContainer', {duration: 0.5});
}
break; break;
case 5: case 5:
dialog.show_error(__("Couldn't download the specified URL: %s").replace("%s", rc['message'])); dialog.show_error(__("Couldn't download the specified URL: %s").replace("%s", rc['message']));

View File

@ -1,5 +1,7 @@
'use strict' 'use strict'
/* global __, ngettext */
/* global __, ngettext, App, Article, Lists */
/* global xhrPost, xhrJson, dojo, dijit, Notify, $$, Feeds */
const Filters = { const Filters = {
filterDlgCheckAction: function(sender) { filterDlgCheckAction: function(sender) {
@ -138,7 +140,7 @@ const Filters = {
content: __('Loading, please wait...'), content: __('Loading, please wait...'),
}); });
const tmph = dojo.connect(rule_dlg, "onShow", null, function (e) { const tmph = dojo.connect(rule_dlg, "onShow", null, function (/* e */) {
dojo.disconnect(tmph); dojo.disconnect(tmph);
xhrPost("backend.php", {op: 'pref-filters', method: 'newrule', rule: ruleStr}, (transport) => { xhrPost("backend.php", {op: 'pref-filters', method: 'newrule', rule: ruleStr}, (transport) => {
@ -252,7 +254,7 @@ const Filters = {
href: "backend.php?op=pref-filters&method=testFilterDlg" href: "backend.php?op=pref-filters&method=testFilterDlg"
}); });
dojo.connect(test_dlg, "onLoad", null, function (e) { dojo.connect(test_dlg, "onLoad", null, function (/* e */) {
test_dlg.getTestResults(params, 0); test_dlg.getTestResults(params, 0);
}); });

View File

@ -1,4 +1,5 @@
/* global dijit */ /* global dojo, dijit, define, App, Feeds, CommonDialogs, LABEL_BASE_INDEX */
define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct) { define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct) {
return declare("fox.FeedTree", dijit.Tree, { return declare("fox.FeedTree", dijit.Tree, {

View File

@ -1,5 +1,6 @@
'use strict' 'use strict'
/* global __, ngettext */
/* global __, ngettext, App, Headlines, xhrPost, dojo, dijit, Form, fox, PluginHost, Notify, $$ */
const Feeds = { const Feeds = {
counters_last_request: 0, counters_last_request: 0,
@ -207,6 +208,7 @@ const Feeds = {
//document.onkeypress = (event) => { return App.hotkeyHandler(event) }; //document.onkeypress = (event) => { return App.hotkeyHandler(event) };
window.onresize = () => { Headlines.scrollHandler(); } window.onresize = () => { Headlines.scrollHandler(); }
/* global hash_get */
const hash_feed_id = hash_get('f'); const hash_feed_id = hash_get('f');
const hash_feed_is_cat = hash_get('c') == "1"; const hash_feed_is_cat = hash_get('c') == "1";
@ -262,6 +264,7 @@ const Feeds = {
setActive: function(id, is_cat) { setActive: function(id, is_cat) {
console.log('setActive', id, is_cat); console.log('setActive', id, is_cat);
/* global hash_set */
hash_set('f', id); hash_set('f', id);
hash_set('c', is_cat ? 1 : 0); hash_set('c', is_cat ? 1 : 0);

View File

@ -1,5 +1,8 @@
'use strict'; 'use strict';
/* global __, ngettext */
/* global __, ngettext, Article, App, escapeHtml */
/* global xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Feeds */
/* global CommonDialogs */
const Headlines = { const Headlines = {
vgroup_last_feed: undefined, vgroup_last_feed: undefined,
@ -319,7 +322,7 @@ const Headlines = {
if (App.getInitParam("cdm_auto_catchup")) { if (App.getInitParam("cdm_auto_catchup")) {
let rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]"); const rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]");
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
const row = rows[i]; const row = rows[i];
@ -1185,8 +1188,8 @@ const Headlines = {
if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(msg)) { if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(msg)) {
for (var i = 0; i < ids_to_mark.length; i++) { for (let i = 0; i < ids_to_mark.length; i++) {
var e = $("RROW-" + ids_to_mark[i]); const e = $("RROW-" + ids_to_mark[i]);
e.removeClassName("Unread"); e.removeClassName("Unread");
} }
} }
@ -1231,14 +1234,14 @@ const Headlines = {
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Open original article"), label: __("Open original article"),
onClick: function (event) { onClick: function (/* event */) {
Article.openInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id")); Article.openInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id"));
} }
})); }));
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Display article URL"), label: __("Display article URL"),
onClick: function (event) { onClick: function (/* event */) {
Article.displayUrl(this.getParent().currentTarget.getAttribute("data-article-id")); Article.displayUrl(this.getParent().currentTarget.getAttribute("data-article-id"));
} }
})); }));
@ -1387,7 +1390,7 @@ const Headlines = {
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Select articles in group"), label: __("Select articles in group"),
onClick: function (event) { onClick: function (/* event */) {
Headlines.select("all", Headlines.select("all",
"#headlines-frame > div[id*=RROW]" + "#headlines-frame > div[id*=RROW]" +
"[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']"); "[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']");

View File

@ -1,5 +1,7 @@
// based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system // based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system
/* exported PluginHost */
const PluginHost = { const PluginHost = {
HOOK_ARTICLE_RENDERED: 1, HOOK_ARTICLE_RENDERED: 1,
HOOK_ARTICLE_RENDERED_CDM: 2, HOOK_ARTICLE_RENDERED_CDM: 2,
@ -31,7 +33,7 @@ const PluginHost = {
} }
}, },
unregister: function (name, callback) { unregister: function (name, callback) {
for (var i = 0; i < this.hooks[name].length; i++) for (let i = 0; i < this.hooks[name].length; i++)
if (this.hooks[name][i] == callback) if (this.hooks[name][i] == callback)
this.hooks[name].splice(i, 1); this.hooks[name].splice(i, 1);
} }

View File

@ -1,9 +1,10 @@
/* global define, dojo */
define(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) { define(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) {
return declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, { return declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
_saveEverything: function(saveCompleteCallback, saveFailedCallback, _saveEverything: function(saveCompleteCallback, saveFailedCallback, newFileContentString) {
newFileContentString) {
dojo.xhrPost({ dojo.xhrPost({
url: "backend.php", url: "backend.php",

View File

@ -1,4 +1,5 @@
/* global lib,dijit */ /* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhrPost */
define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) {
return declare("fox.PrefFeedTree", lib.CheckBoxTree, { return declare("fox.PrefFeedTree", lib.CheckBoxTree, {

View File

@ -1,9 +1,10 @@
/* global define, dojo */
define(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) { define(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) {
return declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, { return declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, {
_saveEverything: function (saveCompleteCallback, saveFailedCallback, _saveEverything: function (saveCompleteCallback, saveFailedCallback, newFileContentString) {
newFileContentString) {
dojo.xhrPost({ dojo.xhrPost({
url: "backend.php", url: "backend.php",

View File

@ -1,4 +1,5 @@
/* global dijit,lib */ /* global __, $$, define, lib, dijit, dojo, xhrPost, Notify, Filters, Lists */
define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) {
return declare("fox.PrefFilterTree", lib.CheckBoxTree, { return declare("fox.PrefFilterTree", lib.CheckBoxTree, {
@ -236,9 +237,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
return false; return false;
}, },
}); });
}); });

View File

@ -1,3 +1,7 @@
'use strict';
/* global __, dijit, dojo, Tables, xhrPost, Notify, xhrJson */
const Helpers = { const Helpers = {
AppPasswords: { AppPasswords: {
getSelected: function() { getSelected: function() {
@ -12,8 +16,7 @@ const Helpers = {
if (rows.length == 0) { if (rows.length == 0) {
alert("No passwords selected."); alert("No passwords selected.");
} else { } else if (confirm(__("Remove selected app passwords?"))) {
if (confirm(__("Remove selected app passwords?"))) {
xhrPost("backend.php", {op: "pref-prefs", method: "deleteAppPassword", ids: rows.toString()}, (transport) => { xhrPost("backend.php", {op: "pref-prefs", method: "deleteAppPassword", ids: rows.toString()}, (transport) => {
this.updateContent(transport.responseText); this.updateContent(transport.responseText);
@ -22,7 +25,6 @@ const Helpers = {
Notify.progress("Loading, please wait..."); Notify.progress("Loading, please wait...");
} }
}
}, },
generate: function() { generate: function() {
const title = prompt("Password description:") const title = prompt("Password description:")
@ -132,6 +134,7 @@ const Helpers = {
}, },
execute: function () { execute: function () {
if (this.validate()) { if (this.validate()) {
//
} }
}, },
href: query href: query

View File

@ -1,4 +1,5 @@
/* global lib,dijit */ /* global __, define, lib, dijit, dojo, xhrPost, Notify */
define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare, domConstruct) { define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare, domConstruct) {
return declare("fox.PrefLabelTree", lib.CheckBoxTree, { return declare("fox.PrefLabelTree", lib.CheckBoxTree, {

View File

@ -1,5 +1,7 @@
'use strict' 'use strict'
/* global __, ngettext */
/* global __ */
/* global xhrPost, dojo, dijit, Notify, Tables */
const Users = { const Users = {
reload: function(sort) { reload: function(sort) {
@ -39,7 +41,7 @@ const Users = {
if (this.validate()) { if (this.validate()) {
Notify.progress("Saving data...", true); Notify.progress("Saving data...", true);
xhrPost("backend.php", dojo.formToObject("user_edit_form"), (transport) => { xhrPost("backend.php", dojo.formToObject("user_edit_form"), (/* transport */) => {
dialog.hide(); dialog.hide();
Users.reload(); Users.reload();
}); });

View File

@ -1,10 +1,11 @@
/* global dijit */ /* global dijit, define */
define(["dojo/_base/declare", "dijit/Toolbar"], function (declare) { define(["dojo/_base/declare", "dijit/Toolbar"], function (declare) {
return declare("fox.Toolbar", dijit.Toolbar, { return declare("fox.Toolbar", dijit.Toolbar, {
_onContainerKeydown: function(/* Event */ e) { _onContainerKeydown: function(/* Event */ /* e */) {
return; // Stop dijit.Toolbar from interpreting keystrokes return; // Stop dijit.Toolbar from interpreting keystrokes
}, },
_onContainerKeypress: function(/* Event */ e) { _onContainerKeypress: function(/* Event */ /* e */) {
return; // Stop dijit.Toolbar from interpreting keystrokes return; // Stop dijit.Toolbar from interpreting keystrokes
}, },
focus: function() { focus: function() {

View File

@ -1,5 +1,8 @@
'use strict' 'use strict'
/* global require, App */
/* exported Plugins */
const Plugins = {}; const Plugins = {};
require(["dojo/_base/kernel", require(["dojo/_base/kernel",

View File

@ -1,6 +1,8 @@
'use strict' 'use strict'
/* global dijit,__ */
/* global require, App */
/* exported Plugins */
const Plugins = {}; const Plugins = {};
require(["dojo/_base/kernel", require(["dojo/_base/kernel",
@ -65,11 +67,13 @@ require(["dojo/_base/kernel",
}); });
}); });
/* exported hash_get */
function hash_get(key) { function hash_get(key) {
const kv = window.location.hash.substring(1).toQueryParams(); const kv = window.location.hash.substring(1).toQueryParams();
return kv[key]; return kv[key];
} }
/* exported hash_set */
function hash_set(key, value) { function hash_set(key, value) {
const kv = window.location.hash.substring(1).toQueryParams(); const kv = window.location.hash.substring(1).toQueryParams();
kv[key] = value; kv[key] = value;

View File

@ -1,4 +1,6 @@
/* TODO: this should probably be something like night_mode.js since it does nothing specific to utility scripts */2 /* global UtilityApp */
/* TODO: this should probably be something like night_mode.js since it does nothing specific to utility scripts */
Event.observe(window, "load", function() { Event.observe(window, "load", function() {
const UtilityJS = { const UtilityJS = {