From 9e3f7ac7faa44df0337fbace42efcda447c495ed Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Thu, 6 Dec 2018 14:02:39 +0100 Subject: [PATCH] Manually fix remaining ESLint errors --- examples/acroforms/acroforms.js | 3 ++- examples/browserify/gulpfile.js | 8 +++++--- examples/image_decoders/jpeg_viewer.js | 13 +++++++------ examples/mobile-viewer/viewer.js | 5 +++-- examples/node/domstubs.js | 6 +++++- examples/node/pdf2png/pdf2png.js | 6 ++++-- examples/node/pdf2svg.js | 11 ++++++----- examples/webpack/.eslintrc | 9 +++++++++ examples/webpack/webpack.config.js | 2 +- 9 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 examples/webpack/.eslintrc diff --git a/examples/acroforms/acroforms.js b/examples/acroforms/acroforms.js index 795e992b4..1f48233d7 100644 --- a/examples/acroforms/acroforms.js +++ b/examples/acroforms/acroforms.js @@ -38,7 +38,8 @@ loadingTask.promise.then(function(doc) { id: pageNum, scale: DEFAULT_SCALE, defaultViewport: pdfPage.getViewport(DEFAULT_SCALE), - annotationLayerFactory: new pdfjsViewer.DefaultAnnotationLayerFactory(), + annotationLayerFactory: + new pdfjsViewer.DefaultAnnotationLayerFactory(), renderInteractiveForms: true, }); diff --git a/examples/browserify/gulpfile.js b/examples/browserify/gulpfile.js index d8fdb05a4..a6230c880 100644 --- a/examples/browserify/gulpfile.js +++ b/examples/browserify/gulpfile.js @@ -24,9 +24,11 @@ gulp.task('build-worker', function() { return browserify(workerSrc, { output: TMP_FILE_PREFIX + 'worker.tmp', }) .bundle() .pipe(source(TMP_FILE_PREFIX + 'worker.tmp')) - .pipe(streamify(uglify({ compress: { - sequences: false, // Chrome has issue with the generated code if true - }, }))) + .pipe(streamify(uglify({ + compress: { + sequences: false, // Chrome has issue with the generated code if true + }, + }))) .pipe(rename('pdf.worker.bundle.js')) .pipe(gulp.dest(OUTPUT_PATH)); }); diff --git a/examples/image_decoders/jpeg_viewer.js b/examples/image_decoders/jpeg_viewer.js index 7f700210b..5e2eae152 100644 --- a/examples/image_decoders/jpeg_viewer.js +++ b/examples/image_decoders/jpeg_viewer.js @@ -68,11 +68,12 @@ var jpegData = jpegImage.getData({ // var imageData = jpegCtx.createImageData(width, height); var imageBytes = imageData.data; -for (var i = 0, j = 0, ii = width * height * 4; i < ii;) { - imageBytes[i++] = jpegData[j++]; - imageBytes[i++] = jpegData[j++]; - imageBytes[i++] = jpegData[j++]; - imageBytes[i++] = 255; +for (var j = 0, k = 0, jj = width * height * 4; j < jj;) { + imageBytes[j++] = jpegData[k++]; + imageBytes[j++] = jpegData[k++]; + imageBytes[j++] = jpegData[k++]; + imageBytes[j++] = 255; } -jpegCanvas.width = width, jpegCanvas.height = height; +jpegCanvas.width = width; +jpegCanvas.height = height; jpegCtx.putImageData(imageData, 0, 0); diff --git a/examples/mobile-viewer/viewer.js b/examples/mobile-viewer/viewer.js index 9106e0a0a..5a28dd401 100644 --- a/examples/mobile-viewer/viewer.js +++ b/examples/mobile-viewer/viewer.js @@ -339,8 +339,9 @@ var PDFViewerApplication = { function() { PDFViewerApplication.page = (this.value | 0); - // Ensure that the page number input displays the correct value, even if the - // value entered by the user was invalid (e.g. a floating point number). + // Ensure that the page number input displays the correct value, + // even if the value entered by the user was invalid + // (e.g. a floating point number). if (this.value !== PDFViewerApplication.page.toString()) { this.value = PDFViewerApplication.page; } diff --git a/examples/node/domstubs.js b/examples/node/domstubs.js index 174faad32..8671022e8 100644 --- a/examples/node/domstubs.js +++ b/examples/node/domstubs.js @@ -96,7 +96,7 @@ DOMElement.prototype = { appendChild: function DOMElement_appendChild(element) { var childNodes = this.childNodes; - if (childNodes.indexOf(element) === -1) { + if (!childNodes.includes(element)) { childNodes.push(element); } }, @@ -152,10 +152,12 @@ DOMElementSerializer.prototype = { return ' xmlns:xlink="http://www.w3.org/1999/xlink"' + ' xmlns:svg="http://www.w3.org/2000/svg"'; } + /* falls through */ case 2: // Initialize variables for looping over attributes. ++this._state; this._loopIndex = 0; this._attributeKeys = Object.keys(node.attributes); + /* falls through */ case 3: // Serialize any attributes and end opening tag. if (this._loopIndex < this._attributeKeys.length) { var name = this._attributeKeys[this._loopIndex++]; @@ -170,6 +172,7 @@ DOMElementSerializer.prototype = { } ++this._state; this._loopIndex = 0; + /* falls through */ case 5: // Serialize child nodes (only for non-tspan/style elements). var value; while (true) { @@ -186,6 +189,7 @@ DOMElementSerializer.prototype = { break; } } + /* falls through */ case 6: // Ending tag. ++this._state; return ''; diff --git a/examples/node/pdf2png/pdf2png.js b/examples/node/pdf2png/pdf2png.js index d70f5122d..2fa7635ce 100644 --- a/examples/node/pdf2png/pdf2png.js +++ b/examples/node/pdf2png/pdf2png.js @@ -66,7 +66,8 @@ loadingTask.promise.then(function(pdfDocument) { // Render the page on a Node canvas with 100% scale. var viewport = page.getViewport(1.0); var canvasFactory = new NodeCanvasFactory(); - var canvasAndContext = canvasFactory.create(viewport.width, viewport.height); + var canvasAndContext = + canvasFactory.create(viewport.width, viewport.height); var renderContext = { canvasContext: canvasAndContext.context, viewport: viewport, @@ -81,7 +82,8 @@ loadingTask.promise.then(function(pdfDocument) { if (error) { console.error('Error: ' + error); } else { - console.log('Finished converting first page of PDF file to a PNG image.'); + console.log( + 'Finished converting first page of PDF file to a PNG image.'); } }); }); diff --git a/examples/node/pdf2svg.js b/examples/node/pdf2svg.js index 546c494e2..3ac42f80c 100644 --- a/examples/node/pdf2svg.js +++ b/examples/node/pdf2svg.js @@ -108,11 +108,12 @@ loadingTask.promise.then(function(doc) { var svgGfx = new pdfjsLib.SVGGraphics(page.commonObjs, page.objs); svgGfx.embedFonts = true; return svgGfx.getSVG(opList, viewport).then(function (svg) { - return writeSvgToFile(svg, getFilePathForPage(pageNum)).then(function () { - console.log('Page: ' + pageNum); - }, function(err) { - console.log('Error: ' + err); - }); + return writeSvgToFile(svg, getFilePathForPage(pageNum)) + .then(function () { + console.log('Page: ' + pageNum); + }, function(err) { + console.log('Error: ' + err); + }); }); }); }); diff --git a/examples/webpack/.eslintrc b/examples/webpack/.eslintrc new file mode 100644 index 000000000..46f120c21 --- /dev/null +++ b/examples/webpack/.eslintrc @@ -0,0 +1,9 @@ +{ + "extends": [ + "../.eslintrc" + ], + + "env": { + "node": true, + }, +} diff --git a/examples/webpack/webpack.config.js b/examples/webpack/webpack.config.js index ab2796aea..69ff53edc 100644 --- a/examples/webpack/webpack.config.js +++ b/examples/webpack/webpack.config.js @@ -1,4 +1,4 @@ -var webpack = require('webpack'); +var webpack = require('webpack'); // eslint-disable-line no-unused-vars var path = require('path'); module.exports = {