From d9a5d50664f0045a4110387a42d157a14404074e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 27 Dec 2019 00:32:40 +0100 Subject: [PATCH] Fix remaining linting errors, from enabling the `prefer-const` ESLint rule in the `web/` directory This covers the handful of cases that the `--fix` command couldn't deal with, and the changes aren't just fixing the linting errors but attempt to slightly improve the relevant code. --- web/app.js | 9 ++++----- web/pdf_find_bar.js | 4 ++-- web/pdf_link_service.js | 8 ++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/web/app.js b/web/app.js index 20031b10b..d876fc66e 100644 --- a/web/app.js +++ b/web/app.js @@ -1182,8 +1182,7 @@ const PDFViewerApplication = { if (!labels || AppOptions.get("disablePageLabels")) { return; } - let i = 0, - numLabels = labels.length; + const numLabels = labels.length; if (numLabels !== this.pagesCount) { console.error( "The number of Page Labels does not match " + @@ -1191,6 +1190,7 @@ const PDFViewerApplication = { ); return; } + let i = 0; // Ignore page labels that correspond to standard page numbering. while (i < numLabels && labels[i] === (i + 1).toString()) { i++; @@ -2004,10 +2004,9 @@ function webViewerTextLayerRendered(evt) { } } -function webViewerPageMode(evt) { +function webViewerPageMode({ mode }) { // Handle the 'pagemode' hash parameter, see also `PDFLinkService_setHash`. - let mode = evt.mode, - view; + let view; switch (mode) { case "thumbs": view = SidebarView.THUMBS; diff --git a/web/pdf_find_bar.js b/web/pdf_find_bar.js index c71dfe9d5..1fa73768f 100644 --- a/web/pdf_find_bar.js +++ b/web/pdf_find_bar.js @@ -153,8 +153,8 @@ class PDFFindBar { if (!this.findResultsCount) { return; // No UI control is provided. } - let matchesCountMsg = "", - limit = MATCHES_COUNT_LIMIT; + const limit = MATCHES_COUNT_LIMIT; + let matchesCountMsg = ""; if (total > 0) { if (total > limit) { diff --git a/web/pdf_link_service.js b/web/pdf_link_service.js index a8d2359d9..bf4116625 100644 --- a/web/pdf_link_service.js +++ b/web/pdf_link_service.js @@ -108,8 +108,8 @@ class PDFLinkService { navigateTo(dest) { const goToDestination = ({ namedDest, explicitDest }) => { // Dest array looks like that: - let destRef = explicitDest[0], - pageNumber; + const destRef = explicitDest[0]; + let pageNumber; if (destRef instanceof Object) { pageNumber = this._cachedPageNumber(destRef); @@ -405,8 +405,7 @@ function isValidExplicitDestination(dest) { if (!Array.isArray(dest)) { return false; } - let destLength = dest.length, - allowNull = true; + const destLength = dest.length; if (destLength < 2) { return false; } @@ -425,6 +424,7 @@ function isValidExplicitDestination(dest) { if (!(typeof zoom === "object" && typeof zoom.name === "string")) { return false; } + let allowNull = true; switch (zoom.name) { case "XYZ": if (destLength !== 5) {