mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Fix the linting errors, from the Prettier auto-formatting, that ESLint --fix
couldn't handle
This patch makes the follow changes: - Remove no longer necessary inline `// eslint-disable-...` comments. - Fix `// eslint-disable-...` comments that Prettier moved down, thus causing new linting errors. - Concatenate strings which now fit on just one line. - Fix comments that are now too long. - Finally, and most importantly, adjust comments that Prettier moved down, since the new positions often is confusing or outright wrong.
This commit is contained in:
parent
de36b2aaba
commit
a63f7ad486
46 changed files with 179 additions and 219 deletions
27
web/app.js
27
web/app.js
|
@ -1103,7 +1103,8 @@ let PDFViewerApplication = {
|
|||
`${values.scrollLeft},${values.scrollTop}`;
|
||||
|
||||
rotation = parseInt(values.rotation, 10);
|
||||
// Always let user preferences take precedence over the view history.
|
||||
// Always let user preferences take precedence over the view
|
||||
// history.
|
||||
if (sidebarView === SidebarView.UNKNOWN) {
|
||||
sidebarView = values.sidebarView | 0;
|
||||
}
|
||||
|
@ -1135,11 +1136,13 @@ let PDFViewerApplication = {
|
|||
pdfViewer.focus();
|
||||
}
|
||||
|
||||
// For documents with different page sizes, once all pages are resolved,
|
||||
// ensure that the correct location becomes visible on load.
|
||||
// For documents with different page sizes, once all pages are
|
||||
// resolved, ensure that the correct location becomes visible on
|
||||
// load.
|
||||
// (To reduce the risk, in very large and/or slow loading documents,
|
||||
// that the location changes *after* the user has started interacting
|
||||
// with the viewer, wait for either `pagesPromise` or a timeout.)
|
||||
// that the location changes *after* the user has started
|
||||
// interacting with the viewer, wait for either `pagesPromise` or
|
||||
// a timeout.)
|
||||
await Promise.race([
|
||||
pagesPromise,
|
||||
new Promise(resolve => {
|
||||
|
@ -1283,8 +1286,9 @@ let PDFViewerApplication = {
|
|||
// Ghostscript can produce invalid 'dc:title' Metadata entries:
|
||||
// - The title may be "Untitled" (fixes bug 1031612).
|
||||
// - The title may contain incorrectly encoded characters, which thus
|
||||
// looks broken, hence we ignore the Metadata entry when it contains
|
||||
// characters from the Specials Unicode block (fixes bug 1605526).
|
||||
// looks broken, hence we ignore the Metadata entry when it
|
||||
// contains characters from the Specials Unicode block
|
||||
// (fixes bug 1605526).
|
||||
if (
|
||||
metadataTitle !== "Untitled" &&
|
||||
!/[\uFFF0-\uFFFF]/g.test(metadataTitle)
|
||||
|
@ -1481,7 +1485,7 @@ let PDFViewerApplication = {
|
|||
.get(
|
||||
"printing_not_supported",
|
||||
null,
|
||||
"Warning: Printing is not fully supported by " + "this browser."
|
||||
"Warning: Printing is not fully supported by this browser."
|
||||
)
|
||||
.then(printMessage => {
|
||||
this.error(printMessage);
|
||||
|
@ -2555,14 +2559,13 @@ function webViewerKeyDown(evt) {
|
|||
(curElement && curElement.isContentEditable)
|
||||
) {
|
||||
// Make sure that the secondary toolbar is closed when Escape is pressed.
|
||||
if (evt.keyCode !== 27) {
|
||||
// 'Esc'
|
||||
if (evt.keyCode !== /* Esc = */ 27) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// No control key pressed at all.
|
||||
if (cmd === 0) {
|
||||
// no control key pressed at all.
|
||||
let turnPage = 0,
|
||||
turnOnlyIfPageFit = false;
|
||||
switch (evt.keyCode) {
|
||||
|
@ -2680,8 +2683,8 @@ function webViewerKeyDown(evt) {
|
|||
}
|
||||
}
|
||||
|
||||
// shift-key
|
||||
if (cmd === 4) {
|
||||
// shift-key
|
||||
switch (evt.keyCode) {
|
||||
case 13: // enter key
|
||||
case 32: // spacebar
|
||||
|
|
|
@ -22,7 +22,7 @@ import { GenericL10n } from "./genericl10n";
|
|||
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {
|
||||
throw new Error(
|
||||
'Module "pdfjs-web/chromecom" shall not be used outside ' + "CHROME build."
|
||||
'Module "pdfjs-web/chromecom" shall not be used outside CHROME build.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -178,11 +178,9 @@ function requestAccessToLocalFile(fileUrl, overlayManager, callback) {
|
|||
// Use Chrome's definition of UI language instead of PDF.js's #lang=...,
|
||||
// because the shown string should match the UI at chrome://extensions.
|
||||
// These strings are from chrome/app/resources/generated_resources_*.xtb.
|
||||
/* eslint-disable no-unexpected-multiline */
|
||||
let i18nFileAccessLabel = PDFJSDev.json(
|
||||
"$ROOT/web/chrome-i18n-allow-access-to-file-urls.json"
|
||||
)[chrome.i18n.getUILanguage && chrome.i18n.getUILanguage()];
|
||||
/* eslint-enable no-unexpected-multiline */
|
||||
|
||||
if (i18nFileAccessLabel) {
|
||||
document.getElementById(
|
||||
|
|
|
@ -217,7 +217,7 @@ class MozL10n {
|
|||
// Avoid attempting to needlessly reset the zoom level *twice* in a row,
|
||||
// when using the `Ctrl + 0` keyboard shortcut.
|
||||
if (
|
||||
type === "zoomreset" && // eslint-disable-next-line max-len
|
||||
type === "zoomreset" &&
|
||||
PDFViewerApplication.pdfViewer.currentScaleValue === DEFAULT_SCALE_VALUE
|
||||
) {
|
||||
return;
|
||||
|
|
|
@ -119,8 +119,7 @@ class OverlayManager {
|
|||
* @private
|
||||
*/
|
||||
_keyDown(evt) {
|
||||
if (this._active && evt.keyCode === 27) {
|
||||
// Esc key.
|
||||
if (this._active && evt.keyCode === /* Esc = */ 27) {
|
||||
this._closeThroughCaller();
|
||||
evt.preventDefault();
|
||||
}
|
||||
|
|
|
@ -52,8 +52,7 @@ class PasswordPrompt {
|
|||
this.submitButton.addEventListener("click", this.verify.bind(this));
|
||||
this.cancelButton.addEventListener("click", this.close.bind(this));
|
||||
this.input.addEventListener("keydown", e => {
|
||||
if (e.keyCode === 13) {
|
||||
// Enter key
|
||||
if (e.keyCode === /* Enter = */ 13) {
|
||||
this.verify();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -95,8 +95,8 @@ class PDFAttachmentViewer {
|
|||
} else if (PDFJSDev.test("CHROME")) {
|
||||
// In the Chrome extension, the URL is rewritten using the history API
|
||||
// in viewer.js, so an absolute URL must be generated.
|
||||
// eslint-disable-next-line no-undef
|
||||
viewerUrl =
|
||||
// eslint-disable-next-line no-undef
|
||||
chrome.runtime.getURL("/content/web/viewer.html") +
|
||||
"?file=" +
|
||||
encodeURIComponent(blobUrl + "#" + filename);
|
||||
|
|
|
@ -86,9 +86,8 @@ class PDFCursorTools {
|
|||
}
|
||||
};
|
||||
|
||||
switch (
|
||||
tool // Enable the new cursor tool.
|
||||
) {
|
||||
// Enable the new cursor tool.
|
||||
switch (tool) {
|
||||
case CursorTool.SELECT:
|
||||
disableActiveTool();
|
||||
break;
|
||||
|
|
|
@ -202,13 +202,13 @@ class PDFFindController {
|
|||
this._pageMatches = [];
|
||||
this._pageMatchesLength = [];
|
||||
this._state = null;
|
||||
// Currently selected match.
|
||||
this._selected = {
|
||||
// Currently selected match.
|
||||
pageIdx: -1,
|
||||
matchIdx: -1,
|
||||
};
|
||||
// Where the find algorithm currently is in the document.
|
||||
this._offset = {
|
||||
// Where the find algorithm currently is in the document.
|
||||
pageIdx: null,
|
||||
matchIdx: null,
|
||||
wrapped: false,
|
||||
|
|
|
@ -352,8 +352,8 @@ class PDFHistory {
|
|||
let newUrl;
|
||||
if (this._updateUrl && destination && destination.hash) {
|
||||
const baseUrl = document.location.href.split("#")[0];
|
||||
// Prevent errors in Firefox.
|
||||
if (!baseUrl.startsWith("file://")) {
|
||||
// Prevent errors in Firefox.
|
||||
newUrl = `${baseUrl}#${destination.hash}`;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,8 +215,8 @@ class PDFPageView {
|
|||
|
||||
update(scale, rotation) {
|
||||
this.scale = scale || this.scale;
|
||||
// The rotation may be zero.
|
||||
if (typeof rotation !== "undefined") {
|
||||
// The rotation may be zero.
|
||||
this.rotation = rotation;
|
||||
}
|
||||
|
||||
|
|
|
@ -300,7 +300,8 @@ window.addEventListener(
|
|||
) {
|
||||
window.print();
|
||||
|
||||
// The (browser) print dialog cannot be prevented from being shown in IE11.
|
||||
// The (browser) print dialog cannot be prevented from being shown in
|
||||
// IE11.
|
||||
event.preventDefault();
|
||||
if (event.stopImmediatePropagation) {
|
||||
event.stopImmediatePropagation();
|
||||
|
|
|
@ -389,8 +389,8 @@ class PDFSidebar {
|
|||
removeNotification(view);
|
||||
return;
|
||||
}
|
||||
// Remove all sidebar notifications on reset.
|
||||
for (view in SidebarView) {
|
||||
// Remove all sidebar notifications on reset.
|
||||
removeNotification(SidebarView[view]);
|
||||
}
|
||||
|
||||
|
|
|
@ -250,11 +250,11 @@ class Toolbar {
|
|||
const width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
|
||||
select.setAttribute(
|
||||
"style",
|
||||
"min-width: " + (width + SCALE_SELECT_PADDING) + "px;"
|
||||
`min-width: ${width + SCALE_SELECT_PADDING}px;`
|
||||
);
|
||||
container.setAttribute(
|
||||
"style",
|
||||
"min-width: " + width + "px; " + "max-width: " + width + "px;"
|
||||
`min-width: ${width}px; max-width: ${width}px;`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue