Skip to content

Commit 43d6c6f

Browse files
committed
Merge pull request mozilla#2639 from jbuck/jshint
jshint experimentation
2 parents 74bfc3d + c226147 commit 43d6c6f

26 files changed

+255
-148
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ build/
44
tags
55
.DS_Store
66
Makefile
7+
node_modules/

.jshintrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
// Environments
3+
"browser": true,
4+
"devel": true,
5+
"es5": true,
6+
"worker": true,
7+
8+
// Enforcing
9+
10+
// Relaxing
11+
"boss": true,
12+
"funcscope": true,
13+
"globalstrict": true,
14+
"loopfunc": true,
15+
"maxerr": 1000,
16+
"nonstandard": true,
17+
"sub": true,
18+
"validthis": true
19+
}

external/builder/builder.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/* jshint node:true */
2+
/* globals cp, ls, test */
3+
4+
'use strict';
5+
16
require('../shelljs/make');
27
var fs = require('fs'),
38
path = require('path'),
@@ -30,7 +35,7 @@ function preprocess(inFilename, outFilename, defines) {
3035
var writeLine = typeof outFilename === 'function' ? outFilename :
3136
function(line) {
3237
out += line + '\n';
33-
}
38+
};
3439
function include(file) {
3540
var realPath = fs.realpathSync(inFilename);
3641
var dir = path.dirname(realPath);

external/crlfchecker/crlfchecker.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
22
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
3+
/* jshint node:true */
4+
/* globals cat, echo, exit, ls */
5+
6+
'use strict';
37

48
function checkIfCrlfIsPresent(files) {
59
var failed = [];

make.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
22
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
3+
/* jshint node:true */
4+
/* globals cat, cd, cp, echo, env, exec, exit, find, ls, mkdir, mv, process, rm, sed, target, test */
35

46
'use strict';
57

@@ -39,7 +41,7 @@ var DEFINES = {
3941
target.all = function() {
4042
// Don't do anything by default
4143
echo('Please specify a target. Available targets:');
42-
for (t in target)
44+
for (var t in target)
4345
if (t !== 'all') echo(' ' + t);
4446
};
4547

@@ -611,8 +613,9 @@ target.chrome = function() {
611613
exit(1);
612614
}
613615

616+
var manifest;
614617
try {
615-
var manifest = JSON.parse(cat(browserManifest));
618+
manifest = JSON.parse(cat(browserManifest));
616619
} catch (e) {
617620
echo('Malformed browser manifest file');
618621
echo(e.message);
@@ -971,6 +974,29 @@ target.lint = function() {
971974
crlfchecker.checkIfCrlfIsPresent(LINT_FILES);
972975
};
973976

977+
//
978+
// make jshint
979+
//
980+
target.jshint = function() {
981+
cd(ROOT_DIR);
982+
echo();
983+
echo('### Linting JS files (this can take a while!)');
984+
985+
var LINT_FILES = ['make.js',
986+
'external/builder/',
987+
'external/crlfchecker/',
988+
'src/',
989+
//'web/*.js',
990+
//'test/*.js',
991+
//'test/unit/*.js',
992+
//'extensions/firefox/*.js',
993+
//'extensions/firefox/components/*.js',
994+
//'extensions/chrome/*.js'
995+
];
996+
997+
exec('jshint --reporter test/reporter.js ' + LINT_FILES.join(' '));
998+
};
999+
9741000
//
9751001
// make clean
9761002
//

src/api.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
22
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
3+
/* globals CanvasGraphics, combineUrl, createScratchCanvas, error, ErrorFont, Font, FontLoader, globalScope, info, isArrayBuffer, loadJpegStream, MessageHandler, PDFJS, PDFObjects, Promise, StatTimer, warn, WorkerMessageHandler */
34
/* Copyright 2012 Mozilla Foundation
45
*
56
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -282,7 +283,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
282283
promise.reject(error);
283284
else
284285
promise.resolve();
285-
};
286+
}
286287
var continueCallback = params.continueCallback;
287288

288289
// Once the operatorList and fonts are loaded, do the actual rendering.
@@ -383,7 +384,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
383384

384385
var continueWrapper;
385386
if (continueCallback)
386-
continueWrapper = function() { continueCallback(next); }
387+
continueWrapper = function() { continueCallback(next); };
387388
else
388389
continueWrapper = next;
389390

src/bidi.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
22
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
3+
/* globals PDFJS */
34
/* Copyright 2012 Mozilla Foundation
45
*
56
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -68,11 +69,11 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
6869
];
6970

7071
function isOdd(i) {
71-
return (i & 1) != 0;
72+
return (i & 1) !== 0;
7273
}
7374

7475
function isEven(i) {
75-
return (i & 1) == 0;
76+
return (i & 1) === 0;
7677
}
7778

7879
function findUnequal(arr, start, value) {
@@ -146,8 +147,8 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
146147
function bidi(str, startLevel) {
147148
var isLTR = true;
148149
var strLength = str.length;
149-
if (strLength == 0)
150-
return new BidiResult(str, ltr);
150+
if (strLength === 0)
151+
return new BidiResult(str, isLTR);
151152

152153
// get types, fill arrays
153154

@@ -180,7 +181,7 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
180181
// if there are no rtl characters then no bidi needed
181182
// if less than 30% chars are rtl then string is primarily ltr
182183
// if more than 30% chars are rtl then string is primarily rtl
183-
if (numBidi == 0) {
184+
if (numBidi === 0) {
184185
isLTR = true;
185186
return new BidiResult(str, isLTR);
186187
}

src/canvas.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
22
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
3+
/* globals ColorSpace, DeviceCmykCS, DeviceGrayCS, DeviceRgbCS, error, FONT_IDENTITY_MATRIX, IDENTITY_MATRIX, ImageData, isArray, isNum, isString, Pattern, TilingPattern, TODO, Util, warn */
34
/* Copyright 2012 Mozilla Foundation
45
*
56
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -238,7 +239,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
238239
buf = imgArray[imgArrayPos++];
239240
mask = 128;
240241
}
241-
if (!(buf & mask) == inverseDecode) {
242+
if (!(buf & mask) === inverseDecode) {
242243
buffer[bufferPos] = 0;
243244
}
244245
bufferPos += 4;
@@ -932,7 +933,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
932933
var lineWidth = current.lineWidth;
933934
var a1 = current.textMatrix[0], b1 = current.textMatrix[1];
934935
var scale = Math.sqrt(a1 * a1 + b1 * b1);
935-
if (scale == 0 || lineWidth == 0)
936+
if (scale === 0 || lineWidth === 0)
936937
lineWidth = this.getSinglePixelWidth();
937938
else
938939
lineWidth /= scale;

src/colorspace.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
22
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
3+
/* globals error, info, input, isArray, isDict, isName, isStream, isString, PDFFunction, warn */
34
/* Copyright 2012 Mozilla Foundation
45
*
56
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -240,7 +241,7 @@ var ColorSpace = (function ColorSpaceClosure() {
240241
return true;
241242
}
242243
for (var i = 0, ii = decode.length; i < ii; i += 2) {
243-
if (decode[i] != 0 || decode[i + 1] != 1)
244+
if (decode[i] !== 0 || decode[i + 1] != 1)
244245
return false;
245246
}
246247
return true;
@@ -1288,7 +1289,7 @@ var LabCS = (function LabCSClosure() {
12881289
this.bmin = -100;
12891290
this.bmax = 100;
12901291
}
1291-
};
1292+
}
12921293

12931294
// Function g(x) from spec
12941295
function fn_g(x) {

src/core.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
22
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
3+
/* globals assertWellFormed, calculateMD5, Catalog, error, info, isArray, isArrayBuffer, isDict, isName, isStream, isString, Lexer, Linearization, NullStream, PartialEvaluator, shadow, Stream, StreamsSequenceStream, stringToPDFString, TODO, Util, warn, XRef */
34
/* Copyright 2012 Mozilla Foundation
45
*
56
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -76,7 +77,7 @@ function getPdf(arg, callback) {
7677
calledErrorBack = true;
7778
params.error();
7879
}
79-
}
80+
};
8081
}
8182

8283
xhr.onreadystatechange = function getPdfOnreadystatechange(e) {
@@ -156,7 +157,7 @@ var Page = (function PageClosure() {
156157
get rotate() {
157158
var rotate = this.inheritPageProp('Rotate') || 0;
158159
// Normalize rotation so it's a multiple of 90 and between 0 and 270
159-
if (rotate % 90 != 0) {
160+
if (rotate % 90 !== 0) {
160161
rotate = 0;
161162
} else if (rotate >= 360) {
162163
rotate = rotate % 360;

0 commit comments

Comments
 (0)