From 326a91d19a7a3129235f8c4c67a9404d8b31c973 Mon Sep 17 00:00:00 2001 From: BJR Matos Date: Sun, 5 Jun 2016 19:23:18 -0500 Subject: [PATCH] [fix] eslint errors --- src/electron.js | 19 +++++++++++++++---- src/recipe.js | 3 +++ test/test.js | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/electron.js b/src/electron.js index f20420c..dbcdbb7 100644 --- a/src/electron.js +++ b/src/electron.js @@ -20,10 +20,10 @@ class Electron { tmpDir }; + let shouldAccessLocalFiles; + // filter undefined options - convertOptions = pick(convertOptions, (val) => { - return val !== undefined; - }); + convertOptions = pick(convertOptions, (val) => val !== undefined); this.reporter = reporter; @@ -49,24 +49,31 @@ class Electron { }); if (reporter.documentStore.model.entityTypes.TemplateType) { + // eslint-disable-next-line no-param-reassign reporter.documentStore.model.entityTypes.TemplateType.electron = { type: 'jsreport.ElectronType' }; } + shouldAccessLocalFiles = definition.options.hasOwnProperty('allowLocalFilesAccess') ? + definition.options.allowLocalFilesAccess : false; + if (!reporter.__electron_html_to__) { + // eslint-disable-next-line no-param-reassign reporter.__electron_html_to__ = Promises.promisify(electronConvert({ ...convertOptions, - allowLocalFilesAccess: definition.options.hasOwnProperty('allowLocalFilesAccess') ? definition.options.allowLocalFilesAccess : false + allowLocalFilesAccess: shouldAccessLocalFiles })); } } execute(request, response) { + // eslint-disable-next-line no-param-reassign request.template.electron = request.template.electron || {}; this.reporter.logger.debug('Electron Pdf recipe start.'); + // eslint-disable-next-line no-param-reassign request.template.recipe = 'html'; return recipe(this.reporter.__electron_html_to__, request, response); @@ -75,11 +82,15 @@ class Electron { export default function(reporter, definition) { if (!Object.keys(definition.options).length) { + // eslint-disable-next-line no-param-reassign definition.options = reporter.options.electron || {}; } + // eslint-disable-next-line no-param-reassign definition.options.strategy = definition.options.strategy || 'dedicated-process'; + // eslint-disable-next-line no-param-reassign definition.options.tmpDir = reporter.options.tempDirectory; + // eslint-disable-next-line no-param-reassign reporter[definition.name] = new Electron(reporter, definition); } diff --git a/src/recipe.js b/src/recipe.js index 08c2bca..6d0f49e 100644 --- a/src/recipe.js +++ b/src/recipe.js @@ -48,13 +48,16 @@ export default function(conversion, request, response) { landscape: parseBoolean(options.landscape, false) } }).then((result) => { + /* eslint-disable no-param-reassign */ response.headers['Content-Type'] = 'application/pdf'; response.headers['Content-Disposition'] = 'inline; filename="report.pdf"'; response.headers['File-Extension'] = 'pdf'; response.headers['Number-Of-Pages'] = result.numberOfPages; + /* eslint-enable no-param-reassign */ return toArray(result.stream); }).then((arr) => { + // eslint-disable-next-line no-param-reassign response.content = Buffer.concat(arr); })); }); diff --git a/test/test.js b/test/test.js index c7598d6..0801ffc 100644 --- a/test/test.js +++ b/test/test.js @@ -2,6 +2,7 @@ import path from 'path'; import jsreport from 'jsreport-core'; +/* eslint-disable prefer-arrow-callback */ describe('electron pdf', function() { let reporter;