Manually fix remaining ESLint errors

This commit is contained in:
Wojciech Maj 2018-12-06 14:02:39 +01:00
parent ef1f255649
commit 9e3f7ac7fa
9 changed files with 42 additions and 21 deletions

View File

@ -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,
});

View File

@ -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));
});

View File

@ -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);

View File

@ -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;
}

View File

@ -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 '</' + node.nodeName + '>';

View File

@ -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.');
}
});
});

View File

@ -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);
});
});
});
});

View File

@ -0,0 +1,9 @@
{
"extends": [
"../.eslintrc"
],
"env": {
"node": true,
},
}

View File

@ -1,4 +1,4 @@
var webpack = require('webpack');
var webpack = require('webpack'); // eslint-disable-line no-unused-vars
var path = require('path');
module.exports = {