diff --git a/.jshintrc b/.jshintrc index f7daa6924..3edabba55 100644 --- a/.jshintrc +++ b/.jshintrc @@ -6,6 +6,8 @@ "worker": true, // Enforcing + "maxlen": 80, + "quotmark": "single", // Relaxing "boss": true, diff --git a/make.js b/make.js index 002b3523d..79f7c92e6 100644 --- a/make.js +++ b/make.js @@ -1,7 +1,22 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +/* Copyright 2012 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* jshint node:true */ -/* globals cat, cd, cp, echo, env, exec, exit, find, ls, mkdir, mv, process, rm, sed, target, test */ +/* globals cat, cd, cp, echo, env, exec, exit, find, ls, mkdir, mv, process, rm, + sed, target, test */ 'use strict'; @@ -46,7 +61,7 @@ target.all = function() { }; -/////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // // Production stuff // @@ -267,7 +282,7 @@ target.bundle = function() { -/////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // // Extension stuff // @@ -657,7 +672,7 @@ target.chrome = function() { }; -/////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // // Test stuff // @@ -933,7 +948,7 @@ target.mozcentralcheck = function() { }; -/////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // // Other // @@ -997,7 +1012,8 @@ target.jshint = function() { //'extensions/chrome/*.js' ]; - exit(exec('./node_modules/.bin/jshint --reporter test/reporter.js ' + LINT_FILES.join(' ')).code); + exit(exec('./node_modules/.bin/jshint --reporter test/reporter.js ' + + LINT_FILES.join(' ')).code); }; // diff --git a/src/api.js b/src/api.js index 689a3885f..25dd14d8a 100644 --- a/src/api.js +++ b/src/api.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals CanvasGraphics, combineUrl, createScratchCanvas, error, ErrorFont, Font, FontLoader, globalScope, info, isArrayBuffer, loadJpegStream, MessageHandler, PDFJS, PDFObjects, Promise, StatTimer, warn, WorkerMessageHandler */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals CanvasGraphics, combineUrl, createScratchCanvas, error, ErrorFont, + Font, FontLoader, globalScope, info, isArrayBuffer, loadJpegStream, + MessageHandler, PDFJS, PDFObjects, Promise, StatTimer, warn, + WorkerMessageHandler */ 'use strict'; diff --git a/src/canvas.js b/src/canvas.js index cc6215a35..6028e85c5 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals ColorSpace, DeviceCmykCS, DeviceGrayCS, DeviceRgbCS, error, FONT_IDENTITY_MATRIX, IDENTITY_MATRIX, ImageData, isArray, isNum, isString, Pattern, TilingPattern, TODO, Util, warn */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals ColorSpace, DeviceCmykCS, DeviceGrayCS, DeviceRgbCS, error, + FONT_IDENTITY_MATRIX, IDENTITY_MATRIX, ImageData, isArray, isNum, + isString, Pattern, TilingPattern, TODO, Util, warn */ 'use strict'; diff --git a/src/colorspace.js b/src/colorspace.js index 116f55e76..4992b716f 100644 --- a/src/colorspace.js +++ b/src/colorspace.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals error, info, input, isArray, isDict, isName, isStream, isString, PDFFunction, warn */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals error, info, input, isArray, isDict, isName, isStream, isString, + PDFFunction, warn */ 'use strict'; diff --git a/src/core.js b/src/core.js index e87c10380..7a883195a 100644 --- a/src/core.js +++ b/src/core.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals assertWellFormed, calculateMD5, Catalog, error, info, isArray, isArrayBuffer, isDict, isName, isStream, isString, Lexer, Linearization, NullStream, PartialEvaluator, shadow, Stream, StreamsSequenceStream, stringToPDFString, TODO, Util, warn, XRef */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals assertWellFormed, calculateMD5, Catalog, error, info, isArray, + isArrayBuffer, isDict, isName, isStream, isString, Lexer, + Linearization, NullStream, PartialEvaluator, shadow, Stream, + StreamsSequenceStream, stringToPDFString, TODO, Util, warn, XRef */ 'use strict'; diff --git a/src/crypto.js b/src/crypto.js index 9ffca919f..70c4ccfe8 100644 --- a/src/crypto.js +++ b/src/crypto.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals bytesToString, DecryptStream, error, isInt, isName, Name, PasswordException, stringToBytes */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals bytesToString, DecryptStream, error, isInt, isName, Name, + PasswordException, stringToBytes */ 'use strict'; diff --git a/src/evaluator.js b/src/evaluator.js index aff314f4e..54b6089b0 100644 --- a/src/evaluator.js +++ b/src/evaluator.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals assert, assertWellFormed, ColorSpace, Dict, Encodings, error, ErrorFont, Font, FONT_IDENTITY_MATRIX, fontCharsToUnicode, FontFlags, IDENTITY_MATRIX, info, isArray, isCmd, isDict, isEOF, isName, isNum, isStream, isString, JpegStream, Lexer, Metrics, Name, Parser, Pattern, PDFImage, PDFJS, serifFonts, stdFontMap, symbolsFonts, TilingPattern, TODO, warn */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals assert, assertWellFormed, ColorSpace, Dict, Encodings, error, + ErrorFont, Font, FONT_IDENTITY_MATRIX, fontCharsToUnicode, FontFlags, + IDENTITY_MATRIX, info, isArray, isCmd, isDict, isEOF, isName, isNum, + isStream, isString, JpegStream, Lexer, Metrics, Name, Parser, + Pattern, PDFImage, PDFJS, serifFonts, stdFontMap, symbolsFonts, + TilingPattern, TODO, warn */ 'use strict'; @@ -729,7 +734,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { case 'Tj': chunk += fontCharsToUnicode(args[0], font); break; - case "'": + case '\'': // For search, adding a extra white space for line breaks would be // better here, but that causes too much spaces in the // text-selection divs. diff --git a/src/fonts.js b/src/fonts.js index 3cdd8a578..80c43b0f5 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals assert, bytesToString, CIDToUnicodeMaps, error, ExpertCharset, ExpertSubsetCharset, FileReaderSync, globalScope, GlyphsUnicode, info, isArray, isNum, ISOAdobeCharset, isWorker, PDFJS, Stream, stringToBytes, TextDecoder, warn */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals assert, bytesToString, CIDToUnicodeMaps, error, ExpertCharset, + ExpertSubsetCharset, FileReaderSync, globalScope, GlyphsUnicode, + info, isArray, isNum, ISOAdobeCharset, isWorker, PDFJS, Stream, + stringToBytes, TextDecoder, warn */ 'use strict'; @@ -4309,7 +4312,7 @@ var Font = (function FontClosure() { // Add the font-face rule to the document var url = ('url(data:' + this.mimetype + ';base64,' + window.btoa(data) + ');'); - var rule = "@font-face { font-family:'" + fontName + "';src:" + url + '}'; + var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}'; var styleElement = document.getElementById('PDFJS_FONT_STYLE_TAG'); if (!styleElement) { diff --git a/src/image.js b/src/image.js index a43cc846b..48f174c76 100644 --- a/src/image.js +++ b/src/image.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals ColorSpace, error, isArray, isStream, JpegStream, Name, Promise, Stream, TODO, warn */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals ColorSpace, error, isArray, isStream, JpegStream, Name, Promise, + Stream, TODO, warn */ 'use strict'; diff --git a/src/jpx.js b/src/jpx.js index 017f0328a..a8fd39d5a 100644 --- a/src/jpx.js +++ b/src/jpx.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals error, globalScope, warn */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals error, globalScope, warn */ 'use strict'; diff --git a/src/obj.js b/src/obj.js index d3f2df96c..3b0e16f3f 100644 --- a/src/obj.js +++ b/src/obj.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals assertWellFormed, bytesToString, CipherTransformFactory, error, info, InvalidPDFException, isArray, isCmd, isDict, isInt, isName, isRef, isStream, JpegStream, Lexer, log, Page, Parser, Promise, shadow, stringToPDFString, stringToUTF8String, warn */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals assertWellFormed, bytesToString, CipherTransformFactory, error, info, + InvalidPDFException, isArray, isCmd, isDict, isInt, isName, isRef, + isStream, JpegStream, Lexer, log, Page, Parser, Promise, shadow, + stringToPDFString, stringToUTF8String, warn */ 'use strict'; diff --git a/src/parser.js b/src/parser.js index 4c99c0683..35954b4c3 100644 --- a/src/parser.js +++ b/src/parser.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals Ascii85Stream, AsciiHexStream, CCITTFaxStream, Cmd, Dict, error, FlateStream, isArray, isCmd, isDict, isInt, isName, isNum, isRef, isString, Jbig2Stream, JpegStream, JpxStream, LZWStream, Name, NullStream, PredictorStream, Ref, RunLengthStream, warn */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals Ascii85Stream, AsciiHexStream, CCITTFaxStream, Cmd, Dict, error, + FlateStream, isArray, isCmd, isDict, isInt, isName, isNum, isRef, + isString, Jbig2Stream, JpegStream, JpxStream, LZWStream, Name, + NullStream, PredictorStream, Ref, RunLengthStream, warn */ 'use strict'; @@ -134,7 +137,8 @@ var Parser = (function ParserClosure() { // searching for the /EI\s/ var state = 0, ch; - while (state != 4 && (ch = stream.getByte()) !== null && ch !== undefined) { + while (state != 4 && + (ch = stream.getByte()) !== null && ch !== undefined) { switch (ch) { case 0x20: case 0x0D: @@ -477,13 +481,13 @@ var Lexer = (function LexerClosure() { if (isFirstHex) { firstDigit = toHexDigit(ch); if (firstDigit === -1) { - warn("Ignoring invalid character '" + ch + "' in hex string"); + warn('Ignoring invalid character "' + ch + '" in hex string'); continue; } } else { secondDigit = toHexDigit(ch); if (secondDigit === -1) { - warn("Ignoring invalid character '" + ch + "' in hex string"); + warn('Ignoring invalid character "' + ch + '" in hex string'); continue; } str += String.fromCharCode((firstDigit << 4) | secondDigit); diff --git a/src/pattern.js b/src/pattern.js index 0b5f4c435..2a2ca1d88 100644 --- a/src/pattern.js +++ b/src/pattern.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals CanvasGraphics, ColorSpace, createScratchCanvas, DeviceRgbCS, error, info, isArray, isPDFFunction, isStream, PDFFunction, TODO, Util, warn */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals CanvasGraphics, ColorSpace, createScratchCanvas, DeviceRgbCS, error, + info, isArray, isPDFFunction, isStream, PDFFunction, TODO, Util, + warn */ 'use strict'; diff --git a/src/stream.js b/src/stream.js index eb43d4623..69279a500 100644 --- a/src/stream.js +++ b/src/stream.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals bytesToString, ColorSpace, Dict, EOF, error, info, Jbig2Image, JpegImage, JpxImage, Lexer */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals bytesToString, ColorSpace, Dict, EOF, error, info, Jbig2Image, + JpegImage, JpxImage, Lexer */ 'use strict'; diff --git a/src/util.js b/src/util.js index 1d0cf1003..b6bfcbdde 100644 --- a/src/util.js +++ b/src/util.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals Cmd, DeviceCmykCS, Dict, globalScope, INFOS, MozBlobBuilder, Name, PDFJS, Ref, WARNINGS, verbosity */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals Cmd, DeviceCmykCS, Dict, globalScope, INFOS, MozBlobBuilder, Name, + PDFJS, Ref, WARNINGS, verbosity */ 'use strict'; @@ -469,11 +470,13 @@ function isArray(v) { } function isStream(v) { - return typeof v == 'object' && v !== null && v !== undefined && ('getChar' in v); + return typeof v == 'object' && v !== null && v !== undefined && + ('getChar' in v); } function isArrayBuffer(v) { - return typeof v == 'object' && v !== null && v !== undefined && ('byteLength' in v); + return typeof v == 'object' && v !== null && v !== undefined && + ('byteLength' in v); } function isRef(v) { diff --git a/src/utils/fonts_utils.js b/src/utils/fonts_utils.js index 27bad2a58..f88458576 100644 --- a/src/utils/fonts_utils.js +++ b/src/utils/fonts_utils.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals CFFDictDataMap, CFFDictPrivateDataMap, CFFEncodingMap, CFFStrings, Components, Dict, dump, error, isNum, log, netscape, Stream, warn */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals CFFDictDataMap, CFFDictPrivateDataMap, CFFEncodingMap, CFFStrings, + Components, Dict, dump, error, isNum, log, netscape, Stream, warn */ 'use strict'; diff --git a/src/worker.js b/src/worker.js index ae32cf3e3..1c8241c6c 100644 --- a/src/worker.js +++ b/src/worker.js @@ -1,6 +1,5 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -/* globals CanvasGraphics, error, globalScope, InvalidPDFException, log, MissingPDFException, PasswordException, PDFDocument, PDFJS, Promise, Stream, UnknownErrorException, warn */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* globals CanvasGraphics, error, globalScope, InvalidPDFException, log, + MissingPDFException, PasswordException, PDFDocument, PDFJS, Promise, + Stream, UnknownErrorException, warn */ 'use strict'; diff --git a/test/reporter.js b/test/reporter.js index c8993e3a9..6c5c5a9fb 100644 --- a/test/reporter.js +++ b/test/reporter.js @@ -1,28 +1,45 @@ -"use strict"; +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +/* Copyright 2012 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; module.exports = { - reporter: function (res) { + reporter: function reporter(res) { var len = 0; - var str = ""; + var str = ''; - res.forEach(function (r) { + res.forEach(function(r) { var file = r.file; var err = r.error; - switch(err.code) { + switch (err.code) { case 'W004': // variable is already defined case 'W018': // confusing use of ! break; default: len++; - str += file + ": line " + err.line + ", col " + - err.character + ", " + err.reason + "\n"; + str += file + ': line ' + err.line + ', col ' + + err.character + ', ' + err.reason + '\n'; } }); if (str) { - process.stdout.write(str + "\n" + len + " error" + - ((len === 1) ? "" : "s") + "\n"); + process.stdout.write(str + '\n' + len + ' error' + + ((len === 1) ? '' : 's') + '\n'); process.exit(2); } else { process.exit(0);