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

Commit

Permalink
style(*): add rule requireSpacesInFunction beforeOpeningCurlyBrace
Browse files Browse the repository at this point in the history
This rule enforces a space after the curly brace
for function declarations, anonymous function expressions,
and named function expressions.
  • Loading branch information
hzoo committed Oct 23, 2014
1 parent 2110069 commit 1d677c0
Show file tree
Hide file tree
Showing 72 changed files with 324 additions and 321 deletions.
3 changes: 3 additions & 0 deletions .jscs.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"disallowTrailingComma": true,
"disallowTrailingWhitespace": true,
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
"requireSpacesInFunction": {
"beforeOpeningCurlyBrace": true
},
"validateParameterSeparator": ", "
}
16 changes: 8 additions & 8 deletions src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ var VALIDITY_STATE_PROPERTY = 'validity';
* @param {string} string String to be converted to lowercase.
* @returns {string} Lowercased string.
*/
var lowercase = function(string){return isString(string) ? string.toLowerCase() : string;};
var lowercase = function(string) {return isString(string) ? string.toLowerCase() : string;};
var hasOwnProperty = Object.prototype.hasOwnProperty;

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


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


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


/**
Expand All @@ -450,7 +450,7 @@ function isDefined(value){return typeof value !== 'undefined';}
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is an `Object` but not `null`.
*/
function isObject(value){
function isObject(value) {
// http://jsperf.com/isobject4
return value !== null && typeof value === 'object';
}
Expand All @@ -468,7 +468,7 @@ function isObject(value){
* @param {*} value Reference to check.
* @returns {boolean} True if `value` is a `String`.
*/
function isString(value){return typeof value === 'string';}
function isString(value) {return typeof value === 'string';}


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


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


/**
Expand Down
2 changes: 1 addition & 1 deletion src/AngularPublic.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ var version = {
};


function publishExternalAPI(angular){
function publishExternalAPI(angular) {
extend(angular, {
'bootstrap': bootstrap,
'copy': copy,
Expand Down
2 changes: 1 addition & 1 deletion src/auto/injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ function createInjector(modulesToLoad, strictDi) {
////////////////////////////////////
// Module Loading
////////////////////////////////////
function loadModules(modulesToLoad){
function loadModules(modulesToLoad) {
var runBlocks = [], moduleFn;
forEach(modulesToLoad, function(module) {
if (loadedModules.get(module)) return;
Expand Down
20 changes: 10 additions & 10 deletions src/jqLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function jqLiteClone(element) {
return element.cloneNode(true);
}

function jqLiteDealoc(element, onlyDescendants){
function jqLiteDealoc(element, onlyDescendants) {
if (!onlyDescendants) jqLiteRemoveData(element);

if (element.querySelectorAll) {
Expand Down Expand Up @@ -493,7 +493,7 @@ var JQLitePrototype = JQLite.prototype = {
},
toString: function() {
var value = [];
forEach(this, function(e){ value.push('' + e);});
forEach(this, function(e) { value.push('' + e);});
return '[' + value.join(', ') + ']';
},

Expand Down Expand Up @@ -584,7 +584,7 @@ forEach({
}
},

attr: function(element, name, value){
attr: function(element, name, value) {
var lowercasedName = lowercase(name);
if (BOOLEAN_ATTR[lowercasedName]) {
if (isDefined(value)) {
Expand Down Expand Up @@ -658,7 +658,7 @@ forEach({
},

empty: jqLiteEmpty
}, function(fn, name){
}, function(fn, name) {
/**
* Properties: writes return selection, reads return first value
*/
Expand Down Expand Up @@ -766,7 +766,7 @@ function createEventHandler(element, events) {
forEach({
removeData: jqLiteRemoveData,

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

// Do not add event handlers to non-elements because they will not be cleaned up.
Expand Down Expand Up @@ -836,7 +836,7 @@ forEach({
replaceWith: function(element, replaceNode) {
var index, parent = element.parentNode;
jqLiteDealoc(element);
forEach(new JQLite(replaceNode), function(node){
forEach(new JQLite(replaceNode), function(node) {
if (index) {
parent.insertBefore(node, index.nextSibling);
} else {
Expand All @@ -848,7 +848,7 @@ forEach({

children: function(element) {
var children = [];
forEach(element.childNodes, function(element){
forEach(element.childNodes, function(element) {
if (element.nodeType === NODE_TYPE_ELEMENT)
children.push(element);
});
Expand All @@ -874,7 +874,7 @@ forEach({
prepend: function(element, node) {
if (element.nodeType === NODE_TYPE_ELEMENT) {
var index = element.firstChild;
forEach(new JQLite(node), function(child){
forEach(new JQLite(node), function(child) {
element.insertBefore(child, index);
});
}
Expand Down Expand Up @@ -911,7 +911,7 @@ forEach({

toggleClass: function(element, selector, condition) {
if (selector) {
forEach(selector.split(' '), function(className){
forEach(selector.split(' '), function(className) {
var classCondition = condition;
if (isUndefined(classCondition)) {
classCondition = !jqLiteHasClass(element, className);
Expand Down Expand Up @@ -976,7 +976,7 @@ forEach({
});
}
}
}, function(fn, name){
}, function(fn, name) {
/**
* chaining functions
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ng/asyncCallback.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

function $$AsyncCallbackProvider(){
function $$AsyncCallbackProvider() {
this.$get = ['$$rAF', '$timeout', function($$rAF, $timeout) {
return $$rAF.supported
? function(fn) { return $$rAF(fn); }
Expand Down
8 changes: 4 additions & 4 deletions src/ng/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function Browser(window, document, $log, $sniffer) {
// force browser to execute all pollFns - this is needed so that cookies and other pollers fire
// at some deterministic time in respect to the test runner's actions. Leaving things up to the
// regular poller would result in flaky tests.
forEach(pollFns, function(pollFn){ pollFn(); });
forEach(pollFns, function(pollFn) { pollFn(); });

if (outstandingRequestCount === 0) {
callback();
Expand Down Expand Up @@ -114,7 +114,7 @@ function Browser(window, document, $log, $sniffer) {
*/
function startPoller(interval, setTimeout) {
(function check() {
forEach(pollFns, function(pollFn){ pollFn(); });
forEach(pollFns, function(pollFn) { pollFn(); });
pollTimeout = setTimeout(check, interval);
})();
}
Expand Down Expand Up @@ -449,9 +449,9 @@ function Browser(window, document, $log, $sniffer) {

}

function $BrowserProvider(){
function $BrowserProvider() {
this.$get = ['$window', '$log', '$sniffer', '$document',
function($window, $log, $sniffer, $document){
function($window, $log, $sniffer, $document) {
return new Browser($window, $document, $log, $sniffer);
}];
}
8 changes: 4 additions & 4 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
}
// We can not compile top level text elements since text nodes can be merged and we will
// not be able to attach scope data to them, so we will wrap them in <span>
forEach($compileNodes, function(node, index){
forEach($compileNodes, function(node, index) {
if (node.nodeType == NODE_TYPE_TEXT && node.nodeValue.match(/\S+/) /* non-empty */ ) {
$compileNodes[index] = jqLite(node).wrap('<span></span>').parent()[0];
}
Expand All @@ -1152,7 +1152,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
maxPriority, ignoreDirective, previousCompileContext);
compile.$$addScopeClass($compileNodes);
var namespace = null;
return function publicLinkFn(scope, cloneConnectFn, transcludeControllers, parentBoundTranscludeFn, futureParentElement){
return function publicLinkFn(scope, cloneConnectFn, transcludeControllers, parentBoundTranscludeFn, futureParentElement) {
assertArg(scope, 'scope');
if (!namespace) {
namespace = detectNamespaceForChildElements(futureParentElement);
Expand Down Expand Up @@ -2496,15 +2496,15 @@ function nodesetLinkingFn(
/* NodeList */ nodeList,
/* Element */ rootElement,
/* function(Function) */ boundTranscludeFn
){}
) {}

function directiveLinkingFn(
/* nodesetLinkingFn */ nodesetLinkingFn,
/* angular.Scope */ scope,
/* Node */ node,
/* Element */ rootElement,
/* function(Function) */ boundTranscludeFn
){}
) {}

function tokenDifference(str1, str2) {
var values = '',
Expand Down
2 changes: 1 addition & 1 deletion src/ng/directive/a.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var htmlAnchorDirective = valueFn({
// SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.
var href = toString.call(element.prop('href')) === '[object SVGAnimatedString]' ?
'xlink:href' : 'href';
element.on('click', function(event){
element.on('click', function(event) {
// if we have no href url, then don't navigate anywhere.
if (!element.attr(href)) {
event.preventDefault();
Expand Down
4 changes: 2 additions & 2 deletions src/ng/directive/ngShowHide.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ var ngShowDirective = ['$animate', function($animate) {
restrict: 'A',
multiElement: true,
link: function(scope, element, attr) {
scope.$watch(attr.ngShow, function ngShowWatchAction(value){
scope.$watch(attr.ngShow, function ngShowWatchAction(value) {
// we're adding a temporary, animation-specific class for ng-hide since this way
// we can control when the element is actually displayed on screen without having
// to have a global/greedy CSS selector that breaks when other animations are run.
Expand Down Expand Up @@ -323,7 +323,7 @@ var ngHideDirective = ['$animate', function($animate) {
restrict: 'A',
multiElement: true,
link: function(scope, element, attr) {
scope.$watch(attr.ngHide, function ngHideWatchAction(value){
scope.$watch(attr.ngHide, function ngHideWatchAction(value) {
// The comment inside of the ngShowDirective explains why we add and
// remove a temporary class for the show/hide animation
$animate[value ? 'addClass' : 'removeClass'](element,NG_HIDE_CLASS, {
Expand Down
4 changes: 2 additions & 2 deletions src/ng/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
</file>
</example>
*/
function $DocumentProvider(){
this.$get = ['$window', function(window){
function $DocumentProvider() {
this.$get = ['$window', function(window) {
return jqLite(window.document);
}];
}
2 changes: 1 addition & 1 deletion src/ng/filter/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function filterFilter() {
}
}

var search = function(obj, text){
var search = function(obj, text) {
if (typeof text === 'string' && text.charAt(0) === '!') {
return !search(obj, text.substr(1));
}
Expand Down
4 changes: 2 additions & 2 deletions src/ng/filter/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
currencyFilter.$inject = ['$locale'];
function currencyFilter($locale) {
var formats = $locale.NUMBER_FORMATS;
return function(amount, currencySymbol, fractionSize){
return function(amount, currencySymbol, fractionSize) {
if (isUndefined(currencySymbol)) {
currencySymbol = formats.CURRENCY_SYM;
}
Expand Down Expand Up @@ -480,7 +480,7 @@ function dateFilter($locale) {
date = new Date(date.getTime());
date.setMinutes(date.getMinutes() + date.getTimezoneOffset());
}
forEach(parts, function(value){
forEach(parts, function(value) {
fn = DATE_FORMATS[value];
text += fn ? fn(date, $locale.DATETIME_FORMATS)
: value.replace(/(^'|'$)/g, '').replace(/''/g, "'");
Expand Down
2 changes: 1 addition & 1 deletion src/ng/filter/limitTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</file>
</example>
*/
function limitToFilter(){
function limitToFilter() {
return function(input, limit) {
if (isNumber(input)) input = input.toString();
if (!isArray(input) && !isString(input)) return input;
Expand Down
12 changes: 6 additions & 6 deletions src/ng/filter/orderBy.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@
</example>
*/
orderByFilter.$inject = ['$parse'];
function orderByFilter($parse){
function orderByFilter($parse) {
return function(array, sortPredicate, reverseOrder) {
if (!(isArrayLike(array))) return array;
sortPredicate = isArray(sortPredicate) ? sortPredicate: [sortPredicate];
if (sortPredicate.length === 0) { sortPredicate = ['+']; }
sortPredicate = sortPredicate.map(function(predicate){
sortPredicate = sortPredicate.map(function(predicate) {
var descending = false, get = predicate || identity;
if (isString(predicate)) {
if ((predicate.charAt(0) == '+' || predicate.charAt(0) == '-')) {
Expand All @@ -142,15 +142,15 @@ function orderByFilter($parse){
}, descending);
}
}
return reverseComparator(function(a, b){
return reverseComparator(function(a, b) {
return compare(get(a),get(b));
}, descending);
});
var arrayCopy = [];
for (var i = 0; i < array.length; i++) { arrayCopy.push(array[i]); }
return arrayCopy.sort(reverseComparator(comparator, reverseOrder));

function comparator(o1, o2){
function comparator(o1, o2) {
for (var i = 0; i < sortPredicate.length; i++) {
var comp = sortPredicate[i](o1, o2);
if (comp !== 0) return comp;
Expand All @@ -159,10 +159,10 @@ function orderByFilter($parse){
}
function reverseComparator(comp, descending) {
return descending
? function(a, b){return comp(b,a);}
? function(a, b) {return comp(b,a);}
: comp;
}
function compare(v1, v2){
function compare(v1, v2) {
var t1 = typeof v1;
var t2 = typeof v2;
if (t1 == t2) {
Expand Down
Loading

0 comments on commit 1d677c0

Please sign in to comment.