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

Commit 7f65f97

Browse files
hzoocaitp
authored andcommitted
style(*): add rule requireSpacesInFunction beforeOpeningCurlyBrace
This rule enforces a space after the curly brace for function declarations, anonymous function expressions, and named function expressions.
1 parent 9221628 commit 7f65f97

Some content is hidden

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

72 files changed

+324
-321
lines changed

.jscs.json

+3
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@
1616
"disallowTrailingComma": true,
1717
"disallowTrailingWhitespace": true,
1818
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
19+
"requireSpacesInFunction": {
20+
"beforeOpeningCurlyBrace": true
21+
},
1922
"validateParameterSeparator": ", "
2023
}

src/Angular.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ var VALIDITY_STATE_PROPERTY = 'validity';
123123
* @param {string} string String to be converted to lowercase.
124124
* @returns {string} Lowercased string.
125125
*/
126-
var lowercase = function(string){return isString(string) ? string.toLowerCase() : string;};
126+
var lowercase = function(string) {return isString(string) ? string.toLowerCase() : string;};
127127
var hasOwnProperty = Object.prototype.hasOwnProperty;
128128

129129
/**
@@ -136,7 +136,7 @@ var hasOwnProperty = Object.prototype.hasOwnProperty;
136136
* @param {string} string String to be converted to uppercase.
137137
* @returns {string} Uppercased string.
138138
*/
139-
var uppercase = function(string){return isString(string) ? string.toUpperCase() : string;};
139+
var uppercase = function(string) {return isString(string) ? string.toUpperCase() : string;};
140140

141141

