Skip to content

Commit 50bc4a1

Browse files
Merge pull request #11809 from Snuffleupagus/Prettier-2
Update Prettier to version 2.0
2 parents a4dd081 + 426945b commit 50bc4a1

File tree

145 files changed

+2004
-2008
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+2004
-2008
lines changed

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"arrowParens": "avoid",
23
"endOfLine": "lf",
34
"printWidth": 80,
45
"semi": true,

examples/acroforms/acroforms.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ var eventBus = new pdfjsViewer.EventBus();
2727

2828
// Fetch the PDF document from the URL using promises.
2929
var loadingTask = pdfjsLib.getDocument(DEFAULT_URL);
30-
loadingTask.promise.then(function(doc) {
30+
loadingTask.promise.then(function (doc) {
3131
// Use a promise to fetch and render the next page.
3232
var promise = Promise.resolve();
3333

3434
for (var i = 1; i <= doc.numPages; i++) {
3535
promise = promise.then(
36-
function(pageNum) {
37-
return doc.getPage(pageNum).then(function(pdfPage) {
36+
function (pageNum) {
37+
return doc.getPage(pageNum).then(function (pdfPage) {
3838
// Create the page view.
3939
var pdfPageView = new pdfjsViewer.PDFPageView({
4040
container: container,

examples/browserify/gulpfile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var source = require("vinyl-source-stream");
88
var OUTPUT_PATH = "../../build/browserify";
99
var TMP_FILE_PREFIX = "../../build/browserify_";
1010

11-
gulp.task("build-bundle", function() {
11+
gulp.task("build-bundle", function () {
1212
return browserify("main.js", { output: TMP_FILE_PREFIX + "main.tmp" })
1313
.ignore(require.resolve("pdfjs-dist/build/pdf.worker")) // Reducing size
1414
.bundle()
@@ -18,7 +18,7 @@ gulp.task("build-bundle", function() {
1818
.pipe(gulp.dest(OUTPUT_PATH));
1919
});
2020

21-
gulp.task("build-worker", function() {
21+
gulp.task("build-worker", function () {
2222
// We can create our own viewer (see worker.js) or use already defined one.
2323
var workerSrc = require.resolve("pdfjs-dist/build/pdf.worker.entry");
2424
return browserify(workerSrc, { output: TMP_FILE_PREFIX + "worker.tmp" })

examples/browserify/main.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ pdfjsLib.GlobalWorkerOptions.workerSrc =
1414
// Loading a document.
1515
var loadingTask = pdfjsLib.getDocument(pdfPath);
1616
loadingTask.promise
17-
.then(function(pdfDocument) {
17+
.then(function (pdfDocument) {
1818
// Request a first page
19-
return pdfDocument.getPage(1).then(function(pdfPage) {
19+
return pdfDocument.getPage(1).then(function (pdfPage) {
2020
// Display page on the existing canvas with 100% scale.
2121
var viewport = pdfPage.getViewport({ scale: 1.0 });
2222
var canvas = document.getElementById("theCanvas");
@@ -30,6 +30,6 @@ loadingTask.promise
3030
return renderTask.promise;
3131
});
3232
})
33-
.catch(function(reason) {
33+
.catch(function (reason) {
3434
console.error("Error: " + reason);
3535
});

examples/components/pageviewer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ var loadingTask = pdfjsLib.getDocument({
4343
cMapUrl: CMAP_URL,
4444
cMapPacked: CMAP_PACKED,
4545
});
46-
loadingTask.promise.then(function(pdfDocument) {
46+
loadingTask.promise.then(function (pdfDocument) {
4747
// Document loaded, retrieving the page.
48-
return pdfDocument.getPage(PAGE_TO_VIEW).then(function(pdfPage) {
48+
return pdfDocument.getPage(PAGE_TO_VIEW).then(function (pdfPage) {
4949
// Creating the page view with default parameters.
5050
var pdfPageView = new pdfjsViewer.PDFPageView({
5151
container: container,

examples/components/simpleviewer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var pdfViewer = new pdfjsViewer.PDFViewer({
5555
});
5656
pdfLinkService.setViewer(pdfViewer);
5757

58-
eventBus.on("pagesinit", function() {
58+
eventBus.on("pagesinit", function () {
5959
// We can use pdfViewer now, e.g. let's change default scale.
6060
pdfViewer.currentScaleValue = "page-width";
6161

@@ -71,7 +71,7 @@ var loadingTask = pdfjsLib.getDocument({
7171
cMapUrl: CMAP_URL,
7272
cMapPacked: CMAP_PACKED,
7373
});
74-
loadingTask.promise.then(function(pdfDocument) {
74+
loadingTask.promise.then(function (pdfDocument) {
7575
// Document loaded, specifying document for the viewer and
7676
// the (optional) linkService.
7777
pdfViewer.setDocument(pdfDocument);

examples/components/singlepageviewer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var pdfSinglePageViewer = new pdfjsViewer.PDFSinglePageViewer({
5555
});
5656
pdfLinkService.setViewer(pdfSinglePageViewer);
5757

58-
eventBus.on("pagesinit", function() {
58+
eventBus.on("pagesinit", function () {
5959
// We can use pdfSinglePageViewer now, e.g. let's change default scale.
6060
pdfSinglePageViewer.currentScaleValue = "page-width";
6161

@@ -71,7 +71,7 @@ var loadingTask = pdfjsLib.getDocument({
7171
cMapUrl: CMAP_URL,
7272
cMapPacked: CMAP_PACKED,
7373
});
74-
loadingTask.promise.then(function(pdfDocument) {
74+
loadingTask.promise.then(function (pdfDocument) {
7575
// Document loaded, specifying document for the viewer and
7676
// the (optional) linkService.
7777
pdfSinglePageViewer.setDocument(pdfDocument);

examples/mobile-viewer/viewer.js

+30-26
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ var PDFViewerApplication = {
4747
* @returns {Promise} - Returns the promise, which is resolved when document
4848
* is opened.
4949
*/
50-
open: function(params) {
50+
open: function (params) {
5151
if (this.pdfLoadingTask) {
5252
// We need to destroy already opened document
5353
return this.close().then(
54-
function() {
54+
function () {
5555
// ... and repeat the open() call.
5656
return this.open(params);
5757
}.bind(this)
@@ -71,12 +71,12 @@ var PDFViewerApplication = {
7171
});
7272
this.pdfLoadingTask = loadingTask;
7373

74-
loadingTask.onProgress = function(progressData) {
74+
loadingTask.onProgress = function (progressData) {
7575
self.progress(progressData.loaded / progressData.total);
7676
};
7777

7878
return loadingTask.promise.then(
79-
function(pdfDocument) {
79+
function (pdfDocument) {
8080
// Document loaded, specifying document for the viewer.
8181
self.pdfDocument = pdfDocument;
8282
self.pdfViewer.setDocument(pdfDocument);
@@ -86,7 +86,7 @@ var PDFViewerApplication = {
8686
self.loadingBar.hide();
8787
self.setTitleUsingMetadata(pdfDocument);
8888
},
89-
function(exception) {
89+
function (exception) {
9090
var message = exception && exception.message;
9191
var l10n = self.l10n;
9292
var loadingErrorMessage;
@@ -119,7 +119,7 @@ var PDFViewerApplication = {
119119
);
120120
}
121121

122-
loadingErrorMessage.then(function(msg) {
122+
loadingErrorMessage.then(function (msg) {
123123
self.error(msg, { message: message });
124124
});
125125
self.loadingBar.hide();
@@ -132,7 +132,7 @@ var PDFViewerApplication = {
132132
* @returns {Promise} - Returns the promise, which is resolved when all
133133
* destruction is completed.
134134
*/
135-
close: function() {
135+
close: function () {
136136
var errorWrapper = document.getElementById("errorWrapper");
137137
errorWrapper.setAttribute("hidden", "true");
138138

@@ -175,9 +175,9 @@ var PDFViewerApplication = {
175175
this.setTitle(title);
176176
},
177177

178-
setTitleUsingMetadata: function(pdfDocument) {
178+
setTitleUsingMetadata: function (pdfDocument) {
179179
var self = this;
180-
pdfDocument.getMetadata().then(function(data) {
180+
pdfDocument.getMetadata().then(function (data) {
181181
var info = data.info,
182182
metadata = data.metadata;
183183
self.documentInfo = info;
@@ -275,27 +275,27 @@ var PDFViewerApplication = {
275275
errorMessage.textContent = message;
276276

277277
var closeButton = document.getElementById("errorClose");
278-
closeButton.onclick = function() {
278+
closeButton.onclick = function () {
279279
errorWrapper.setAttribute("hidden", "true");
280280
};
281281

282282
var errorMoreInfo = document.getElementById("errorMoreInfo");
283283
var moreInfoButton = document.getElementById("errorShowMore");
284284
var lessInfoButton = document.getElementById("errorShowLess");
285-
moreInfoButton.onclick = function() {
285+
moreInfoButton.onclick = function () {
286286
errorMoreInfo.removeAttribute("hidden");
287287
moreInfoButton.setAttribute("hidden", "true");
288288
lessInfoButton.removeAttribute("hidden");
289289
errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
290290
};
291-
lessInfoButton.onclick = function() {
291+
lessInfoButton.onclick = function () {
292292
errorMoreInfo.setAttribute("hidden", "true");
293293
moreInfoButton.removeAttribute("hidden");
294294
lessInfoButton.setAttribute("hidden", "true");
295295
};
296296
moreInfoButton.removeAttribute("hidden");
297297
lessInfoButton.setAttribute("hidden", "true");
298-
Promise.all(moreInfoText).then(function(parts) {
298+
Promise.all(moreInfoText).then(function (parts) {
299299
errorMoreInfo.value = parts.join("\n");
300300
});
301301
},
@@ -369,29 +369,31 @@ var PDFViewerApplication = {
369369
});
370370
linkService.setHistory(this.pdfHistory);
371371

372-
document.getElementById("previous").addEventListener("click", function() {
372+
document.getElementById("previous").addEventListener("click", function () {
373373
PDFViewerApplication.page--;
374374
});
375375

376-
document.getElementById("next").addEventListener("click", function() {
376+
document.getElementById("next").addEventListener("click", function () {
377377
PDFViewerApplication.page++;
378378
});
379379

380-
document.getElementById("zoomIn").addEventListener("click", function() {
380+
document.getElementById("zoomIn").addEventListener("click", function () {
381381
PDFViewerApplication.zoomIn();
382382
});
383383

384-
document.getElementById("zoomOut").addEventListener("click", function() {
384+
document.getElementById("zoomOut").addEventListener("click", function () {
385385
PDFViewerApplication.zoomOut();
386386
});
387387

388-
document.getElementById("pageNumber").addEventListener("click", function() {
389-
this.select();
390-
});
388+
document
389+
.getElementById("pageNumber")
390+
.addEventListener("click", function () {
391+
this.select();
392+
});
391393

392394
document
393395
.getElementById("pageNumber")
394-
.addEventListener("change", function() {
396+
.addEventListener("change", function () {
395397
PDFViewerApplication.page = this.value | 0;
396398

397399
// Ensure that the page number input displays the correct value,
@@ -402,14 +404,14 @@ var PDFViewerApplication = {
402404
}
403405
});
404406

405-
eventBus.on("pagesinit", function() {
407+
eventBus.on("pagesinit", function () {
406408
// We can use pdfViewer now, e.g. let's change default scale.
407409
pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
408410
});
409411

410412
eventBus.on(
411413
"pagechanging",
412-
function(evt) {
414+
function (evt) {
413415
var page = evt.pageNumber;
414416
var numPages = PDFViewerApplication.pagesCount;
415417

@@ -424,7 +426,7 @@ var PDFViewerApplication = {
424426

425427
document.addEventListener(
426428
"DOMContentLoaded",
427-
function() {
429+
function () {
428430
PDFViewerApplication.initUI();
429431
},
430432
true
@@ -433,13 +435,15 @@ document.addEventListener(
433435
(function animationStartedClosure() {
434436
// The offsetParent is not set until the PDF.js iframe or object is visible.
435437
// Waiting for first animation.
436-
PDFViewerApplication.animationStartedPromise = new Promise(function(resolve) {
438+
PDFViewerApplication.animationStartedPromise = new Promise(function (
439+
resolve
440+
) {
437441
window.requestAnimationFrame(resolve);
438442
});
439443
})();
440444

441445
// We need to delay opening until all HTML is loaded.
442-
PDFViewerApplication.animationStartedPromise.then(function() {
446+
PDFViewerApplication.animationStartedPromise.then(function () {
443447
PDFViewerApplication.open({
444448
url: DEFAULT_URL,
445449
});

examples/node/domstubs.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function DOMElement(name) {
5858
if (name === "style") {
5959
this.sheet = {
6060
cssRules: [],
61-
insertRule: function(rule) {
61+
insertRule: function (rule) {
6262
this.cssRules.push(rule);
6363
},
6464
};
@@ -226,16 +226,16 @@ const document = {
226226
return this;
227227
},
228228

229-
createElementNS: function(NS, element) {
229+
createElementNS: function (NS, element) {
230230
var elObject = new DOMElement(element);
231231
return elObject;
232232
},
233233

234-
createElement: function(element) {
234+
createElement: function (element) {
235235
return this.createElementNS("", element);
236236
},
237237

238-
getElementsByTagName: function(element) {
238+
getElementsByTagName: function (element) {
239239
if (element === "head") {
240240
return [this.head || (this.head = new DOMElement("head"))];
241241
}
@@ -264,14 +264,14 @@ exports.Image = Image;
264264

265265
var exported_symbols = Object.keys(exports);
266266

267-
exports.setStubs = function(namespace) {
268-
exported_symbols.forEach(function(key) {
267+
exports.setStubs = function (namespace) {
268+
exported_symbols.forEach(function (key) {
269269
console.assert(!(key in namespace), "property should not be set: " + key);
270270
namespace[key] = exports[key];
271271
});
272272
};
273-
exports.unsetStubs = function(namespace) {
274-
exported_symbols.forEach(function(key) {
273+
exports.unsetStubs = function (namespace) {
274+
exported_symbols.forEach(function (key) {
275275
console.assert(key in namespace, "property should be set: " + key);
276276
delete namespace[key];
277277
});

0 commit comments

Comments
 (0)