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

Enable the consistent-return ESLint rule

This rule is already enabled in mozilla-central, and helps ensure more consistent functions/methods, see https://searchfox.org/mozilla-central/rev/b9da45f63cb567244933c77b2c7e827a057d3f9b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js#119-120

Please see https://eslint.org/docs/rules/consistent-return for additional information.
This commit is contained in:
Jonas Jenwald 2019-05-10 12:54:06 +02:00
parent ca2fee3d51
commit 173fbef05b
26 changed files with 105 additions and 55 deletions

View file

@ -198,7 +198,7 @@ let PDFViewerApplication = {
async _parseHashParameters() {
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION') &&
!AppOptions.get('pdfBugEnabled')) {
return;
return undefined;
}
const waitOn = [];
@ -576,7 +576,7 @@ let PDFViewerApplication = {
errorWrapper.setAttribute('hidden', 'true');
if (!this.pdfLoadingTask) {
return;
return undefined;
}
let promise = this.pdfLoadingTask.destroy();
@ -681,7 +681,7 @@ let PDFViewerApplication = {
this.load(pdfDocument);
}, (exception) => {
if (loadingTask !== this.pdfLoadingTask) {
return; // Ignore errors for previously opened PDF files.
return undefined; // Ignore errors for previously opened PDF files.
}
let message = exception && exception.message;

View file

@ -58,8 +58,8 @@ class DownloadManager {
downloadData(data, filename, contentType) {
if (navigator.msSaveBlob) { // IE10 and above
return navigator.msSaveBlob(new Blob([data], { type: contentType, }),
filename);
navigator.msSaveBlob(new Blob([data], { type: contentType, }), filename);
return;
}
let blobUrl = createObjectURL(data, contentType,
this.disableCreateObjectURL);

View file

@ -221,6 +221,7 @@ function isLeftMouseReleased(event) {
// Safari 6.0+
return event.which === 0;
}
return false;
}
export {

View file

@ -90,7 +90,7 @@ class PasswordPrompt {
let password = this.input.value;
if (password && password.length > 0) {
this.close();
return this.updateCallback(password);
this.updateCallback(password);
}
}

View file

@ -256,10 +256,10 @@ class PDFDocumentProperties {
/**
* @private
*/
_parseFileSize(fileSize = 0) {
async _parseFileSize(fileSize = 0) {
let kb = fileSize / 1024;
if (!kb) {
return Promise.resolve(undefined);
return undefined;
} else if (kb < 1024) {
return this.l10n.get('document_properties_kb', {
size_kb: (+kb.toPrecision(3)).toLocaleString(),
@ -275,9 +275,9 @@ class PDFDocumentProperties {
/**
* @private
*/
_parsePageSize(pageSizeInches, pagesRotation) {
async _parsePageSize(pageSizeInches, pagesRotation) {
if (!pageSizeInches) {
return Promise.resolve(undefined);
return undefined;
}
// Take the viewer rotation into account as well; compare with Adobe Reader.
if (pagesRotation % 180 !== 0) {
@ -362,15 +362,15 @@ class PDFDocumentProperties {
/**
* @private
*/
_parseDate(inputDate) {
async _parseDate(inputDate) {
const dateObject = PDFDateString.toDateObject(inputDate);
if (dateObject) {
const dateString = dateObject.toLocaleDateString();
const timeString = dateObject.toLocaleTimeString();
return this.l10n.get('document_properties_date_string',
{ date: dateString, time: timeString, },
'{{date}}, {{time}}');
if (!dateObject) {
return undefined;
}
return this.l10n.get('document_properties_date_string', {
date: dateObject.toLocaleDateString(),
time: dateObject.toLocaleTimeString(),
}, '{{date}}, {{time}}');
}
/**

View file

@ -292,6 +292,7 @@ window.addEventListener('keydown', function(event) {
}
}, true);
if (hasAttachEvent) {
// eslint-disable-next-line consistent-return
document.attachEvent('onkeydown', function(event) {
event = event || window.event;
if (event.keyCode === /* P= */ 80 && event.ctrlKey) {