diff --git a/examples/.eslintrc b/examples/.eslintrc index 8c4df5059aa63..433abdbfab2c4 100644 --- a/examples/.eslintrc +++ b/examples/.eslintrc @@ -3,23 +3,9 @@ "../.eslintrc" ], - "parserOptions": { - "ecmaVersion": 6, - }, - - "env": { - "es6": false, - }, - "globals": { "pdfjsImageDecoders": false, "pdfjsLib": false, "pdfjsViewer": false, - "Uint8Array": false, }, - - "rules": { - "no-alert": "off", - "object-shorthand": ["error", "never"] - } } diff --git a/examples/acroforms/acroforms.js b/examples/acroforms/acroforms.js index ef64248be3d71..51e9d3b3fc626 100644 --- a/examples/acroforms/acroforms.js +++ b/examples/acroforms/acroforms.js @@ -37,11 +37,11 @@ loadingTask.promise.then(function (doc) { return doc.getPage(pageNum).then(function (pdfPage) { // Create the page view. var pdfPageView = new pdfjsViewer.PDFPageView({ - container: container, + container, id: pageNum, scale: DEFAULT_SCALE, defaultViewport: pdfPage.getViewport({ scale: DEFAULT_SCALE }), - eventBus: eventBus, + eventBus, annotationLayerFactory: new pdfjsViewer.DefaultAnnotationLayerFactory(), renderInteractiveForms: true, }); diff --git a/examples/browserify/main.js b/examples/browserify/main.js index eb515077d9229..585bffe2a1e4b 100644 --- a/examples/browserify/main.js +++ b/examples/browserify/main.js @@ -25,7 +25,7 @@ loadingTask.promise var ctx = canvas.getContext("2d"); var renderTask = pdfPage.render({ canvasContext: ctx, - viewport: viewport, + viewport, }); return renderTask.promise; }); diff --git a/examples/components/pageviewer.js b/examples/components/pageviewer.js index 74791faf8cb42..25f99bc97d661 100644 --- a/examples/components/pageviewer.js +++ b/examples/components/pageviewer.js @@ -16,6 +16,7 @@ "use strict"; if (!pdfjsLib.getDocument || !pdfjsViewer.PDFPageView) { + // eslint-disable-next-line no-alert alert("Please build the pdfjs-dist library using\n `gulp dist-install`"); } @@ -48,11 +49,11 @@ loadingTask.promise.then(function (pdfDocument) { return pdfDocument.getPage(PAGE_TO_VIEW).then(function (pdfPage) { // Creating the page view with default parameters. var pdfPageView = new pdfjsViewer.PDFPageView({ - container: container, + container, id: PAGE_TO_VIEW, scale: SCALE, defaultViewport: pdfPage.getViewport({ scale: SCALE }), - eventBus: eventBus, + eventBus, // We can enable text/annotations layers, if needed textLayerFactory: new pdfjsViewer.DefaultTextLayerFactory(), annotationLayerFactory: new pdfjsViewer.DefaultAnnotationLayerFactory(), diff --git a/examples/components/simpleviewer.js b/examples/components/simpleviewer.js index daec1c6e0b319..b90868ee76d67 100644 --- a/examples/components/simpleviewer.js +++ b/examples/components/simpleviewer.js @@ -16,6 +16,7 @@ "use strict"; if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) { + // eslint-disable-next-line no-alert alert("Please build the pdfjs-dist library using\n `gulp dist-install`"); } @@ -38,18 +39,18 @@ var eventBus = new pdfjsViewer.EventBus(); // (Optionally) enable hyperlinks within PDF files. var pdfLinkService = new pdfjsViewer.PDFLinkService({ - eventBus: eventBus, + eventBus, }); // (Optionally) enable find controller. var pdfFindController = new pdfjsViewer.PDFFindController({ - eventBus: eventBus, + eventBus, linkService: pdfLinkService, }); var pdfViewer = new pdfjsViewer.PDFViewer({ - container: container, - eventBus: eventBus, + container, + eventBus, linkService: pdfLinkService, findController: pdfFindController, }); diff --git a/examples/components/singlepageviewer.js b/examples/components/singlepageviewer.js index 8d12380ca22fc..d6ec5a8054405 100644 --- a/examples/components/singlepageviewer.js +++ b/examples/components/singlepageviewer.js @@ -16,6 +16,7 @@ "use strict"; if (!pdfjsLib.getDocument || !pdfjsViewer.PDFSinglePageViewer) { + // eslint-disable-next-line no-alert alert("Please build the pdfjs-dist library using\n `gulp dist-install`"); } @@ -38,18 +39,18 @@ var eventBus = new pdfjsViewer.EventBus(); // (Optionally) enable hyperlinks within PDF files. var pdfLinkService = new pdfjsViewer.PDFLinkService({ - eventBus: eventBus, + eventBus, }); // (Optionally) enable find controller. var pdfFindController = new pdfjsViewer.PDFFindController({ - eventBus: eventBus, + eventBus, linkService: pdfLinkService, }); var pdfSinglePageViewer = new pdfjsViewer.PDFSinglePageViewer({ - container: container, - eventBus: eventBus, + container, + eventBus, linkService: pdfLinkService, findController: pdfFindController, }); diff --git a/examples/image_decoders/jpeg_viewer.js b/examples/image_decoders/jpeg_viewer.js index e84307cf9a7b6..31008ff19a4f3 100644 --- a/examples/image_decoders/jpeg_viewer.js +++ b/examples/image_decoders/jpeg_viewer.js @@ -16,6 +16,7 @@ "use strict"; if (!pdfjsImageDecoders.JpegImage) { + // eslint-disable-next-line no-alert alert("Please build the pdfjs-dist library using `gulp dist-install`"); } @@ -61,8 +62,8 @@ jpegImage.parse(typedArrayImage); var width = jpegImage.width, height = jpegImage.height; var jpegData = jpegImage.getData({ - width: width, - height: height, + width, + height, forceRGB: true, }); diff --git a/examples/mobile-viewer/viewer.js b/examples/mobile-viewer/viewer.js index d168ab0a1c7c7..eb2026a8c7c3d 100644 --- a/examples/mobile-viewer/viewer.js +++ b/examples/mobile-viewer/viewer.js @@ -16,6 +16,7 @@ "use strict"; if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) { + // eslint-disable-next-line no-alert alert("Please build the pdfjs-dist library using\n `gulp dist-install`"); } @@ -47,7 +48,7 @@ var PDFViewerApplication = { * @returns {Promise} - Returns the promise, which is resolved when document * is opened. */ - open: function (params) { + open(params) { if (this.pdfLoadingTask) { // We need to destroy already opened document return this.close().then( @@ -64,7 +65,7 @@ var PDFViewerApplication = { // Loading document. var loadingTask = pdfjsLib.getDocument({ - url: url, + url, maxImageSize: MAX_IMAGE_SIZE, cMapUrl: CMAP_URL, cMapPacked: CMAP_PACKED, @@ -120,7 +121,7 @@ var PDFViewerApplication = { } loadingErrorMessage.then(function (msg) { - self.error(msg, { message: message }); + self.error(msg, { message }); }); self.loadingBar.hide(); } @@ -132,7 +133,7 @@ var PDFViewerApplication = { * @returns {Promise} - Returns the promise, which is resolved when all * destruction is completed. */ - close: function () { + close() { var errorWrapper = document.getElementById("errorWrapper"); errorWrapper.setAttribute("hidden", "true"); @@ -175,7 +176,7 @@ var PDFViewerApplication = { this.setTitle(title); }, - setTitleUsingMetadata: function (pdfDocument) { + setTitleUsingMetadata(pdfDocument) { var self = this; pdfDocument.getMetadata().then(function (data) { var info = data.info, @@ -345,7 +346,7 @@ var PDFViewerApplication = { this.eventBus = eventBus; var linkService = new pdfjsViewer.PDFLinkService({ - eventBus: eventBus, + eventBus, }); this.pdfLinkService = linkService; @@ -353,9 +354,9 @@ var PDFViewerApplication = { var container = document.getElementById("viewerContainer"); var pdfViewer = new pdfjsViewer.PDFViewer({ - container: container, - eventBus: eventBus, - linkService: linkService, + container, + eventBus, + linkService, l10n: this.l10n, useOnlyCssZoom: USE_ONLY_CSS_ZOOM, textLayerMode: TEXT_LAYER_MODE, @@ -364,8 +365,8 @@ var PDFViewerApplication = { linkService.setViewer(pdfViewer); this.pdfHistory = new pdfjsViewer.PDFHistory({ - eventBus: eventBus, - linkService: linkService, + eventBus, + linkService, }); linkService.setHistory(this.pdfHistory); diff --git a/examples/node/domstubs.js b/examples/node/domstubs.js index 3fdd02fd1ea5c..1f5b98d488eda 100644 --- a/examples/node/domstubs.js +++ b/examples/node/domstubs.js @@ -58,7 +58,7 @@ function DOMElement(name) { if (name === "style") { this.sheet = { cssRules: [], - insertRule: function (rule) { + insertRule(rule) { this.cssRules.push(rule); }, }; @@ -226,16 +226,16 @@ const document = { return this; }, - createElementNS: function (NS, element) { + createElementNS(NS, element) { var elObject = new DOMElement(element); return elObject; }, - createElement: function (element) { + createElement(element) { return this.createElementNS("", element); }, - getElementsByTagName: function (element) { + getElementsByTagName(element) { if (element === "head") { return [this.head || (this.head = new DOMElement("head"))]; } diff --git a/examples/node/pdf2png/pdf2png.js b/examples/node/pdf2png/pdf2png.js index b8765c1ffee03..b33c5404d7de4 100644 --- a/examples/node/pdf2png/pdf2png.js +++ b/examples/node/pdf2png/pdf2png.js @@ -24,8 +24,8 @@ NodeCanvasFactory.prototype = { var canvas = Canvas.createCanvas(width, height); var context = canvas.getContext("2d"); return { - canvas: canvas, - context: context, + canvas, + context, }; }, @@ -61,7 +61,7 @@ var data = new Uint8Array(fs.readFileSync(pdfPath)); // Load the PDF file. var loadingTask = pdfjsLib.getDocument({ - data: data, + data, cMapUrl: CMAP_URL, cMapPacked: CMAP_PACKED, }); @@ -80,8 +80,8 @@ loadingTask.promise ); var renderContext = { canvasContext: canvasAndContext.context, - viewport: viewport, - canvasFactory: canvasFactory, + viewport, + canvasFactory, }; var renderTask = page.render(renderContext); diff --git a/examples/node/pdf2svg.js b/examples/node/pdf2svg.js index 58c419f4ae03f..d95737df283fe 100644 --- a/examples/node/pdf2svg.js +++ b/examples/node/pdf2svg.js @@ -71,7 +71,7 @@ ReadableSVGStream.prototype._read = function () { // Streams the SVG element to the given file path. function writeSvgToFile(svgElement, filePath) { var readableSvgStream = new ReadableSVGStream({ - svgElement: svgElement, + svgElement, }); var writableStream = fs.createWriteStream(filePath); return new Promise(function (resolve, reject) { @@ -89,7 +89,7 @@ function writeSvgToFile(svgElement, filePath) { // Will be using promises to load document, pages and misc data instead of // callback. var loadingTask = pdfjsLib.getDocument({ - data: data, + data, cMapUrl: CMAP_URL, cMapPacked: CMAP_PACKED, fontExtraProperties: true, diff --git a/examples/svgviewer/viewer.js b/examples/svgviewer/viewer.js index 0ec51c29dc5f7..b72ba782584a1 100644 --- a/examples/svgviewer/viewer.js +++ b/examples/svgviewer/viewer.js @@ -16,6 +16,7 @@ "use strict"; if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) { + // eslint-disable-next-line no-alert alert("Please build the pdfjs-dist library using\n `gulp dist-install`"); } @@ -37,12 +38,12 @@ var eventBus = new pdfjsViewer.EventBus(); // (Optionally) enable hyperlinks within PDF files. var pdfLinkService = new pdfjsViewer.PDFLinkService({ - eventBus: eventBus, + eventBus, }); var pdfViewer = new pdfjsViewer.PDFViewer({ - container: container, - eventBus: eventBus, + container, + eventBus, linkService: pdfLinkService, renderer: "svg", textLayerMode: 0, diff --git a/examples/text-only/pdf2svg.js b/examples/text-only/pdf2svg.js index fd6e372fa70ef..c62954f8831c7 100644 --- a/examples/text-only/pdf2svg.js +++ b/examples/text-only/pdf2svg.js @@ -65,10 +65,8 @@ function pageLoaded() { document.addEventListener("DOMContentLoaded", function () { if (typeof pdfjsLib === "undefined") { - alert( - "Built version of PDF.js was not found.\n" + - "Please run `gulp dist-install`." - ); + // eslint-disable-next-line no-alert + alert("Please build the pdfjs-dist library using\n `gulp dist-install`"); return; } pageLoaded(); diff --git a/examples/webpack/main.js b/examples/webpack/main.js index 942693c10d7f0..088358c929137 100644 --- a/examples/webpack/main.js +++ b/examples/webpack/main.js @@ -25,7 +25,7 @@ loadingTask.promise var ctx = canvas.getContext("2d"); var renderTask = pdfPage.render({ canvasContext: ctx, - viewport: viewport, + viewport, }); return renderTask.promise; }); diff --git a/extensions/.eslintrc b/extensions/.eslintrc deleted file mode 100644 index a729eba0fe31e..0000000000000 --- a/extensions/.eslintrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": [ - ../.eslintrc - ], - - "rules": { - "no-restricted-globals": "off", - }, -} diff --git a/external/.eslintrc b/external/.eslintrc index 7648ec705d3b6..e3523dce526ed 100644 --- a/external/.eslintrc +++ b/external/.eslintrc @@ -6,10 +6,4 @@ "env": { "node": true, }, - - "rules": { - "mozilla/use-includes-instead-of-indexOf": "off", - "object-shorthand": "off", - "no-restricted-globals": "off", - }, } diff --git a/external/builder/preprocessor2.js b/external/builder/preprocessor2.js index 1b1c9320e2241..eb991a032eeaa 100644 --- a/external/builder/preprocessor2.js +++ b/external/builder/preprocessor2.js @@ -35,7 +35,7 @@ function handlePreprocessorAction(ctx, actionName, args, loc) { throw new Error("No code for testing is given"); } var isTrue = !!evalWithDefines(arg.value, ctx.defines); - return { type: "Literal", value: isTrue, loc: loc }; + return { type: "Literal", value: isTrue, loc }; case "eval": arg = args[0]; if (!arg || arg.type !== "Literal" || typeof arg.value !== "string") { @@ -47,7 +47,7 @@ function handlePreprocessorAction(ctx, actionName, args, loc) { typeof result === "string" || typeof result === "number" ) { - return { type: "Literal", value: result, loc: loc }; + return { type: "Literal", value: result, loc }; } if (typeof result === "object") { const parsedObj = acorn.parse("(" + JSON.stringify(result) + ")", { @@ -333,8 +333,8 @@ function preprocessPDFJSCode(ctx, code) { sourceType: "module", }; var codegenOptions = { - format: format, - parse: function (input) { + format, + parse(input) { return acorn.parse(input, { ecmaVersion: ACORN_ECMA_VERSION }); }, sourceMap: ctx.sourceMap, diff --git a/external/builder/test-fixtures_esprima.js b/external/builder/test-fixtures_esprima.js index 3f85230382080..655b965cc3bfe 100644 --- a/external/builder/test-fixtures_esprima.js +++ b/external/builder/test-fixtures_esprima.js @@ -34,8 +34,8 @@ files.forEach(function (expectationFilename) { "import-alias": "import-name", }; var ctx = { - defines: defines, - map: map, + defines, + map, rootPath: __dirname + "/../..", }; var out; diff --git a/external/systemjs/plugin-babel-cached.js b/external/systemjs/plugin-babel-cached.js index 622ebd47ed9d5..d0f2e711ce371 100644 --- a/external/systemjs/plugin-babel-cached.js +++ b/external/systemjs/plugin-babel-cached.js @@ -46,11 +46,11 @@ function storeCache(address, hashCode, translated, format) { var tx = db.transaction(dbCacheTable, "readwrite"); var store = tx.objectStore(dbCacheTable); store.put({ - address: address, - hashCode: hashCode, - translated: translated, + address, + hashCode, + translated, expires: Date.now() + cacheExpiration, - format: format, + format, }); return new Promise(function (resolve, reject) { tx.oncomplete = function () { diff --git a/gulpfile.js b/gulpfile.js index 560dd98e1df8d..056da0734e9d3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,7 +13,6 @@ * limitations under the License. */ /* eslint-env node */ -/* eslint-disable object-shorthand */ /* globals target */ "use strict"; @@ -222,7 +221,7 @@ function createWebpackConfig( return { mode: "none", - output: output, + output, performance: { hints: false, // Disable messages about larger file sizes. }, @@ -629,7 +628,7 @@ gulp.task("buildnumber", function (done) { "version.json", JSON.stringify( { - version: version, + version, build: buildNumber, commit: buildCommit, }, diff --git a/test/.eslintrc b/test/.eslintrc index e41ade95b740b..ab42529e71bc2 100644 --- a/test/.eslintrc +++ b/test/.eslintrc @@ -7,8 +7,4 @@ "node": true, "jasmine": true, }, - - "rules": { - "no-restricted-globals": "off", - }, } diff --git a/test/chromium/test-telemetry.js b/test/chromium/test-telemetry.js index cd2f2c522c656..c0121c5cb783c 100755 --- a/test/chromium/test-telemetry.js +++ b/test/chromium/test-telemetry.js @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* eslint-disable object-shorthand */ "use strict"; @@ -110,17 +109,17 @@ function createExtensionGlobal() { }; var headers = {}; return { - open: function (method, url) { + open(method, url) { assert.equal(invoked.open, false); invoked.open = true; assert.equal(method, "POST"); assert.equal(url, LOG_URL); }, - setRequestHeader: function (k, v) { + setRequestHeader(k, v) { assert.equal(invoked.open, true); headers[k] = String(v); }, - send: function (body) { + send(body) { assert.equal(invoked.open, true); assert.equal(invoked.send, false); invoked.send = true; @@ -138,7 +137,7 @@ function createExtensionGlobal() { }; window.Date = { test_now_value: Date.now(), - now: function () { + now() { return window.Date.test_now_value; }, }; diff --git a/test/downloadutils.js b/test/downloadutils.js index eecbcaf89e350..15c0c3c3bfd62 100644 --- a/test/downloadutils.js +++ b/test/downloadutils.js @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* eslint-disable object-shorthand */ "use strict"; @@ -133,7 +132,7 @@ function downloadManifestFiles(manifest, callback) { var linkfile = file + ".link"; var url = fs.readFileSync(linkfile).toString(); url = url.replace(/\s+$/, ""); - return { file: file, url: url }; + return { file, url }; }); var i = 0; diff --git a/test/test.js b/test/test.js index 374fddf3537e7..13ab5461c3890 100644 --- a/test/test.js +++ b/test/test.js @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* eslint-disable object-shorthand */ "use strict"; @@ -646,15 +645,15 @@ function refTestPostHandler(req, res) { } taskResults[round][page] = { - failure: failure, - snapshot: snapshot, + failure, + snapshot, }; if (stats) { stats.push({ - browser: browser, + browser, pdf: id, - page: page, - round: round, + page, + round, stats: data.stats, }); } diff --git a/test/webserver.js b/test/webserver.js index cb89284d6b656..68b413858112a 100644 --- a/test/webserver.js +++ b/test/webserver.js @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* eslint-disable object-shorthand */ "use strict"; @@ -53,7 +52,7 @@ function WebServer() { }; } WebServer.prototype = { - start: function (callback) { + start(callback) { this._ensureNonZeroPort(); this.server = http.createServer(this._handler.bind(this)); this.server.listen(this.port, this.host, callback); @@ -61,11 +60,11 @@ WebServer.prototype = { "Server running at http://" + this.host + ":" + this.port + "/" ); }, - stop: function (callback) { + stop(callback) { this.server.close(callback); this.server = null; }, - _ensureNonZeroPort: function () { + _ensureNonZeroPort() { if (!this.port) { // If port is 0, a random port will be chosen instead. Do not set a host // name to make sure that the port is synchronously set by .listen(). @@ -78,7 +77,7 @@ WebServer.prototype = { server.close(); } }, - _handler: function (req, res) { + _handler(req, res) { var url = req.url.replace(/\/\//g, "/"); var urlParts = /([^?]*)((?:\?(.*))?)/.exec(url); try { @@ -312,7 +311,7 @@ WebServer.prototype = { function serveRequestedFileRange(reqFilePath, start, end) { var stream = fs.createReadStream(reqFilePath, { flags: "rs", - start: start, + start, end: end - 1, });