142142
var manualLowercase = function(s) {
@@ -419,7 +419,7 @@ function valueFn(value) {return function() {return value;};}
419419
* @param {*} value Reference to check.
420420
* @returns {boolean} True if `value` is undefined.
421421
*/
422-
function isUndefined(value){return typeof value === 'undefined';}
422+
function isUndefined(value) {return typeof value === 'undefined';}
423423

424424

425425
/**
@@ -434,7 +434,7 @@ function isUndefined(value){return typeof value === 'undefined';}
434434
* @param {*} value Reference to check.
435435
* @returns {boolean} True if `value` is defined.
436436
*/
437-
function isDefined(value){return typeof value !== 'undefined';}
437+
function isDefined(value) {return typeof value !== 'undefined';}
438438

439439

440440
/**
@@ -450,7 +450,7 @@ function isDefined(value){return typeof value !== 'undefined';}
450450
* @param {*} value Reference to check.
451451
* @returns {boolean} True if `value` is an `Object` but not `null`.
452452
*/
453-
function isObject(value){
453+
function isObject(value) {
454454
// http://jsperf.com/isobject4
455455
return value !== null && typeof value === 'object';
456456
}
@@ -468,7 +468,7 @@ function isObject(value){
468468
* @param {*} value Reference to check.
469469
* @returns {boolean} True if `value` is a `String`.
470470
*/
471-
function isString(value){return typeof value === 'string';}
471+
function isString(value) {return typeof value === 'string';}
472472

473473

474474
/**
@@ -483,7 +483,7 @@ function isString(value){return typeof value === 'string';}
483483
* @param {*} value Reference to check.
484484
* @returns {boolean} True if `value` is a `Number`.
485485
*/
486-
function isNumber(value){return typeof value === 'number';}
486+
function isNumber(value) {return typeof value === 'number';}
487487

488488

489489
/**
@@ -529,7 +529,7 @@ var isArray = Array.isArray;
529529
* @param {*} value Reference to check.
530530
* @returns {boolean} True if `value` is a `Function`.
531531
*/
532-
function isFunction(value){return typeof value === 'function';}
532+
function isFunction(value) {return typeof value === 'function';}
533533

534534

535535
/**

src/AngularPublic.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ var version = {
110110
};
111111

112112

113-
function publishExternalAPI(angular){
113+
function publishExternalAPI(angular) {
114114
extend(angular, {
115115
'bootstrap': bootstrap,
116116
'copy': copy,

src/auto/injector.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ function createInjector(modulesToLoad, strictDi) {
705705
////////////////////////////////////
706706
// Module Loading
707707
////////////////////////////////////
708-
function loadModules(modulesToLoad){
708+
function loadModules(modulesToLoad) {
709709
var runBlocks = [], moduleFn;
710710
forEach(modulesToLoad, function(module) {
711711
if (loadedModules.get(module)) return;

src/jqLite.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ function jqLiteClone(element) {
251251
return element.cloneNode(true);
252252
}
253253

254-
function jqLiteDealoc(element, onlyDescendants){
254+
function jqLiteDealoc(element, onlyDescendants) {
255255
if (!onlyDescendants) jqLiteRemoveData(element);
256256

257257
if (element.querySelectorAll) {
@@ -493,7 +493,7 @@ var JQLitePrototype = JQLite.prototype = {
493493
},
494494
toString: function() {
495495
var value = [];
496-
forEach(this, function(e){ value.push('' + e);});
496+
forEach(this, function(e) { value.push('' + e);});
497497
return '[' + value.join(', ') + ']';
498498
},
499499

@@ -584,7 +584,7 @@ forEach({
584584
}
585585
},
586586

587-
attr: function(element, name, value){
587+
attr: function(element, name, value) {
588588
var lowercasedName = lowercase(name);
589589
if (BOOLEAN_ATTR[lowercasedName]) {
590590
if (isDefined(value)) {
@@ -658,7 +658,7 @@ forEach({
658658
},
659659

660660
empty: jqLiteEmpty
661-
}, function(fn, name){
661+
}, function(fn, name) {
662662
/**
663663
* Properties: writes return selection, reads return first value
664664
*/
@@ -766,7 +766,7 @@ function createEventHandler(element, events) {
766766
forEach({
767767
removeData: jqLiteRemoveData,
768768

769-
on: function jqLiteOn(element, type, fn, unsupported){
769+
on: function jqLiteOn(element, type, fn, unsupported) {
770770
if (isDefined(unsupported)) throw jqLiteMinErr('onargs', 'jqLite#on() does not support the `selector` or `eventData` parameters');
771771

772772
// Do not add event handlers to non-elements because they will not be cleaned up.
@@ -836,7 +836,7 @@ forEach({
836836
replaceWith: function(element, replaceNode) {
837837
var index, parent = element.parentNode;
838838
jqLiteDealoc(element);
839-
forEach(new JQLite(replaceNode), function(node){
839+
forEach(new JQLite(replaceNode), function(node) {
840840
if (index) {
841841
parent.insertBefore(node, index.nextSibling);
842842
} else {
@@ -848,7 +848,7 @@ forEach({
848848

849849
children: function(element) {
850850
var children = [];
851-
forEach(element.childNodes, function(element){
851+
forEach(element.childNodes, function(element) {
852852
if (element.nodeType === NODE_TYPE_ELEMENT)
853853
children.push(element);
854854
});
@@ -874,7 +874,7 @@ forEach({
874874
prepend: function(element, node) {
875875
if (element.nodeType === NODE_TYPE_ELEMENT) {
876876
var index = element.firstChild;
877-
forEach(new JQLite(node), function(child){
877+
forEach(new JQLite(node), function(child) {
878878
element.insertBefore(child, index);
879879
});
880880
}
@@ -911,7 +911,7 @@ forEach({
911911

912912
toggleClass: function(element, selector, condition) {
913913
if (selector) {
914-
forEach(selector.split(' '), function(className){
914+
forEach(selector.split(' '), function(className) {
915915
var classCondition = condition;
916916
if (isUndefined(classCondition)) {
917917
classCondition = !jqLiteHasClass(element, className);
@@ -976,7 +976,7 @@ forEach({
976976
});
977977
}
978978
}
979-
}, function(fn, name){
979+
}, function(fn, name) {
980980
/**
981981
* chaining functions
982982
*/

src/ng/asyncCallback.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
function $$AsyncCallbackProvider(){
3+
function $$AsyncCallbackProvider() {
44
this.$get = ['$$rAF', '$timeout', function($$rAF, $timeout) {
55
return $$rAF.supported
66
? function(fn) { return $$rAF(fn); }

src/ng/browser.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function Browser(window, document, $log, $sniffer) {
7272
// force browser to execute all pollFns - this is needed so that cookies and other pollers fire
7373
// at some deterministic time in respect to the test runner's actions. Leaving things up to the
7474
// regular poller would result in flaky tests.
75-
forEach(pollFns, function(pollFn){ pollFn(); });
75+
forEach(pollFns, function(pollFn) { pollFn(); });
7676

7777
if (outstandingRequestCount === 0) {
7878
callback();
@@ -114,7 +114,7 @@ function Browser(window, document, $log, $sniffer) {
114114
*/
115115
function startPoller(interval, setTimeout) {
116116
(function check() {
117-
forEach(pollFns, function(pollFn){ pollFn(); });
117+
forEach(pollFns, function(pollFn) { pollFn(); });
118118
pollTimeout = setTimeout(check, interval);
119119
})();
120120
}
@@ -449,9 +449,9 @@ function Browser(window, document, $log, $sniffer) {
449449

450450
}
451451

452-
function $BrowserProvider(){
452+
function $BrowserProvider() {
453453
this.$get = ['$window', '$log', '$sniffer', '$document',
454-
function($window, $log, $sniffer, $document){
454+
function($window, $log, $sniffer, $document) {
455455
return new Browser($window, $document, $log, $sniffer);
456456
}];
457457
}

src/ng/compile.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
11451145
}
11461146
// We can not compile top level text elements since text nodes can be merged and we will
11471147
// not be able to attach scope data to them, so we will wrap them in <span>
1148-
forEach($compileNodes, function(node, index){
1148+
forEach($compileNodes, function(node, index) {
11491149
if (node.nodeType == NODE_TYPE_TEXT && node.nodeValue.match(/\S+/) /* non-empty */ ) {
11501150
$compileNodes[index] = jqLite(node).wrap('<span></span>').parent()[0];
11511151
}
@@ -1155,7 +1155,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
11551155
maxPriority, ignoreDirective, previousCompileContext);
11561156
compile.$$addScopeClass($compileNodes);
11571157
var namespace = null;
1158-
return function publicLinkFn(scope, cloneConnectFn, transcludeControllers, parentBoundTranscludeFn, futureParentElement){
1158+
return function publicLinkFn(scope, cloneConnectFn, transcludeControllers, parentBoundTranscludeFn, futureParentElement) {
11591159
assertArg(scope, 'scope');
11601160
if (!namespace) {
11611161
namespace = detectNamespaceForChildElements(futureParentElement);
@@ -2504,15 +2504,15 @@ function nodesetLinkingFn(
25042504
/* NodeList */ nodeList,
25052505
/* Element */ rootElement,
25062506
/* function(Function) */ boundTranscludeFn
2507-
){}
2507+
) {}
25082508

25092509
function directiveLinkingFn(
25102510
/* nodesetLinkingFn */ nodesetLinkingFn,
25112511
/* angular.Scope */ scope,
25122512
/* Node */ node,
25132513
/* Element */ rootElement,
25142514
/* function(Function) */ boundTranscludeFn
2515-
){}
2515+
) {}
25162516

25172517
function tokenDifference(str1, str2) {
25182518
var values = '',

src/ng/directive/a.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var htmlAnchorDirective = valueFn({
2121
// SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.
2222
var href = toString.call(element.prop('href')) === '[object SVGAnimatedString]' ?
2323
'xlink:href' : 'href';
24-
element.on('click', function(event){
24+
element.on('click', function(event) {
2525
// if we have no href url, then don't navigate anywhere.
2626
if (!element.attr(href)) {
2727
event.preventDefault();

src/ng/directive/ngShowHide.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ var ngShowDirective = ['$animate', function($animate) {
162162
restrict: 'A',
163163
multiElement: true,
164164
link: function(scope, element, attr) {
165-
scope.$watch(attr.ngShow, function ngShowWatchAction(value){
165+
scope.$watch(attr.ngShow, function ngShowWatchAction(value) {
166166
// we're adding a temporary, animation-specific class for ng-hide since this way
167167
// we can control when the element is actually displayed on screen without having
168168
// to have a global/greedy CSS selector that breaks when other animations are run.
@@ -323,7 +323,7 @@ var ngHideDirective = ['$animate', function($animate) {
323323
restrict: 'A',
324324
multiElement: true,
325325
link: function(scope, element, attr) {
326-
scope.$watch(attr.ngHide, function ngHideWatchAction(value){
326+
scope.$watch(attr.ngHide, function ngHideWatchAction(value) {
327327
// The comment inside of the ngShowDirective explains why we add and
328328
// remove a temporary class for the show/hide animation
329329
$animate[value ? 'addClass' : 'removeClass'](element,NG_HIDE_CLASS, {

src/ng/document.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
</file>
2626
</example>
2727
*/
28-
function $DocumentProvider(){
29-
this.$get = ['$window', function(window){
28+
function $DocumentProvider() {
29+
this.$get = ['$window', function(window) {
3030
return jqLite(window.document);
3131
}];
3232
}

src/ng/filter/filter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function filterFilter() {
153153
}
154154
}
155155

156-
var search = function(obj, text){
156+
var search = function(obj, text) {
157157
if (typeof text === 'string' && text.charAt(0) === '!') {
158158
return !search(obj, text.substr(1));
159159
}

src/ng/filter/filters.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
currencyFilter.$inject = ['$locale'];
5656
function currencyFilter($locale) {
5757
var formats = $locale.NUMBER_FORMATS;
58-
return function(amount, currencySymbol, fractionSize){
58+
return function(amount, currencySymbol, fractionSize) {
5959
if (isUndefined(currencySymbol)) {
6060
currencySymbol = formats.CURRENCY_SYM;
6161
}
@@ -480,7 +480,7 @@ function dateFilter($locale) {
480480
date = new Date(date.getTime());
481481
date.setMinutes(date.getMinutes() + date.getTimezoneOffset());
482482
}
483-
forEach(parts, function(value){
483+
forEach(parts, function(value) {
484484
fn = DATE_FORMATS[value];
485485
text += fn ? fn(date, $locale.DATETIME_FORMATS)
486486
: value.replace(/(^'|'$)/g, '').replace(/''/g, "'");

src/ng/filter/limitTo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
</file>
8787
</example>
8888
*/
89-
function limitToFilter(){
89+
function limitToFilter() {
9090
return function(input, limit) {
9191
if (isNumber(input)) input = input.toString();
9292
if (!isArray(input) && !isString(input)) return input;

src/ng/filter/orderBy.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@
116116
</example>
117117
*/
118118
orderByFilter.$inject = ['$parse'];
119-
function orderByFilter($parse){
119+
function orderByFilter($parse) {
120120
return function(array, sortPredicate, reverseOrder) {
121121
if (!(isArrayLike(array))) return array;
122122
sortPredicate = isArray(sortPredicate) ? sortPredicate: [sortPredicate];
123123
if (sortPredicate.length === 0) { sortPredicate = ['+']; }
124-
sortPredicate = sortPredicate.map(function(predicate){
124+
sortPredicate = sortPredicate.map(function(predicate) {
125125
var descending = false, get = predicate || identity;
126126
if (isString(predicate)) {
127127
if ((predicate.charAt(0) == '+' || predicate.charAt(0) == '-')) {
@@ -142,15 +142,15 @@ function orderByFilter($parse){
142142
}, descending);
143143
}
144144
}
145-
return reverseComparator(function(a, b){
145+
return reverseComparator(function(a, b) {
146146
return compare(get(a),get(b));
147147
}, descending);
148148
});
149149
var arrayCopy = [];
150150
for (var i = 0; i < array.length; i++) { arrayCopy.push(array[i]); }
151151
return arrayCopy.sort(reverseComparator(comparator, reverseOrder));
152152

153-
function comparator(o1, o2){
153+
function comparator(o1, o2) {
154154
for (var i = 0; i < sortPredicate.length; i++) {
155155
var comp = sortPredicate[i](o1, o2);
156156
if (comp !== 0) return comp;
@@ -159,10 +159,10 @@ function orderByFilter($parse){
159159
}
160160
function reverseComparator(comp, descending) {
161161
return descending
162-
? function(a, b){return comp(b,a);}
162+
? function(a, b) {return comp(b,a);}
163163
: comp;
164164
}
165-
function compare(v1, v2){
165+
function compare(v1, v2) {
166166
var t1 = typeof v1;
167167
var t2 = typeof v2;
168168
if (t1 == t2) {

0 commit comments

Comments
 (0)