Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b9707d9

Browse files
vojtajinaIgorMinar
authored andcommitted
style(): get rid off some jsl warnings
1 parent 5bbd64a commit b9707d9

File tree

5 files changed

+38
-34
lines changed

5 files changed

+38
-34
lines changed

src/service/http.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,17 @@ function transform(data, fns, param) {
6161
* @description
6262
*/
6363
function $HttpProvider() {
64+
var JSON_START = /^\s*[\[\{]/,
65+
JSON_END = /[\}\]]\s*$/,
66+
PROTECTION_PREFIX = /^\)\]\}',?\n/;
67+
6468
var $config = this.defaults = {
6569
// transform in-coming reponse data
6670
transformResponse: function(data) {
6771
if (isString(data)) {
6872
// strip json vulnerability protection prefix
69-
data = data.replace(/^\)\]\}',?\n/, '');
70-
if (/^\s*[\[\{]/.test(data) && /[\}\]]\s*$/.test(data))
73+
data = data.replace(PROTECTION_PREFIX, '');
74+
if (JSON_START.test(data) && JSON_END.test(data))
7175
data = fromJson(data, true);
7276
}
7377
return data;
@@ -313,9 +317,9 @@ function $HttpProvider() {
313317
*/
314318
function headers(name) {
315319
if (name) {
316-
return parsedHeaders
317-
? parsedHeaders[lowercase(name)] || null
318-
: rawRequest.getResponseHeader(name);
320+
return parsedHeaders ?
321+
parsedHeaders[lowercase(name)] || null :
322+
rawRequest.getResponseHeader(name);
319323
}
320324

321325
parsedHeaders = parsedHeaders || parseHeaders(rawRequest.getAllResponseHeaders());

src/service/location.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ function encodePath(path) {
2525

2626

2727
function matchUrl(url, obj) {
28-
var match = URL_MATCH.exec(url),
28+
var match = URL_MATCH.exec(url);
2929

3030
match = {
3131
protocol: match[1],
3232
host: match[3],
33-
port: parseInt(match[5]) || DEFAULT_PORTS[match[1]] || null,
33+
port: parseInt(match[5], 10) || DEFAULT_PORTS[match[1]] || null,
3434
path: match[6] || '/',
3535
search: match[8],
3636
hash: match[10]
@@ -61,7 +61,7 @@ function convertToHtml5Url(url, basePath, hashPrefix) {
6161

6262
// already html5 url
6363
if (decodeURIComponent(match.path) != basePath || isUndefined(match.hash) ||
64-
match.hash.indexOf(hashPrefix) != 0) {
64+
match.hash.indexOf(hashPrefix) !== 0) {
6565
return url;
6666
// convert hashbang url -> html5 url
6767
} else {
@@ -84,7 +84,7 @@ function convertToHashbangUrl(url, basePath, hashPrefix) {
8484
pathPrefix = pathPrefixFromBase(basePath),
8585
path = match.path.substr(pathPrefix.length);
8686

87-
if (match.path.indexOf(pathPrefix) != 0) {
87+
if (match.path.indexOf(pathPrefix) !== 0) {
8888
throw 'Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !';
8989
}
9090

@@ -113,7 +113,7 @@ function LocationUrl(url, pathPrefix) {
113113
this.$$parse = function(url) {
114114
var match = matchUrl(url, this);
115115

116-
if (match.path.indexOf(pathPrefix) != 0) {
116+
if (match.path.indexOf(pathPrefix) !== 0) {
117117
throw 'Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !';
118118
}
119119

@@ -122,7 +122,7 @@ function LocationUrl(url, pathPrefix) {
122122
this.$$hash = match.hash && decodeURIComponent(match.hash) || '';
123123

124124
this.$$compose();
125-
},
125+
};
126126

127127
/**
128128
* Compose url and update `absUrl` property
@@ -160,7 +160,7 @@ function LocationHashbangUrl(url, hashPrefix) {
160160
this.$$parse = function(url) {
161161
var match = matchUrl(url, this);
162162

163-
if (match.hash && match.hash.indexOf(hashPrefix) != 0) {
163+
if (match.hash && match.hash.indexOf(hashPrefix) !== 0) {
164164
throw 'Invalid url "' + url + '", missing hash prefix "' + hashPrefix + '" !';
165165
}
166166

src/widgets.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ angularWidget('@ng:repeat', function(expression, element){
434434
childScope[valueIdent] = value;
435435
if (keyIdent) childScope[keyIdent] = key;
436436
childScope.$index = index;
437-
childScope.$position = index == 0
438-
? 'first'
439-
: (index == collectionLength - 1 ? 'last' : 'middle');
437+
childScope.$position = index === 0 ?
438+
'first' :
439+
(index == collectionLength - 1 ? 'last' : 'middle');
440440

441441
if (!last) {
442442
linker(childScope, function(clone){

test/angular-mocksSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,8 @@ describe('mocks', function() {
697697

698698
hb('POST', '/u1', 'ddd', noop, {});
699699

700-
expect(function() {hb.verifyNoOutstandingExpectation();})
701-
.toThrow('Unsatisfied requests: GET /u2, POST /u3');
700+
expect(function() {hb.verifyNoOutstandingExpectation();}).
701+
toThrow('Unsatisfied requests: GET /u2, POST /u3');
702702
});
703703

704704

test/service/httpSpec.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ describe('$http', function() {
6161

6262
it('should log more exceptions', function() {
6363
$httpBackend.expect('GET', '/url').respond(500, '');
64-
$http({url: '/url', method: 'GET'})
65-
.on('500', throwing('exception in error callback'))
66-
.on('5xx', throwing('exception in error callback'));
64+
$http({url: '/url', method: 'GET'}).
65+
on('500', throwing('exception in error callback')).
66+
on('5xx', throwing('exception in error callback'));
6767
$httpBackend.flush();
6868

6969
expect($exceptionHandler.errors.length).toBe(2);
@@ -491,7 +491,7 @@ describe('$http', function() {
491491

492492
beforeEach(function() {
493493
$httpBackend.when('GET').respond(function(m, url) {
494-
return [parseInt(url.substr(1)), '', {}];
494+
return [parseInt(url.substr(1), 10), '', {}];
495495
});
496496
});
497497

@@ -550,13 +550,13 @@ describe('$http', function() {
550550

551551
it('should call all matched callbacks', function() {
552552
var no = jasmine.createSpy('wrong');
553-
$http({method: 'GET', url: '/205'})
554-
.on('xxx', callback)
555-
.on('2xx', callback)
556-
.on('205', callback)
557-
.on('3xx', no)
558-
.on('2x1', no)
559-
.on('4xx', no);
553+
$http({method: 'GET', url: '/205'}).
554+
on('xxx', callback).
555+
on('2xx', callback).
556+
on('205', callback).
557+
on('3xx', no).
558+
on('2x1', no).
559+
on('4xx', no);
560560

561561
$httpBackend.flush();
562562

@@ -576,10 +576,10 @@ describe('$http', function() {
576576
it('should preserve the order of listeners', function() {
577577
var log = '';
578578

579-
$http({method: 'GET', url: '/201'})
580-
.on('2xx', function() {log += '1';})
581-
.on('201', function() {log += '2';})
582-
.on('2xx', function() {log += '3';});
579+
$http({method: 'GET', url: '/201'}).
580+
on('2xx', function() {log += '1';}).
581+
on('201', function() {log += '2';}).
582+
on('2xx', function() {log += '3';});
583583

584584
$httpBackend.flush();
585585
expect(log).toBe('123');
@@ -766,8 +766,8 @@ describe('$http', function() {
766766
function second(d) {return d + '2';}
767767

768768
$httpBackend.expect('POST', '/url').respond('0');
769-
$http({method: 'POST', url: '/url', transformResponse: [first, second]})
770-
.on('200', callback);
769+
$http({method: 'POST', url: '/url', transformResponse: [first, second]}).
770+
on('200', callback);
771771
$httpBackend.flush();
772772

773773
expect(callback).toHaveBeenCalledOnce();

0 commit comments

Comments
 (0)