1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 08:08:07 +02:00

Enable the no-else-return ESLint rule

Using `else` after `return` is not necessary, and can often lead to unnecessarily cluttered code. By using the `no-else-return` rule in ESLint we can avoid this pattern, see http://eslint.org/docs/rules/no-else-return.
This commit is contained in:
Jonas Jenwald 2016-12-16 13:05:33 +01:00
parent 049d7fa277
commit 4046d67fde
19 changed files with 67 additions and 79 deletions

View file

@ -202,9 +202,8 @@ if (typeof PDFJS === 'undefined') {
get: function xmlHttpRequestResponseGet() {
if (this.responseType === 'arraybuffer') {
return new Uint8Array(new VBArray(this.responseBody).toArray());
} else {
return this.responseText;
}
return this.responseText;
}
});
return;

View file

@ -178,12 +178,11 @@ var PDFDocumentProperties = (function PDFDocumentPropertiesClosure() {
size_kb: (+kb.toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, '{{size_kb}} KB ({{size_b}} bytes)');
} else {
return mozL10n.get('document_properties_mb', {
size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, '{{size_mb}} MB ({{size_b}} bytes)');
}
return mozL10n.get('document_properties_mb', {
size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, '{{size_mb}} MB ({{size_b}} bytes)');
},
/**

View file

@ -399,22 +399,21 @@ var PDFFindController = (function PDFFindControllerClosure() {
offset.matchIdx = (previous ? numMatches - 1 : 0);
this.updateMatch(true);
return true;
} else {
// No matches, so attempt to search the next page.
this.advanceOffsetPage(previous);
if (offset.wrapped) {
offset.matchIdx = null;
if (this.pagesToSearch < 0) {
// No point in wrapping again, there were no matches.
this.updateMatch(false);
// while matches were not found, searching for a page
// with matches should nevertheless halt.
return true;
}
}
// Matches were not found (and searching is not done).
return false;
}
// No matches, so attempt to search the next page.
this.advanceOffsetPage(previous);
if (offset.wrapped) {
offset.matchIdx = null;
if (this.pagesToSearch < 0) {
// No point in wrapping again, there were no matches.
this.updateMatch(false);
// while matches were not found, searching for a page
// with matches should nevertheless halt.
return true;
}
}
// Matches were not found (and searching is not done).
return false;
},
/**

View file

@ -284,9 +284,8 @@
this.nextHashParam = null;
this.updatePreviousBookmark = true;
return;
} else {
this.nextHashParam = null;
}
this.nextHashParam = null;
}
if (params.hash) {

View file

@ -624,7 +624,7 @@ var PDFPageView = (function PDFPageViewClosure() {
onRenderContinue: function (cont) { },
cancel: function () { },
};
} else {
} else { // eslint-disable-line no-else-return
var cancelled = false;
var ensureNotCancelled = function () {
if (cancelled) {

View file

@ -833,14 +833,13 @@ var PDFViewer = (function pdfViewer() {
_getVisiblePages: function () {
if (!this.isInPresentationMode) {
return getVisibleElements(this.container, this._pages, true);
} else {
// The algorithm in getVisibleElements doesn't work in all browsers and
// configurations when presentation mode is active.
var visible = [];
var currentPage = this._pages[this._currentPageNumber - 1];
visible.push({ id: currentPage.id, view: currentPage });
return { first: currentPage, last: currentPage, views: visible };
}
// The algorithm in getVisibleElements doesn't work in all browsers and
// configurations when presentation mode is active.
var visible = [];
var currentPage = this._pages[this._currentPageNumber - 1];
visible.push({ id: currentPage.id, view: currentPage });
return { first: currentPage, last: currentPage, views: visible };
},
cleanup: function () {

View file

@ -280,12 +280,14 @@ function approximateFraction(x) {
a = p; b = q;
}
}
var result;
// Select closest of the neighbours to x.
if (x_ - a / b < c / d - x_) {
return x_ === x ? [a, b] : [b, a];
result = x_ === x ? [a, b] : [b, a];
} else {
return x_ === x ? [c, d] : [d, c];
result = x_ === x ? [c, d] : [d, c];
}
return result;
}
function roundToDivide(x, div) {