Skip to content

Commit

Permalink
Merge pull request mozilla#7890 from Snuffleupagus/pre-eslint-fixes
Browse files Browse the repository at this point in the history
Fix a number of code style issues found by various ESLint rules, to make it easier to switch from JSHint to ESLint
  • Loading branch information
timvandermeij authored Dec 14, 2016
2 parents 45a6b04 + 98275d0 commit e1fa6cf
Show file tree
Hide file tree
Showing 41 changed files with 99 additions and 103 deletions.
6 changes: 3 additions & 3 deletions extensions/chromium/pdfHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function isPdfDownloadable(details) {
* @return {undefined|{name: string, value: string}} The header, if found.
*/
function getHeaderFromHeaders(headers, headerName) {
for (var i=0; i<headers.length; ++i) {
for (var i = 0; i < headers.length; ++i) {
var header = headers[i];
if (header.name.toLowerCase() === headerName) {
return header;
Expand All @@ -72,7 +72,7 @@ function getHeaderFromHeaders(headers, headerName) {
function isPdfFile(details) {
var header = getHeaderFromHeaders(details.responseHeaders, 'content-type');
if (header) {
var headerValue = header.value.toLowerCase().split(';',1)[0].trim();
var headerValue = header.value.toLowerCase().split(';', 1)[0].trim();
if (headerValue === 'application/pdf') {
return true;
}
Expand Down Expand Up @@ -153,7 +153,7 @@ chrome.webRequest.onHeadersReceived.addListener(
],
types: ['main_frame', 'sub_frame']
},
['blocking','responseHeaders']);
['blocking', 'responseHeaders']);

chrome.webRequest.onBeforeRequest.addListener(
function onBeforeRequestForFTP(details) {
Expand Down
1 change: 0 additions & 1 deletion extensions/firefox/content/PdfjsChromeUtils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,3 @@ var PdfjsChromeUtils = {
});
}
};

2 changes: 1 addition & 1 deletion external/builder/preprocessor2.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function handlePreprocessorAction(ctx, actionName, args, loc) {
jsonPath.substring(ROOT_PREFIX.length));
}
var jsonContent = fs.readFileSync(jsonPath).toString();
var parsedJSON = esprima.parse('(' +jsonContent + ')');
var parsedJSON = esprima.parse('(' + jsonContent + ')');
parsedJSON.body[0].expression.loc = loc;
return parsedJSON.body[0].expression;
}
Expand Down
1 change: 0 additions & 1 deletion external/crlfchecker/crlfchecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ function checkIfCrlfIsPresent(files) {
}

exports.checkIfCrlfIsPresent = checkIfCrlfIsPresent;

2 changes: 1 addition & 1 deletion external/umdutils/verifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function readDependencies(rootPaths) {
}
});
if (discovered.length === 0) {
throw new Error ('Some circular references exist: somewhere at ' +
throw new Error('Some circular references exist: somewhere at ' +
left.join(','));
}
discovered.sort();
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function createBundle(defines) {
case 'mainfile':
// 'buildnumber' shall create BUILD_DIR for us
tmpFile = BUILD_DIR + '~' + mainOutputName + '.tmp';
bundle('src/pdf.js', tmpFile, 'src/', mainFiles, mainAMDName,
bundle('src/pdf.js', tmpFile, 'src/', mainFiles, mainAMDName,
defines, true, versionJSON);
this.push(new gutil.File({
cwd: '',
Expand Down
2 changes: 1 addition & 1 deletion make.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ target.chromium = function() {
'extensions/chromium/*.html',
'extensions/chromium/*.js',
'extensions/chromium/*.css',
'extensions/chromium/icon*.png',],
'extensions/chromium/icon*.png'],
CHROME_BUILD_DIR],
['extensions/chromium/pageAction/*.*', CHROME_BUILD_DIR + '/pageAction'],
['extensions/chromium/options/*.*', CHROME_BUILD_DIR + '/options'],
Expand Down
2 changes: 1 addition & 1 deletion src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ var Annotation = (function AnnotationClosure() {
// Properties
]);
var bbox = appearanceDict.getArray('BBox') || [0, 0, 1, 1];
var matrix = appearanceDict.getArray('Matrix') || [1, 0, 0, 1, 0 ,0];
var matrix = appearanceDict.getArray('Matrix') || [1, 0, 0, 1, 0, 0];
var transform = getTransformMatrix(data.rect, bbox, matrix);
var self = this;

Expand Down
2 changes: 1 addition & 1 deletion src/core/chunked_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
if (this.pdfNetworkStream) {
this.pdfNetworkStream.cancelAllRequests('abort');
}
for(var requestId in this.promisesByRequest) {
for (var requestId in this.promisesByRequest) {
var capability = this.promisesByRequest[requestId];
capability.reject(new Error('Request was aborted'));
}
Expand Down
42 changes: 21 additions & 21 deletions src/core/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,22 +609,22 @@ var calculateSHA512 = (function calculateSHA512Closure() {
var result;
if (!mode384) {
result = new Uint8Array(64);
h0.copyTo(result,0);
h1.copyTo(result,8);
h2.copyTo(result,16);
h3.copyTo(result,24);
h4.copyTo(result,32);
h5.copyTo(result,40);
h6.copyTo(result,48);
h7.copyTo(result,56);
h0.copyTo(result, 0);
h1.copyTo(result, 8);
h2.copyTo(result, 16);
h3.copyTo(result, 24);
h4.copyTo(result, 32);
h5.copyTo(result, 40);
h6.copyTo(result, 48);
h7.copyTo(result, 56);
} else {
result = new Uint8Array(48);
h0.copyTo(result,0);
h1.copyTo(result,8);
h2.copyTo(result,16);
h3.copyTo(result,24);
h4.copyTo(result,32);
h5.copyTo(result,40);
h0.copyTo(result, 0);
h1.copyTo(result, 8);
h2.copyTo(result, 16);
h3.copyTo(result, 24);
h4.copyTo(result, 32);
h5.copyTo(result, 40);
}
return result;
}
Expand Down Expand Up @@ -1729,21 +1729,21 @@ var PDF20 = (function PDF20Closure() {

var CipherTransform = (function CipherTransformClosure() {
function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
this.stringCipherConstructor = stringCipherConstructor;
this.streamCipherConstructor = streamCipherConstructor;
this.StringCipherConstructor = stringCipherConstructor;
this.StreamCipherConstructor = streamCipherConstructor;
}

CipherTransform.prototype = {
createStream: function CipherTransform_createStream(stream, length) {
var cipher = new this.streamCipherConstructor();
var cipher = new this.StreamCipherConstructor();
return new DecryptStream(stream, length,
function cipherTransformDecryptStream(data, finalize) {
return cipher.decryptBlock(data, finalize);
}
);
},
decryptString: function CipherTransform_decryptString(s) {
var cipher = new this.stringCipherConstructor();
var cipher = new this.StringCipherConstructor();
var data = stringToBytes(s);
data = cipher.decryptBlock(data, true);
return bytesToString(data);
Expand Down Expand Up @@ -2057,17 +2057,17 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
return new NullCipher();
};
}
if ('V2' === cfm.name) {
if (cfm.name === 'V2') {
return function cipherTransformFactoryBuildCipherConstructorV2() {
return new ARCFourCipher(buildObjectKey(num, gen, key, false));
};
}
if ('AESV2' === cfm.name) {
if (cfm.name === 'AESV2') {
return function cipherTransformFactoryBuildCipherConstructorAESV2() {
return new AES128Cipher(buildObjectKey(num, gen, key, true));
};
}
if ('AESV3' === cfm.name) {
if (cfm.name === 'AESV3') {
return function cipherTransformFactoryBuildCipherConstructorAESV3() {
return new AES256Cipher(key);
};
Expand Down
2 changes: 1 addition & 1 deletion src/core/font_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
x = xb; y = yb;
if (Math.abs(x - x0) > Math.abs(y - y0)) {
x += stack.shift();
} else {
} else {
y += stack.shift();
}
bezierCurveTo(xa, ya, xb, yb, x, y);
Expand Down
6 changes: 3 additions & 3 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2943,6 +2943,7 @@ var ErrorFont = (function ErrorFontClosure() {
function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
var charCodeToGlyphId = Object.create(null);
var glyphId, charCode, baseEncoding;
var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);

if (properties.baseEncodingName) {
// If a valid base encoding name was used, the mapping is initialized with
Expand All @@ -2956,9 +2957,8 @@ function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
charCodeToGlyphId[charCode] = 0; // notdef
}
}
} else if (!!(properties.flags & FontFlags.Symbolic)) {
// For a symbolic font the encoding should be the fonts built-in
// encoding.
} else if (isSymbolicFont) {
// For a symbolic font the encoding should be the fonts built-in encoding.
for (charCode in builtInEncoding) {
charCodeToGlyphId[charCode] = builtInEncoding[charCode];
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/jbig2.js
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
var combinationOperator = pageInfo.combinationOperatorOverride ?
regionInfo.combinationOperator : pageInfo.combinationOperator;
var buffer = this.buffer;
var mask0 = 128 >> (regionInfo.x & 7);
var mask0 = 128 >> (regionInfo.x & 7);
var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
var i, j, mask, offset;
switch (combinationOperator) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/jpg.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ var JpegImage = (function JpegImageClosure() {
component = frame.components[i];
var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) *
component.h / frame.maxH);
var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) *
var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) *
component.v / frame.maxV);
var blocksPerLineForMcu = mcusPerLine * component.h;
var blocksPerColumnForMcu = mcusPerColumn * component.v;
Expand Down
4 changes: 2 additions & 2 deletions src/core/jpx.js
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ var JpxImage = (function JpxImageClosure() {
var qcdOrQcc = (context.currentTile.QCC[c] !== undefined ?
context.currentTile.QCC[c] : context.currentTile.QCD);
component.quantizationParameters = qcdOrQcc;
var codOrCoc = (context.currentTile.COC[c] !== undefined ?
var codOrCoc = (context.currentTile.COC[c] !== undefined ?
context.currentTile.COC[c] : context.currentTile.COD);
component.codingStyleParameters = codOrCoc;
}
Expand Down Expand Up @@ -1552,7 +1552,7 @@ var JpxImage = (function JpxImageClosure() {
})();

var InclusionTree = (function InclusionTreeClosure() {
function InclusionTree(width, height, defaultValue) {
function InclusionTree(width, height, defaultValue) {
var levelsLength = log2(Math.max(width, height)) + 1;
this.levels = [];
for (var i = 0; i < levelsLength; i++) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/murmurhash3.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@

var Uint32ArrayView = sharedUtil.Uint32ArrayView;

var MurmurHash3_64 = (function MurmurHash3_64Closure (seed) {
var MurmurHash3_64 = (function MurmurHash3_64Closure(seed) {
// Workaround for missing math precision in JS.
var MASK_HIGH = 0xffff0000;
var MASK_LOW = 0xffff;

function MurmurHash3_64 (seed) {
function MurmurHash3_64(seed) {
var SEED = 0xc3d2e1f0;
this.h1 = seed ? seed & 0xffffffff : SEED;
this.h2 = seed ? seed & 0xffffffff : SEED;
Expand Down Expand Up @@ -145,7 +145,7 @@ var MurmurHash3_64 = (function MurmurHash3_64Closure (seed) {
return this;
},

hexdigest: function MurmurHash3_64_hexdigest () {
hexdigest: function MurmurHash3_64_hexdigest() {
var h1 = this.h1;
var h2 = this.h2;

Expand Down
2 changes: 1 addition & 1 deletion src/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ var Lexer = (function LexerClosure() {
var x2 = toHexDigit(ch);
if (x2 === -1) {
warn('Lexer_getName: Illegal digit (' +
String.fromCharCode(ch) +') in hexadecimal number.');
String.fromCharCode(ch) + ') in hexadecimal number.');
strBuf.push('#', String.fromCharCode(previousCh));
if (specialChars[ch]) {
break;
Expand Down
2 changes: 1 addition & 1 deletion src/core/pdf_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() {
result = value;
}
resolve(result);
} catch(e) {
} catch (e) {
if (!(e instanceof MissingDataException)) {
reject(e);
return;
Expand Down
6 changes: 3 additions & 3 deletions src/core/type1_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var Type1CharString = (function Type1CharStringClosure() {
'rrcurveto': [8],
'callsubr': [10],
'flex': [12, 35],
'drop' : [12, 18],
'drop': [12, 18],
'endchar': [14],
'rmoveto': [21],
'hmoveto': [22],
Expand Down Expand Up @@ -483,7 +483,7 @@ var Type1Parser = (function Type1ParserClosure() {
return token === 'true' ? 1 : 0;
},

nextChar : function Type1_nextChar() {
nextChar: function Type1_nextChar() {
return (this.currentChar = this.stream.getByte());
},

Expand Down Expand Up @@ -550,7 +550,7 @@ var Type1Parser = (function Type1ParserClosure() {
this.getToken(); // read in 'dict'
this.getToken(); // read in 'dup'
this.getToken(); // read in 'begin'
while(true) {
while (true) {
token = this.getToken();
if (token === null || token === 'end') {
break;
Expand Down
2 changes: 1 addition & 1 deletion src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ var PDFWorker = (function PDFWorkerClosure() {
}
try {
sendTest();
} catch (e) {
} catch (e) {
// We need fallback to a faked worker.
this._setupFakeWorker();
}
Expand Down
10 changes: 5 additions & 5 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
}
if (sourceCtx.setLineDash !== undefined) {
destCtx.setLineDash(sourceCtx.getLineDash());
destCtx.lineDashOffset = sourceCtx.lineDashOffset;
destCtx.lineDashOffset = sourceCtx.lineDashOffset;
}
}

Expand Down Expand Up @@ -1780,13 +1780,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.save();
this.baseTransformStack.push(this.baseTransform);

if (isArray(matrix) && 6 === matrix.length) {
if (isArray(matrix) && matrix.length === 6) {
this.transform.apply(this, matrix);
}

this.baseTransform = this.ctx.mozCurrentTransform;

if (isArray(bbox) && 4 === bbox.length) {
if (isArray(bbox) && bbox.length === 4) {
var width = bbox[2] - bbox[0];
var height = bbox[3] - bbox[1];
this.ctx.rect(bbox[0], bbox[1], width, height);
Expand Down Expand Up @@ -1862,7 +1862,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var cacheId = 'groupAt' + this.groupLevel;
if (group.smask) {
// Using two cache entries is case if masks are used one after another.
cacheId += '_smask_' + ((this.smaskCounter++) % 2);
cacheId += '_smask_' + ((this.smaskCounter++) % 2);
}
var scratchCanvas = this.cachedCanvases.getCanvas(
cacheId, drawnWidth, drawnHeight, true);
Expand Down Expand Up @@ -1947,7 +1947,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
matrix) {
this.save();

if (isArray(rect) && 4 === rect.length) {
if (isArray(rect) && rect.length === 4) {
var width = rect[2] - rect[0];
var height = rect[3] - rect[1];
this.ctx.rect(rect[0], rect[1], width, height);
Expand Down
4 changes: 2 additions & 2 deletions src/display/svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ var SVGGraphics = (function SVGGraphicsClosure() {
var height = args[j++];
var xw = x + width;
var yh = y + height;
d.push('M', pf(x), pf(y), 'L', pf(xw) , pf(y), 'L', pf(xw), pf(yh),
d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh),
'L', pf(x), pf(yh), 'Z');
break;
case OPS.moveTo:
Expand All @@ -852,7 +852,7 @@ var SVGGraphics = (function SVGGraphicsClosure() {
case OPS.lineTo:
x = args[j++];
y = args[j++];
d.push('L', pf(x) , pf(y));
d.push('L', pf(x), pf(y));
break;
case OPS.curveTo:
x = args[j + 4];
Expand Down
2 changes: 1 addition & 1 deletion src/display/text_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
i++;
}
var j = horizon.length - 1;
while(j >= 0 && horizon[j].start >= boundary.y2) {
while (j >= 0 && horizon[j].start >= boundary.y2) {
j--;
}

Expand Down
Loading

0 comments on commit e1fa6cf

Please sign in to comment.