Skip to content

Commit accd35b

Browse files
shahatapetebacondarwin
authored andcommitted
chore(jshint): enforce jshint for tests
Closes angular#7264
1 parent e16c6aa commit accd35b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1365
-1212
lines changed

Gruntfile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ module.exports = function(grunt) {
107107
options: {
108108
jshintrc: true,
109109
},
110+
tests: {
111+
files: { src: 'test/**/*.js' },
112+
},
110113
ng: {
111114
files: { src: files['angularSrc'] },
112115
},

test/.jshintrc

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"sub": true,
1717
"undef": true,
1818
"browser": true,
19+
"indent": 2,
1920
"globals": {
2021
/* auto/injector.js */
2122
"createInjector": false,
@@ -42,7 +43,6 @@
4243
"isArrayLike": false,
4344
"forEach": false,
4445
"sortedKeys": false,
45-
"forEachSorted": false,
4646
"reverseParams": false,
4747
"nextUid": false,
4848
"setHashKey": false,
@@ -102,9 +102,6 @@
102102
"getter": false,
103103
"getBlockElements": false,
104104

105-
/* filters.js */
106-
"getFirstThursdayOfYear": false,
107-
108105
/* AngularPublic.js */
109106
"version": false,
110107
"publishExternalAPI": false,
@@ -147,24 +144,6 @@
147144
"urlResolve": false,
148145
"urlIsSameOrigin": false,
149146

150-
/* ng/compile.js */
151-
"directiveNormalize": false,
152-
153-
/* ng/parse.js */
154-
"setter": false,
155-
156-
/* ng/directive/directives.js */
157-
"ngDirective": false,
158-
159-
/* ng/directive/input.js */
160-
"VALID_CLASS": false,
161-
"INVALID_CLASS": false,
162-
"PRISTINE_CLASS": false,
163-
"DIRTY_CLASS": false,
164-
165-
/* ng/directive/form.js */
166-
"nullFormCtrl": false,
167-
168147
/* jasmine / karma */
169148
"it": false,
170149
"iit": false,
@@ -175,10 +154,29 @@
175154
"expect": false,
176155
"jasmine": false,
177156
"spyOn": false,
157+
"waits": false,
158+
"waitsFor": false,
159+
"runs": false,
160+
"dump": false,
161+
162+
/* e2e */
163+
"browser": false,
164+
"element": false,
165+
"by": false,
178166

179167
/* testabilityPatch / matchers */
180168
"inject": false,
181169
"module": false,
182-
"dealoc": false
170+
"dealoc": false,
171+
"_jQuery": false,
172+
"_jqLiteMode": false,
173+
"sortedHtml": false,
174+
"childrenTagsOf": false,
175+
"assertHidden": false,
176+
"assertVisible": false,
177+
"provideLog": false,
178+
"spyOnlyCallsWithArgs": false,
179+
"createMockStyleSheet": false,
180+
"browserTrigger": false
183181
}
184182
}

