From 080151711bc545f2d04f5a803b7da8145b6b44d7 Mon Sep 17 00:00:00 2001 From: Jerome Wu Date: Wed, 22 May 2019 11:49:11 +0800 Subject: [PATCH] Fix lint error --- .eslintrc | 6 ++++-- package-lock.json | 34 +++++++++++++--------------------- package.json | 1 + src/browser/index.js | 4 ++-- src/browser/worker.js | 4 ++-- src/common/workerUtils.js | 7 +++---- 6 files changed, 25 insertions(+), 31 deletions(-) diff --git a/.eslintrc b/.eslintrc index 5103e0e..a3bad8a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,11 +3,13 @@ "env": { "browser": true, "node": true, - "mocha": true + "mocha": true, + "worker": true }, "rules": { "no-underscore-dangle": 0, "no-console": 0, - "global-require": 0 + "global-require": 0, + "camelcase": 0 } } diff --git a/package-lock.json b/package-lock.json index 3b5029b..b515578 100644 --- a/package-lock.json +++ b/package-lock.json @@ -381,6 +381,12 @@ "negotiator": "0.6.1" } }, + "acorn": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", + "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==", + "dev": true + }, "acorn-dynamic-import": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz", @@ -2549,14 +2555,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2571,20 +2575,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -2701,8 +2702,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -2714,7 +2714,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2729,7 +2728,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2737,14 +2735,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -2763,7 +2759,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -2844,8 +2839,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -2857,7 +2851,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -2979,7 +2972,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/package.json b/package.json index 80a3cd0..7f266be 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ ], "license": "Apache-2.0", "devDependencies": { + "acorn": "^6.1.1", "cors": "^2.8.5", "eslint": "^5.9.0", "eslint-config-airbnb": "^17.1.0", diff --git a/src/browser/index.js b/src/browser/index.js index 28b36df..8568171 100644 --- a/src/browser/index.js +++ b/src/browser/index.js @@ -39,7 +39,7 @@ const readFromBlobOrFile = (blob, res) => { * string: URL string, can be relative path * img HTMLElement: extract image source from src attribute * video HTMLElement: extract image source from poster attribute - * canvas HTMLElement: extract image data by converting to Blob + * canvas HTMLElement: extract image data by converting to Blob * File instance: data from * @returns {array} binary image in array format */ @@ -88,7 +88,7 @@ const downloadFile = (path, blob) => { document.body.removeChild(link); } } -} +}; /* * Default options for browser worker diff --git a/src/browser/worker.js b/src/browser/worker.js index 3a2b092..55a6cbe 100644 --- a/src/browser/worker.js +++ b/src/browser/worker.js @@ -33,7 +33,7 @@ workerUtils.setAdapter({ */ if (check.not.undefined(global.TesseractCoreWASM) && typeof WebAssembly === 'object') { global.TesseractCore = global.TesseractCoreWASM; - } else if (check.not.undefined(global.TesseractCoreASM)){ + } else if (check.not.undefined(global.TesseractCoreASM)) { global.TesseractCore = global.TesseractCoreASM; } else { throw Error('Failed to load TesseractCore'); @@ -44,7 +44,7 @@ workerUtils.setAdapter({ }, b64toU8Array: s => new Uint8Array(atob(s).split('').map(c => c.charCodeAt(0))), writeFile: (path, data, type) => { - self.postMessage({ + postMessage({ jobId: 'Download', path, data, diff --git a/src/common/workerUtils.js b/src/common/workerUtils.js index 0aa434e..a26c2dc 100644 --- a/src/common/workerUtils.js +++ b/src/common/workerUtils.js @@ -8,7 +8,6 @@ * @author Jerome Wu */ const { readImage, loadLang } = require('tesseract.js-utils'); -const check = require('check-types'); const pdfTTF = require('./pdf-ttf'); const dump = require('./dump'); const { defaultParams } = require('./options'); @@ -59,7 +58,7 @@ const setImage = (image) => { * @name handleParams * @function hanlde params from users * @access private - * @param {string} lang - lang string for Init() + * @param {string} lang - lang string for Init() * @param {object} customParams - an object of params */ const handleParams = (lang, customParams) => { @@ -110,14 +109,14 @@ const handleOutput = (customParams) => { if (pdf_bin) { files = { pdf: data, ...files }; } - + if (pdf_auto_download) { adapter.writeFile(`${pdf_name}.pdf`, data, 'application/pdf'); } } return files; -} +}; /** * handleInit