diff --git a/.eslintrc.js b/.eslintrc.js index 58dd6f9e2..f44a8b3ed 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -88,7 +88,7 @@ module.exports = { "max-nested-callbacks": "error", "max-params": "off", "max-statements": "off", - "max-statements-per-line": "error", + "max-statements-per-line": [ "warn", { "max" : 2 } ], "multiline-comment-style": "off", "multiline-ternary": "off", "new-cap": "error", diff --git a/js/App.js b/js/App.js index 54e8f61f3..f75413c86 100644 --- a/js/App.js +++ b/js/App.js @@ -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 = { _initParams: [], _rpc_seq: 0, @@ -505,12 +511,12 @@ const App = { stack_msg += `
Additional information:
`; - let content = `
+ const content = `

${message}

${stack_msg}
+ onclick="dijit.byId('exceptionDlg').hide()">${__('Close this window')}
`; @@ -579,7 +585,7 @@ const App = { let errorMsg = ""; ['MutationObserver'].each(function(wf) { - if (! (wf in window)) { + if (!(wf in window)) { errorMsg = `Browser feature check failed: window.${wf} not found.`; throw $break; } @@ -611,7 +617,7 @@ const App = { switch (this.urlParam('method')) { case "editfeed": - window.setTimeout(function () { + window.setTimeout(() => { CommonDialogs.editFeed(this.urlParam('methodparam')) }, 100); break; @@ -1099,22 +1105,24 @@ const App = { CommonDialogs.editFeed(Feeds.getActive()); break; case "qmcRemoveFeed": - const actid = Feeds.getActive(); + { + const actid = Feeds.getActive(); - if (!actid) { - alert(__("Please select some feed first.")); - return; - } + if (!actid) { + alert(__("Please select some feed first.")); + return; + } - if (Feeds.activeIsCat()) { - alert(__("You can't unsubscribe from the category.")); - return; - } + if (Feeds.activeIsCat()) { + alert(__("You can't unsubscribe from the category.")); + return; + } - const fn = Feeds.getName(actid); + const fn = Feeds.getName(actid); - if (confirm(__("Unsubscribe from %s?").replace("%s", fn))) { - CommonDialogs.unsubscribeFeed(actid); + if (confirm(__("Unsubscribe from %s?").replace("%s", fn))) { + CommonDialogs.unsubscribeFeed(actid); + } } break; case "qmcCatchupAll": diff --git a/js/Article.js b/js/Article.js index 197bfb3ab..5044b6e0e 100644 --- a/js/Article.js +++ b/js/Article.js @@ -1,5 +1,7 @@ 'use strict' -/* global __, ngettext */ + +/* global __, ngettext, App, Headlines, xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, escapeHtml */ + const Article = { _scroll_reset_timeout: false, getScoreClass: function (score) { @@ -342,7 +344,7 @@ const Article = { mouseIn: function (id) { this.post_under_pointer = id; }, - mouseOut: function (id) { + mouseOut: function (/* id */) { this.post_under_pointer = false; }, getUnderPointer: function () { diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 16e390302..ea178ffca 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -1,6 +1,8 @@ 'use strict' -/* global __, ngettext */ -// noinspection JSUnusedGlobalSymbols + +/* global __, ngettext, dojo, dijit, Notify, App, Feeds, $$, xhrPost, xhrJson, Tables, Effect */ + +/* exported CommonDialogs */ const CommonDialogs = { closeInfoBox: function() { const dialog = dijit.byId("infoBox"); @@ -102,8 +104,10 @@ const CommonDialogs = { xhrPost("backend.php", this.attr('value'), (transport) => { try { + let reply; + try { - var reply = JSON.parse(transport.responseText); + reply = JSON.parse(transport.responseText); } catch (e) { 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.")); @@ -136,27 +140,26 @@ const CommonDialogs = { dialog.show_error(__("Specified URL doesn't seem to contain any feeds.")); break; case 4: - const feeds = rc['feeds']; + { + const feeds = rc['feeds']; - Element.show("fadd_multiple_notify"); + Element.show("fadd_multiple_notify"); - const select = dijit.byId("feedDlg_feedContainerSelect"); + const select = dijit.byId("feedDlg_feedContainerSelect"); - while (select.getOptions().length > 0) - select.removeOption(0); + while (select.getOptions().length > 0) + select.removeOption(0); - select.addOption({value: '', label: __("Expand to select feed")}); + select.addOption({value: '', label: __("Expand to select feed")}); - let count = 0; - for (const feedUrl in feeds) { - if (feeds.hasOwnProperty(feedUrl)) { - select.addOption({value: feedUrl, label: feeds[feedUrl]}); - count++; + for (const feedUrl in feeds) { + if (feeds.hasOwnProperty(feedUrl)) { + select.addOption({value: feedUrl, label: feeds[feedUrl]}); + } } + + Effect.Appear('feedDlg_feedsContainer', {duration: 0.5}); } - - Effect.Appear('feedDlg_feedsContainer', {duration: 0.5}); - break; case 5: dialog.show_error(__("Couldn't download the specified URL: %s").replace("%s", rc['message'])); diff --git a/js/CommonFilters.js b/js/CommonFilters.js index 9f0ee579a..c34380526 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -1,5 +1,7 @@ 'use strict' -/* global __, ngettext */ + +/* global __, ngettext, App, Article, Lists */ +/* global xhrPost, xhrJson, dojo, dijit, Notify, $$, Feeds */ const Filters = { filterDlgCheckAction: function(sender) { @@ -138,7 +140,7 @@ const Filters = { 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); 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" }); - dojo.connect(test_dlg, "onLoad", null, function (e) { + dojo.connect(test_dlg, "onLoad", null, function (/* e */) { test_dlg.getTestResults(params, 0); }); diff --git a/js/FeedTree.js b/js/FeedTree.js index 85892b3d9..4e8f5930e 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -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) { return declare("fox.FeedTree", dijit.Tree, { diff --git a/js/Feeds.js b/js/Feeds.js index 9d6dd307c..9b8685a25 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -1,5 +1,6 @@ 'use strict' -/* global __, ngettext */ + +/* global __, ngettext, App, Headlines, xhrPost, dojo, dijit, Form, fox, PluginHost, Notify, $$ */ const Feeds = { counters_last_request: 0, @@ -207,6 +208,7 @@ const Feeds = { //document.onkeypress = (event) => { return App.hotkeyHandler(event) }; window.onresize = () => { Headlines.scrollHandler(); } + /* global hash_get */ const hash_feed_id = hash_get('f'); const hash_feed_is_cat = hash_get('c') == "1"; @@ -262,6 +264,7 @@ const Feeds = { setActive: function(id, is_cat) { console.log('setActive', id, is_cat); + /* global hash_set */ hash_set('f', id); hash_set('c', is_cat ? 1 : 0); diff --git a/js/Headlines.js b/js/Headlines.js index 7a5a7ee94..1e6fc4268 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -1,5 +1,8 @@ 'use strict'; -/* global __, ngettext */ + +/* global __, ngettext, Article, App, escapeHtml */ +/* global xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Feeds */ +/* global CommonDialogs */ const Headlines = { vgroup_last_feed: undefined, @@ -319,7 +322,7 @@ const Headlines = { 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++) { const row = rows[i]; @@ -1185,8 +1188,8 @@ const Headlines = { if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(msg)) { - for (var i = 0; i < ids_to_mark.length; i++) { - var e = $("RROW-" + ids_to_mark[i]); + for (let i = 0; i < ids_to_mark.length; i++) { + const e = $("RROW-" + ids_to_mark[i]); e.removeClassName("Unread"); } } @@ -1231,14 +1234,14 @@ const Headlines = { menu.addChild(new dijit.MenuItem({ label: __("Open original article"), - onClick: function (event) { + onClick: function (/* event */) { Article.openInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id")); } })); menu.addChild(new dijit.MenuItem({ label: __("Display article URL"), - onClick: function (event) { + onClick: function (/* event */) { Article.displayUrl(this.getParent().currentTarget.getAttribute("data-article-id")); } })); @@ -1387,7 +1390,7 @@ const Headlines = { menu.addChild(new dijit.MenuItem({ label: __("Select articles in group"), - onClick: function (event) { + onClick: function (/* event */) { Headlines.select("all", "#headlines-frame > div[id*=RROW]" + "[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']"); diff --git a/js/PluginHost.js b/js/PluginHost.js index 11f2bd1f1..caee79d58 100644 --- a/js/PluginHost.js +++ b/js/PluginHost.js @@ -1,5 +1,7 @@ // based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system + +/* exported PluginHost */ const PluginHost = { HOOK_ARTICLE_RENDERED: 1, HOOK_ARTICLE_RENDERED_CDM: 2, @@ -31,7 +33,7 @@ const PluginHost = { } }, 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) this.hooks[name].splice(i, 1); } diff --git a/js/PrefFeedStore.js b/js/PrefFeedStore.js index 152ebba44..ee983af54 100644 --- a/js/PrefFeedStore.js +++ b/js/PrefFeedStore.js @@ -1,9 +1,10 @@ +/* global define, dojo */ + define(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) { return declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, { - _saveEverything: function(saveCompleteCallback, saveFailedCallback, - newFileContentString) { + _saveEverything: function(saveCompleteCallback, saveFailedCallback, newFileContentString) { dojo.xhrPost({ url: "backend.php", diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index 3a5e33b2b..4ea0cdac1 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -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) { return declare("fox.PrefFeedTree", lib.CheckBoxTree, { diff --git a/js/PrefFilterStore.js b/js/PrefFilterStore.js index cccec6479..a41d84129 100644 --- a/js/PrefFilterStore.js +++ b/js/PrefFilterStore.js @@ -1,9 +1,10 @@ +/* global define, dojo */ + define(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) { return declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, { - _saveEverything: function (saveCompleteCallback, saveFailedCallback, - newFileContentString) { + _saveEverything: function (saveCompleteCallback, saveFailedCallback, newFileContentString) { dojo.xhrPost({ url: "backend.php", diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index 5fe0714c0..0e8e52658 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -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) { return declare("fox.PrefFilterTree", lib.CheckBoxTree, { @@ -236,9 +237,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio return false; }, - - - }); }); diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index 21e07bc26..12710bc6a 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -1,3 +1,7 @@ +'use strict'; + +/* global __, dijit, dojo, Tables, xhrPost, Notify, xhrJson */ + const Helpers = { AppPasswords: { getSelected: function() { @@ -12,16 +16,14 @@ const Helpers = { if (rows.length == 0) { alert("No passwords selected."); - } else { - if (confirm(__("Remove selected app passwords?"))) { + } else if (confirm(__("Remove selected app passwords?"))) { - xhrPost("backend.php", {op: "pref-prefs", method: "deleteAppPassword", ids: rows.toString()}, (transport) => { - this.updateContent(transport.responseText); - Notify.close(); - }); + xhrPost("backend.php", {op: "pref-prefs", method: "deleteAppPassword", ids: rows.toString()}, (transport) => { + this.updateContent(transport.responseText); + Notify.close(); + }); - Notify.progress("Loading, please wait..."); - } + Notify.progress("Loading, please wait..."); } }, generate: function() { @@ -132,6 +134,7 @@ const Helpers = { }, execute: function () { if (this.validate()) { + // } }, href: query diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index 988e313b0..b14474feb 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -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) { return declare("fox.PrefLabelTree", lib.CheckBoxTree, { diff --git a/js/PrefUsers.js b/js/PrefUsers.js index 1e7ed6523..8136e9c65 100644 --- a/js/PrefUsers.js +++ b/js/PrefUsers.js @@ -1,5 +1,7 @@ 'use strict' -/* global __, ngettext */ + +/* global __ */ +/* global xhrPost, dojo, dijit, Notify, Tables */ const Users = { reload: function(sort) { @@ -39,7 +41,7 @@ const Users = { if (this.validate()) { 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(); Users.reload(); }); diff --git a/js/Toolbar.js b/js/Toolbar.js index 6d2c20058..d4993e713 100755 --- a/js/Toolbar.js +++ b/js/Toolbar.js @@ -1,10 +1,11 @@ -/* global dijit */ +/* global dijit, define */ + define(["dojo/_base/declare", "dijit/Toolbar"], function (declare) { return declare("fox.Toolbar", dijit.Toolbar, { - _onContainerKeydown: function(/* Event */ e) { + _onContainerKeydown: function(/* Event */ /* e */) { return; // Stop dijit.Toolbar from interpreting keystrokes }, - _onContainerKeypress: function(/* Event */ e) { + _onContainerKeypress: function(/* Event */ /* e */) { return; // Stop dijit.Toolbar from interpreting keystrokes }, focus: function() { diff --git a/js/prefs.js b/js/prefs.js index 94cfe6394..a71b4f39e 100755 --- a/js/prefs.js +++ b/js/prefs.js @@ -1,5 +1,8 @@ 'use strict' +/* global require, App */ + +/* exported Plugins */ const Plugins = {}; require(["dojo/_base/kernel", diff --git a/js/tt-rss.js b/js/tt-rss.js index 503ebdac1..83c6681cd 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -1,6 +1,8 @@ 'use strict' -/* global dijit,__ */ +/* global require, App */ + +/* exported Plugins */ const Plugins = {}; require(["dojo/_base/kernel", @@ -65,11 +67,13 @@ require(["dojo/_base/kernel", }); }); +/* exported hash_get */ function hash_get(key) { const kv = window.location.hash.substring(1).toQueryParams(); return kv[key]; } +/* exported hash_set */ function hash_set(key, value) { const kv = window.location.hash.substring(1).toQueryParams(); kv[key] = value; diff --git a/js/utility.js b/js/utility.js index 2380f9823..eef1c6b61 100644 --- a/js/utility.js +++ b/js/utility.js @@ -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() { const UtilityJS = {