test/AngularSpec.js

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe('angular', function() {
118118

119119
it('should throw an exception when source and destination are equivalent', function() {
120120
var src, dst;
121-
src = dst = {key: 'value'};
121+
src = dst = {key: 'value'};
122122
expect(function() { copy(src, dst); }).toThrowMinErr("ng", "cpi", "Can't copy! Source and destination are identical.");
123123
src = dst = [2, 4];
124124
expect(function() { copy(src, dst); }).toThrowMinErr("ng", "cpi", "Can't copy! Source and destination are identical.");
@@ -149,7 +149,6 @@ describe('angular', function() {
149149
});
150150

151151
describe("extend", function() {
152-
153152
it('should not copy the private $$hashKey', function() {
154153
var src,dst;
155154
src = {};
@@ -209,7 +208,7 @@ describe('angular', function() {
209208

210209
it('should omit properties from prototype chain', function() {
211210
var original, clone = {};
212-
function Func() {};
211+
function Func() {}
213212
Func.prototype.hello = "world";
214213

215214
original = new Func();
@@ -316,6 +315,7 @@ describe('angular', function() {
316315
});
317316

318317
it('should correctly test for keys that are present on Object.prototype', function() {
318+
/* jshint -W001 */
319319
// MS IE8 just doesn't work for this kind of thing, since "for ... in" doesn't return
320320
// things like hasOwnProperty even if it is explicitly defined on the actual object!
321321
if (msie<=8) return;
@@ -457,7 +457,7 @@ describe('angular', function() {
457457
expect(toKeyValue({key: [323,'value',true]})).toEqual('key=323&key=value&key');
458458
expect(toKeyValue({key: [323,'value',true, 1234]})).
459459
toEqual('key=323&key=value&key&key=1234');
460-
});
460+
});
461461
});
462462

463463

@@ -472,13 +472,14 @@ describe('angular', function() {
472472
var obj = new MyObj(),
473473
log = [];
474474

475-
forEach(obj, function(value, key) { log.push(key + ':' + value)});
475+
forEach(obj, function(value, key) { log.push(key + ':' + value); });
476476

477477
expect(log).toEqual(['bar:barVal', 'baz:bazVal']);
478478
});
479479

480480

481481
it('should not break if obj is an array we override hasOwnProperty', function() {
482+
/* jshint -W001 */
482483
var obj = [];
483484
obj[0] = 1;
484485
obj[1] = 2;
@@ -506,7 +507,7 @@ describe('angular', function() {
506507
log = [];
507508

508509

509-
forEach(nodeList, function(value, key) { log.push(key + ':' + value.innerHTML)});
510+
forEach(nodeList, function(value, key) { log.push(key + ':' + value.innerHTML); });
510511
expect(log).toEqual(['0:a', '1:b', '2:c']);
511512
});
512513

@@ -521,7 +522,7 @@ describe('angular', function() {
521522
var htmlCollection = document.getElementsByName('x'),
522523
log = [];
523524

524-
forEach(htmlCollection, function(value, key) { log.push(key + ':' + value.innerHTML)});
525+
forEach(htmlCollection, function(value, key) { log.push(key + ':' + value.innerHTML); });
525526
expect(log).toEqual(['0:a', '1:c']);
526527
});
527528

@@ -536,7 +537,7 @@ describe('angular', function() {
536537
var htmlCollection = document.querySelectorAll('[name="x"]'),
537538
log = [];
538539

539-
forEach(htmlCollection, function(value, key) { log.push(key + ':' + value.innerHTML)});
540+
forEach(htmlCollection, function(value, key) { log.push(key + ':' + value.innerHTML); });
540541
expect(log).toEqual(['0:a', '1:c']);
541542
});
542543
}
@@ -545,42 +546,42 @@ describe('angular', function() {
545546
var args,
546547
log = [];
547548

548-
(function(){ args = arguments}('a', 'b', 'c'));
549+
(function(){ args = arguments; }('a', 'b', 'c'));
549550

550-
forEach(args, function(value, key) { log.push(key + ':' + value)});
551+
forEach(args, function(value, key) { log.push(key + ':' + value); });
551552
expect(log).toEqual(['0:a', '1:b', '2:c']);
552553
});
553554

554555
it('should handle string values like arrays', function() {
555556
var log = [];
556557

557-
forEach('bar', function(value, key) { log.push(key + ':' + value)});
558+
forEach('bar', function(value, key) { log.push(key + ':' + value); });
558559
expect(log).toEqual(['0:b', '1:a', '2:r']);
559560
});
560561

561562

562563
it('should handle objects with length property as objects', function() {
563564
var obj = {
564-
'foo' : 'bar',
565-
'length': 2
566-
},
567-
log = [];
565+
'foo' : 'bar',
566+
'length': 2
567+
},
568+
log = [];
568569

569-
forEach(obj, function(value, key) { log.push(key + ':' + value)});
570+
forEach(obj, function(value, key) { log.push(key + ':' + value); });
570571
expect(log).toEqual(['foo:bar', 'length:2']);
571572
});
572573

573574

574575
it('should handle objects of custom types with length property as objects', function() {
575576
function CustomType() {
576577
this.length = 2;
577-
this.foo = 'bar'
578+
this.foo = 'bar';
578579
}
579580

580581
var obj = new CustomType(),
581582
log = [];
582583

583-
forEach(obj, function(value, key) { log.push(key + ':' + value)});
584+
forEach(obj, function(value, key) { log.push(key + ':' + value); });
584585
expect(log).toEqual(['length:2', 'foo:bar']);
585586
});
586587
});
@@ -748,9 +749,11 @@ describe('angular', function() {
748749
var appElement = jqLite('<div ng-app="doesntexist"></div>')[0];
749750

750751
expect(function() {
751-
angularInit(appElement, bootstrap);
752+
angularInit(appElement, angular.bootstrap);
752753
}).toThrowMatching(
753-
/\[\$injector:modulerr] Failed to instantiate module doesntexist due to:\n.*\[\$injector:nomod] Module 'doesntexist' is not available! You either misspelled the module name or forgot to load it\./
754+
new RegExp('\\[\\$injector:modulerr] Failed to instantiate module doesntexist due to:\\n' +
755+
'.*\\[\\$injector:nomod] Module \'doesntexist\' is not available! You either ' +
756+
'misspelled the module name or forgot to load it\\.')
754757
);
755758
});
756759

@@ -789,7 +792,7 @@ describe('angular', function() {
789792
expect(bootstrapSpy.mostRecentCall.args[2].strictDi).toBe(true);
790793

791794
var injector = appElement.injector();
792-
function testFactory($rootScope) {};
795+
function testFactory($rootScope) {}
793796
expect(function() {
794797
injector.instantiate(testFactory);
795798
}).toThrowMinErr('$injector', 'strictdi');
@@ -956,7 +959,9 @@ describe('angular', function() {
956959
expect(function() {
957960
angular.bootstrap(element, ['doesntexist']);
958961
}).toThrowMatching(
959-
/\[\$injector:modulerr\] Failed to instantiate module doesntexist due to:\n.*\[\$injector:nomod\] Module 'doesntexist' is not available! You either misspelled the module name or forgot to load it\./);
962+
new RegExp('\\[\\$injector:modulerr\\] Failed to instantiate module doesntexist due to:\\n' +
963+
'.*\\[\\$injector:nomod\\] Module \'doesntexist\' is not available! You either ' +
964+
'misspelled the module name or forgot to load it\\.'));
960965

961966
expect(element.html()).toBe('{{1+2}}');
962967
dealoc(element);

0 commit comments

Comments
 (0)