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

Commit 06016bb

Browse files
hzoopkozlowski-opensource
authored andcommitted
style(*): add rules requireSpace(After|Before)BinaryOperators
1 parent 50e72fc commit 06016bb

Some content is hidden

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

46 files changed

+253
-253
lines changed

.jscs.json

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"disallowTrailingWhitespace": true,
2424
"requireCommaBeforeLineBreak": true,
2525
"requireLineFeedAtFileEnd": true,
26+
"requireSpaceAfterBinaryOperators": ["?", ":", "+", "-", "/", "*", "%", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "&&", "||"],
27+
"requireSpaceBeforeBinaryOperators": ["?", ":", "+", "-", "/", "*", "%", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "&&", "||"],
2628
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
2729
"requireSpaceBeforeBlockStatements": true,
2830
"requireSpacesInFunction": {

.jscs.json.todo

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
{
77
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
8-
"requireSpaceAfterBinaryOperators": ["?", ":", "+", "-", "/", "*", "%", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "&&", "||"],
9-
"requireSpaceBeforeBinaryOperators": ["?", ":", "+", "-", "/", "*", "%", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "&&", "||"],
108
"disallowImplicitTypeConversion": ["string"],
119
"disallowMultipleLineBreaks": true,
1210
"disallowKeywordsOnNewLine": ["else"],

src/Angular.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ function includes(array, obj) {
634634

635635
function arrayRemove(array, value) {
636636
var index = array.indexOf(value);
637-
if (index >=0)
637+
if (index >= 0)
638638
array.splice(index, 1);
639639
return value;
640640
}
@@ -835,7 +835,7 @@ function equals(o1, o2) {
835835
if (isArray(o1)) {
836836
if (!isArray(o2)) return false;
837837
if ((length = o1.length) == o2.length) {
838-
for (key=0; key<length; key++) {
838+
for (key = 0; key < length; key++) {
839839
if (!equals(o1[key], o2[key])) return false;
840840
}
841841
return true;
@@ -1121,7 +1121,7 @@ var ngAttrPrefixes = ['ng-', 'data-ng-', 'ng:', 'x-ng-'];
11211121
function getNgAttribute(element, ngAttr) {
11221122
var attr, i, ii = ngAttrPrefixes.length;
11231123
element = jqLite(element);
1124-
for (i=0; i<ii; ++i) {
1124+
for (i = 0; i < ii; ++i) {
11251125
attr = ngAttrPrefixes[i] + ngAttr;
11261126
if (isString(attr = element.attr(attr))) {
11271127
return attr;

src/jqLite.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ forEach({
597597
}
598598
} else {
599599
return (element[name] ||
600-
(element.attributes.getNamedItem(name)|| noop).specified)
600+
(element.attributes.getNamedItem(name) || noop).specified)
601601
? lowercasedName
602602
: undefined;
603603
}

src/minErr.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function minErr(module, ErrorConstructor) {
6969
message = message + '\nhttp://errors.angularjs.org/"NG_VERSION_FULL"/' +
7070
(module ? module + '/' : '') + code;
7171
for (i = 2; i < arguments.length; i++) {
72-
message = message + (i == 2 ? '?' : '&') + 'p' + (i-2) + '=' +
72+
message = message + (i == 2 ? '?' : '&') + 'p' + (i - 2) + '=' +
7373
encodeURIComponent(stringify(arguments[i]));
7474
}
7575
return new ErrorConstructor(message);

src/ng/browser.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ function Browser(window, document, $log, $sniffer) {
370370
// - 20 cookies per unique domain
371371
// - 4096 bytes per cookie
372372
if (cookieLength > 4096) {
373-
$log.warn("Cookie '"+ name +
374-
"' possibly not set or overflowed because it was too large ("+
373+
$log.warn("Cookie '" + name +
374+
"' possibly not set or overflowed because it was too large (" +
375375
cookieLength + " > 4096 bytes)!");
376376
}
377377
}

src/ng/compile.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1029,16 +1029,16 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
10291029

10301030
// for each tuples
10311031
var nbrUrisWith2parts = Math.floor(rawUris.length / 2);
1032-
for (var i=0; i<nbrUrisWith2parts; i++) {
1033-
var innerIdx = i*2;
1032+
for (var i = 0; i < nbrUrisWith2parts; i++) {
1033+
var innerIdx = i * 2;
10341034
// sanitize the uri
10351035
result += $$sanitizeUri(trim(rawUris[innerIdx]), true);
10361036
// add the descriptor
1037-
result += (" " + trim(rawUris[innerIdx+1]));
1037+
result += (" " + trim(rawUris[innerIdx + 1]));
10381038
}
10391039

10401040
// split the last item into uri and descriptor
1041-
var lastTuple = trim(rawUris[i*2]).split(/\s/);
1041+
var lastTuple = trim(rawUris[i * 2]).split(/\s/);
10421042

10431043
// sanitize the last uri
10441044
result += $$sanitizeUri(trim(lastTuple[0]), true);
@@ -2045,7 +2045,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
20452045
var match = null;
20462046
if (hasDirectives.hasOwnProperty(name)) {
20472047
for (var directive, directives = $injector.get(name + Suffix),
2048-
i = 0, ii = directives.length; i<ii; i++) {
2048+
i = 0, ii = directives.length; i < ii; i++) {
20492049
try {
20502050
directive = directives[i];
20512051
if ((maxPriority === undefined || maxPriority > directive.priority) &&
@@ -2074,7 +2074,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
20742074
function directiveIsMultiElement(name) {
20752075
if (hasDirectives.hasOwnProperty(name)) {
20762076
for (var directive, directives = $injector.get(name + Suffix),
2077-
i = 0, ii = directives.length; i<ii; i++) {
2077+
i = 0, ii = directives.length; i < ii; i++) {
20782078
directive = directives[i];
20792079
if (directive.multiElement) {
20802080
return true;
@@ -2293,7 +2293,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
22932293
case 'svg':
22942294
case 'math':
22952295
var wrapper = document.createElement('div');
2296-
wrapper.innerHTML = '<'+type+'>'+template+'</'+type+'>';
2296+
wrapper.innerHTML = '<' + type + '>' + template + '</' + type + '>';
22972297
return wrapper.childNodes[0].childNodes;
22982298
default:
22992299
return template;

src/ng/directive/input.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,8 @@ function createDateParser(regexp, mapping) {
10631063
// When a date is JSON'ified to wraps itself inside of an extra
10641064
// set of double quotes. This makes the date parsing code unable
10651065
// to match the date string and parse it as a date.
1066-
if (iso.charAt(0) == '"' && iso.charAt(iso.length-1) == '"') {
1067-
iso = iso.substring(1, iso.length-1);
1066+
if (iso.charAt(0) == '"' && iso.charAt(iso.length - 1) == '"') {
1067+
iso = iso.substring(1, iso.length - 1);
10681068
}
10691069
if (ISO_DATE_REGEXP.test(iso)) {
10701070
return new Date(iso);

src/ng/directive/select.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
616616
lastElement = null; // start at the beginning
617617
for (index = 0, length = optionGroup.length; index < length; index++) {
618618
option = optionGroup[index];
619-
if ((existingOption = existingOptions[index+1])) {
619+
if ((existingOption = existingOptions[index + 1])) {
620620
// reuse elements
621621
lastElement = existingOption.element;
622622
if (existingOption.label !== option.label) {

src/ng/filter/filter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ function filterFilter() {
147147
}
148148
return false;
149149
}
150-
text = (''+text).toLowerCase();
151-
return (''+obj).toLowerCase().indexOf(text) > -1;
150+
text = ('' + text).toLowerCase();
151+
return ('' + obj).toLowerCase().indexOf(text) > -1;
152152
};
153153
}
154154
}

src/ng/filter/filters.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,15 @@ function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
187187
if (whole.length >= (lgroup + group)) {
188188
pos = whole.length - lgroup;
189189
for (i = 0; i < pos; i++) {
190-
if ((pos - i)%group === 0 && i !== 0) {
190+
if ((pos - i) % group === 0 && i !== 0) {
191191
formatedText += groupSep;
192192
}
193193
formatedText += whole.charAt(i);
194194
}
195195
}
196196

197197
for (i = pos; i < whole.length; i++) {
198-
if ((whole.length - i)%lgroup === 0 && i !== 0) {
198+
if ((whole.length - i) % lgroup === 0 && i !== 0) {
199199
formatedText += groupSep;
200200
}
201201
formatedText += whole.charAt(i);
@@ -435,10 +435,10 @@ function dateFilter($locale) {
435435
tzMin = int(match[9] + match[11]);
436436
}
437437
dateSetter.call(date, int(match[1]), int(match[2]) - 1, int(match[3]));
438-
var h = int(match[4]||0) - tzHour;
439-
var m = int(match[5]||0) - tzMin;
440-
var s = int(match[6]||0);
441-
var ms = Math.round(parseFloat('0.' + (match[7]||0)) * 1000);
438+
var h = int(match[4] || 0) - tzHour;
439+
var m = int(match[5] || 0) - tzMin;
440+
var s = int(match[6] || 0);
441+
var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
442442
timeSetter.call(date, h, m, s, ms);
443443
return date;
444444
}

src/ng/filter/limitTo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function limitToFilter() {
123123
n = input.length;
124124
}
125125

126-
for (; i<n; i++) {
126+
for (; i < n; i++) {
127127
out.push(input[i]);
128128
}
129129

src/ng/parse.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function ensureSafeMemberName(name, fullExpression) {
3232
|| name === "__proto__") {
3333
throw $parseMinErr('isecfld',
3434
'Attempting to access a disallowed field in Angular expressions! '
35-
+'Expression: {0}', fullExpression);
35+
+ 'Expression: {0}', fullExpression);
3636
}
3737
return name;
3838
}
@@ -112,21 +112,21 @@ var OPERATORS = extend(createMap(), {
112112
return isDefined(b)?b:undefined;},
113113
'-':function(self, locals, a, b) {
114114
a=a(self, locals); b=b(self, locals);
115-
return (isDefined(a)?a:0)-(isDefined(b)?b:0);
115+
return (isDefined(a)?a:0) - (isDefined(b)?b:0);
116116
},
117-
'*':function(self, locals, a, b) {return a(self, locals)*b(self, locals);},
118-
'/':function(self, locals, a, b) {return a(self, locals)/b(self, locals);},
119-
'%':function(self, locals, a, b) {return a(self, locals)%b(self, locals);},
120-
'===':function(self, locals, a, b) {return a(self, locals)===b(self, locals);},
121-
'!==':function(self, locals, a, b) {return a(self, locals)!==b(self, locals);},
122-
'==':function(self, locals, a, b) {return a(self, locals)==b(self, locals);},
123-
'!=':function(self, locals, a, b) {return a(self, locals)!=b(self, locals);},
124-
'<':function(self, locals, a, b) {return a(self, locals)<b(self, locals);},
125-
'>':function(self, locals, a, b) {return a(self, locals)>b(self, locals);},
126-
'<=':function(self, locals, a, b) {return a(self, locals)<=b(self, locals);},
127-
'>=':function(self, locals, a, b) {return a(self, locals)>=b(self, locals);},
128-
'&&':function(self, locals, a, b) {return a(self, locals)&&b(self, locals);},
129-
'||':function(self, locals, a, b) {return a(self, locals)||b(self, locals);},
117+
'*':function(self, locals, a, b) {return a(self, locals) * b(self, locals);},
118+
'/':function(self, locals, a, b) {return a(self, locals) / b(self, locals);},
119+
'%':function(self, locals, a, b) {return a(self, locals) % b(self, locals);},
120+
'===':function(self, locals, a, b) {return a(self, locals) === b(self, locals);},
121+
'!==':function(self, locals, a, b) {return a(self, locals) !== b(self, locals);},
122+
'==':function(self, locals, a, b) {return a(self, locals) == b(self, locals);},
123+
'!=':function(self, locals, a, b) {return a(self, locals) != b(self, locals);},
124+
'<':function(self, locals, a, b) {return a(self, locals) < b(self, locals);},
125+
'>':function(self, locals, a, b) {return a(self, locals) > b(self, locals);},
126+
'<=':function(self, locals, a, b) {return a(self, locals) <= b(self, locals);},
127+
'>=':function(self, locals, a, b) {return a(self, locals) >= b(self, locals);},
128+
'&&':function(self, locals, a, b) {return a(self, locals) && b(self, locals);},
129+
'||':function(self, locals, a, b) {return a(self, locals) || b(self, locals);},
130130
'!':function(self, locals, a) {return !a(self, locals);},
131131

132132
//Tokenized as operators but parsed as assignment/filters

src/ng/rootScope.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ function $RootScopeProvider() {
11611161
do {
11621162
namedListeners = scope.$$listeners[name] || empty;
11631163
event.currentScope = scope;
1164-
for (i=0, length=namedListeners.length; i<length; i++) {
1164+
for (i = 0, length = namedListeners.length; i < length; i++) {
11651165

11661166
// if listeners were deregistered, defragment the array
11671167
if (!namedListeners[i]) {
@@ -1235,7 +1235,7 @@ function $RootScopeProvider() {
12351235
while ((current = next)) {
12361236
event.currentScope = current;
12371237
listeners = current.$$listeners[name] || [];
1238-
for (i=0, length = listeners.length; i<length; i++) {
1238+
for (i = 0, length = listeners.length; i < length; i++) {
12391239
// if listeners were deregistered, defragment the array
12401240
if (!listeners[i]) {
12411241
listeners.splice(i, 1);

src/ng/sanitizeUri.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function $$SanitizeUriProvider() {
6363
var normalizedVal;
6464
normalizedVal = urlResolve(uri).href;
6565
if (normalizedVal !== '' && !normalizedVal.match(regex)) {
66-
return 'unsafe:'+normalizedVal;
66+
return 'unsafe:' + normalizedVal;
6767
}
6868
return uri;
6969
};

src/ng/sniffer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function $SnifferProvider() {
4444
transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle));
4545
animations = !!(('animation' in bodyStyle) || (vendorPrefix + 'Animation' in bodyStyle));
4646

47-
if (android && (!transitions||!animations)) {
47+
if (android && (!transitions || !animations)) {
4848
transitions = isString(document.body.style.webkitTransition);
4949
animations = isString(document.body.style.webkitAnimation);
5050
}

src/ng/templateRequest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function $TemplateRequestProvider() {
3030
if (isArray(transformResponse)) {
3131
var original = transformResponse;
3232
transformResponse = [];
33-
for (var i=0; i<original.length; ++i) {
33+
for (var i = 0; i < original.length; ++i) {
3434
var transformer = original[i];
3535
if (transformer !== defaultHttpResponseTransform) {
3636
transformResponse.push(transformer);

src/ngAnimate/animate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,7 @@ angular.module('ngAnimate', ['ng'])
18831883
//the jqLite object, so we're safe to use a single variable to house
18841884
//the styles since there is always only one element being animated
18851885
var oldStyle = node.getAttribute('style') || '';
1886-
if (oldStyle.charAt(oldStyle.length-1) !== ';') {
1886+
if (oldStyle.charAt(oldStyle.length - 1) !== ';') {
18871887
oldStyle += ';';
18881888
}
18891889
node.setAttribute('style', oldStyle + ' ' + style);

src/ngMock/angular-mocks.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ angular.mock.$Browser = function() {
110110
self.defer.now += delay;
111111
} else {
112112
if (self.deferredFns.length) {
113-
self.defer.now = self.deferredFns[self.deferredFns.length-1].time;
113+
self.defer.now = self.deferredFns[self.deferredFns.length - 1].time;
114114
} else {
115115
throw new Error('No deferred tasks to be flushed');
116116
}
@@ -421,7 +421,7 @@ angular.mock.$LogProvider = function() {
421421
});
422422
});
423423
if (errors.length) {
424-
errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or "+
424+
errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or " +
425425
"an expected log message was not checked and removed:");
426426
errors.push('');
427427
throw new Error(errors.join('\n---------\n'));
@@ -574,10 +574,10 @@ function jsonStringToDate(string) {
574574
tzMin = int(match[9] + match[11]);
575575
}
576576
date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3]));
577-
date.setUTCHours(int(match[4]||0) - tzHour,
578-
int(match[5]||0) - tzMin,
579-
int(match[6]||0),
580-
int(match[7]||0));
577+
date.setUTCHours(int(match[4] || 0) - tzHour,
578+
int(match[5] || 0) - tzMin,
579+
int(match[6] || 0),
580+
int(match[7] || 0));
581581
return date;
582582
}
583583
return string;
@@ -656,7 +656,7 @@ angular.mock.TzDate = function(offset, timestamp) {
656656
}
657657

658658
var localOffset = new Date(timestamp).getTimezoneOffset();
659-
self.offsetDiff = localOffset*60*1000 - offset*1000*60*60;
659+
self.offsetDiff = localOffset * 60 * 1000 - offset * 1000 * 60 * 60;
660660
self.date = new Date(timestamp + self.offsetDiff);
661661

662662
self.getTime = function() {
@@ -808,7 +808,7 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
808808
animate.queue.push({
809809
event: method,
810810
element: arguments[0],
811-
options: arguments[arguments.length-1],
811+
options: arguments[arguments.length - 1],
812812
args: arguments
813813
});
814814
return $delegate[method].apply($delegate, arguments);
@@ -1763,7 +1763,7 @@ angular.mock.$RAFDecorator = ['$delegate', function($delegate) {
17631763
}
17641764

17651765
var length = queue.length;
1766-
for (var i=0;i<length;i++) {
1766+
for (var i = 0; i < length; i++) {
17671767
queue[i]();
17681768
}
17691769

src/ngRoute/route.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ function $RouteProvider() {
153153

154154
// create redirection for trailing slashes
155155
if (path) {
156-
var redirectPath = (path[path.length-1] == '/')
157-
? path.substr(0, path.length-1)
158-
: path +'/';
156+
var redirectPath = (path[path.length - 1] == '/')
157+
? path.substr(0, path.length - 1)
158+
: path + '/';
159159

160160
routes[redirectPath] = angular.extend(
161161
{redirectTo: path},
@@ -634,7 +634,7 @@ function $RouteProvider() {
634634
*/
635635
function interpolate(string, params) {
636636
var result = [];
637-
angular.forEach((string||'').split(':'), function(segment, i) {
637+
angular.forEach((string || '').split(':'), function(segment, i) {
638638
if (i === 0) {
639639
result.push(segment);
640640
} else {

0 commit comments

Comments
 (0)