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.
This commit is contained in:
Jonas Jenwald 2019-12-27 00:32:40 +01:00
parent 5d14e68bec
commit d9a5d50664
3 changed files with 10 additions and 11 deletions

View File

@ -1182,8 +1182,7 @@ const PDFViewerApplication = {
if (!labels || AppOptions.get("disablePageLabels")) { if (!labels || AppOptions.get("disablePageLabels")) {
return; return;
} }
let i = 0, const numLabels = labels.length;
numLabels = labels.length;
if (numLabels !== this.pagesCount) { if (numLabels !== this.pagesCount) {
console.error( console.error(
"The number of Page Labels does not match " + "The number of Page Labels does not match " +
@ -1191,6 +1190,7 @@ const PDFViewerApplication = {
); );
return; return;
} }
let i = 0;
// Ignore page labels that correspond to standard page numbering. // Ignore page labels that correspond to standard page numbering.
while (i < numLabels && labels[i] === (i + 1).toString()) { while (i < numLabels && labels[i] === (i + 1).toString()) {
i++; i++;
@ -2004,10 +2004,9 @@ function webViewerTextLayerRendered(evt) {
} }
} }
function webViewerPageMode(evt) { function webViewerPageMode({ mode }) {
// Handle the 'pagemode' hash parameter, see also `PDFLinkService_setHash`. // Handle the 'pagemode' hash parameter, see also `PDFLinkService_setHash`.
let mode = evt.mode, let view;
view;
switch (mode) { switch (mode) {
case "thumbs": case "thumbs":
view = SidebarView.THUMBS; view = SidebarView.THUMBS;

View File

@ -153,8 +153,8 @@ class PDFFindBar {
if (!this.findResultsCount) { if (!this.findResultsCount) {
return; // No UI control is provided. return; // No UI control is provided.
} }
let matchesCountMsg = "", const limit = MATCHES_COUNT_LIMIT;
limit = MATCHES_COUNT_LIMIT; let matchesCountMsg = "";
if (total > 0) { if (total > 0) {
if (total > limit) { if (total > limit) {

View File

@ -108,8 +108,8 @@ class PDFLinkService {
navigateTo(dest) { navigateTo(dest) {
const goToDestination = ({ namedDest, explicitDest }) => { const goToDestination = ({ namedDest, explicitDest }) => {
// Dest array looks like that: <page-ref> </XYZ|/FitXXX> <args..> // Dest array looks like that: <page-ref> </XYZ|/FitXXX> <args..>
let destRef = explicitDest[0], const destRef = explicitDest[0];
pageNumber; let pageNumber;
if (destRef instanceof Object) { if (destRef instanceof Object) {
pageNumber = this._cachedPageNumber(destRef); pageNumber = this._cachedPageNumber(destRef);
@ -405,8 +405,7 @@ function isValidExplicitDestination(dest) {
if (!Array.isArray(dest)) { if (!Array.isArray(dest)) {
return false; return false;
} }
let destLength = dest.length, const destLength = dest.length;
allowNull = true;
if (destLength < 2) { if (destLength < 2) {
return false; return false;
} }
@ -425,6 +424,7 @@ function isValidExplicitDestination(dest) {
if (!(typeof zoom === "object" && typeof zoom.name === "string")) { if (!(typeof zoom === "object" && typeof zoom.name === "string")) {
return false; return false;
} }
let allowNull = true;
switch (zoom.name) { switch (zoom.name) {
case "XYZ": case "XYZ":
if (destLength !== 5) { if (destLength !== 5) {