diff options
| author | Greg <supahgreg@users.noreply.github.com> | 2025-10-13 23:39:24 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-13 23:39:24 -0500 |
| commit | 6505cbb592b91556ca25a2bf72ad1d8cb0b3bc2a (patch) | |
| tree | 8ab133cc17a329ef7d99d152b3f6b4edc3830509 /js/FeedTree.js | |
| parent | 0d2b1d601294802286aa26e5486c1c4fee92c05a (diff) | |
| parent | 8b46ab31a96b6b6129f624719ac33ddf761805f1 (diff) | |
Merge pull request #42 from tt-rss/bugfix/eslint-config-and-findings
Get ESLint 9.x working, make the new config stricter, address findings
Diffstat (limited to 'js/FeedTree.js')
| -rwxr-xr-x | js/FeedTree.js | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/js/FeedTree.js b/js/FeedTree.js index 683205579..01755e7b4 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -1,5 +1,4 @@ -/* eslint-disable prefer-rest-params */ -/* global __, dojo, dijit, define, App, Feeds, CommonDialogs */ +/* global __, define, App, Feeds, CommonDialogs */ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/cookie", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct, array, cookie) { @@ -26,7 +25,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co // var oreo = cookie(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 }); } @@ -50,7 +49,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co let iconNode; if (iconName) { - if (iconName.indexOf("/") == -1) { + if (iconName.indexOf("/") === -1) { iconNode = dojo.create("i", { className: "material-icons icon icon-" + iconName, innerHTML: iconName }); } else { iconNode = dojo.create('img', { className: 'icon' }); @@ -156,7 +155,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co domConstruct.place(tnode.loadingNode, tnode.expandoNode, 'only'); } - if (id.match("CAT:") && bare_id == -1) { + if (id.match("CAT:") && bare_id === -1) { const menu = new dijit.Menu(); menu.row_id = bare_id; @@ -205,33 +204,36 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co } }, getTooltip: function (item) { - return [item.updated, item.error].filter((x) => x && x != "").join(" - "); + // TODO: item.error is `[""]` for feeds. Need to look into what's happening on the frontend to cause that-- the backend sends a string. + // For now, just adding a check for `[""]`. + return [item.updated, item.error].filter((x) => x && x !== '' && !(Array.isArray(x) && x.length === 1 && x[0] === '')).join(' - '); }, getIconClass: function (item, opened) { - // eslint-disable-next-line no-nested-ternary return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon"; }, - getLabelClass: function (item/* , opened */) { + getLabelClass: function (item /*, opened */) { return (item.unread <= 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread"; }, - getRowClass: function (item/*, opened */) { + getRowClass: function (item /*, opened */) { let rc = "dijitTreeRow dijitTreeRowFlex"; - const is_cat = String(item.id).indexOf('CAT:') != -1; + const is_cat = String(item.id).indexOf('CAT:') !== -1; if (is_cat) rc += " Is_Cat"; else rc += " Is_Feed"; - if (!is_cat && item.error != '') rc += " Error"; + // TODO: item.error is `[""]` for feeds. Need to look into what's happening on the frontend to cause that-- the backend sends a string. + // For now, just adding a check for `[""]`. + if (!is_cat && item.error !== '' && !(Array.isArray(item.error) && item.error.length === 1 && item.error[0] === '')) rc += ' Error'; if (item.unread > 0) rc += " Unread"; if (item.auxcounter > 0) rc += " Has_Aux"; if (item.markedcounter > 0) rc += " Has_Marked"; if (item.publishedcounter > 0) rc += " Has_Published"; if (item.updates_disabled > 0) rc += " UpdatesDisabled"; - if (item.bare_id >= App.LABEL_BASE_INDEX && item.bare_id < 0 && !is_cat || item.bare_id == Feeds.FEED_ARCHIVED && !is_cat) rc += " Special"; - if (item.bare_id == Feeds.CATEGORY_SPECIAL && is_cat) rc += " AlwaysVisible"; + if (item.bare_id >= App.LABEL_BASE_INDEX && item.bare_id < 0 && !is_cat || item.bare_id === Feeds.FEED_ARCHIVED && !is_cat) rc += " Special"; + if (item.bare_id === Feeds.CATEGORY_SPECIAL && is_cat) rc += " AlwaysVisible"; if (item.bare_id < App.LABEL_BASE_INDEX) rc += " Label"; return rc; @@ -266,7 +268,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co const items = this.model.store._arrayOfTopLevelItems; for (let i = 0; i < items.length; i++) { - if (String(items[i].id) == test_id) { + if (String(items[i].id) === test_id) { this.expandParentNodes(feed, is_cat, parents); } else { this.findNodeParentsAndExpandThem(feed, is_cat, items[i], []); @@ -276,13 +278,13 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co parents.push(root); for (let i = 0; i < root.items.length; i++) { - if (String(root.items[i].id) == test_id) { + if (String(root.items[i].id) === test_id) { this.expandParentNodes(feed, is_cat, parents); } else { this.findNodeParentsAndExpandThem(feed, is_cat, root.items[i], parents.slice(0)); } } - } else if (String(root.id) == test_id) { + } else if (String(root.id) === test_id) { this.expandParentNodes(feed, is_cat, parents.slice(0)); } } catch (e) { @@ -423,7 +425,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co const items = this.model.store._arrayOfAllItems; const start = items.indexOf(treeItem); - if (start != -1) { + if (start !== -1) { let item = this._nextTreeItemFromIndex(start, unread_only); // let's try again from the top @@ -469,7 +471,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co const items = this.model.store._arrayOfAllItems; const start = items.indexOf(treeItem); - if (start != -1) { + if (start !== -1) { let item = this._prevTreeItemFromIndex(start, unread_only); // wrap from the bottom @@ -490,7 +492,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co _itemsByIdentity["FEED:" + feed])[0]. getParent().item.bare_id[0]; - } catch (e) { + } catch { return false; } }, |