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 disallowSpacesInAnonymousFunctionExpression before…
Browse files Browse the repository at this point in the history
…OpeningRoundBrace
  • Loading branch information
hzoo committed Oct 21, 2014
1 parent 2cc1321 commit 74b23c8
Show file tree
Hide file tree
Showing 794 changed files with 1,135 additions and 1,130 deletions.
3 changes: 3 additions & 0 deletions .jscs.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": ["!"],
"disallowSpaceBeforeBinaryOperators": [","],
"disallowSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true
},
Expand Down
4 changes: 2 additions & 2 deletions src/jqLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ forEach({
if (isUndefined(value)) {
if (element.multiple && nodeName_(element) === 'select') {
var result = [];
forEach(element.options, function (option) {
forEach(element.options, function(option) {
if (option.selected) {
result.push(option.value || option.text);
}
Expand Down Expand Up @@ -710,7 +710,7 @@ forEach({
});

function createEventHandler(element, events) {
var eventHandler = function (event, type) {
var eventHandler = function(event, type) {
// jQuery specific api
event.isDefaultPrevented = function() {
return event.defaultPrevented;
Expand Down
6 changes: 3 additions & 3 deletions src/minErr.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@

function minErr(module, ErrorConstructor) {
ErrorConstructor = ErrorConstructor || Error;
return function () {
return function() {
var code = arguments[0],
prefix = '[' + (module ? module + ':' : '') + code + '] ',
template = arguments[1],
templateArgs = arguments,
stringify = function (obj) {
stringify = function(obj) {
if (typeof obj === 'function') {
return obj.toString().replace(/ \{[\s\S]*$/, '');
} else if (typeof obj === 'undefined') {
Expand All @@ -49,7 +49,7 @@ function minErr(module, ErrorConstructor) {
},
message, i;

message = prefix + template.replace(/\{\d+\}/g, function (match) {
message = prefix + template.replace(/\{\d+\}/g, function(match) {
var index = +match.slice(1, -1), arg;

if (index + 2 < templateArgs.length) {
Expand Down
4 changes: 2 additions & 2 deletions src/ng/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ var $AnimateProvider = ['$provide', function($provide) {
className = !isString(className)
? (isArray(className) ? className.join(' ') : '')
: className;
forEach(element, function (element) {
forEach(element, function(element) {
jqLiteAddClass(element, className);
});
applyStyles(element, options);
Expand Down Expand Up @@ -289,7 +289,7 @@ var $AnimateProvider = ['$provide', function($provide) {
className = !isString(className)
? (isArray(className) ? className.join(' ') : '')
: className;
forEach(element, function (element) {
forEach(element, function(element) {
jqLiteRemoveClass(element, className);
});
applyStyles(element, options);
Expand Down
6 changes: 3 additions & 3 deletions src/ng/directive/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
* Setting a form back to a pristine state is often useful when we want to 'reuse' a form after
* saving or resetting it.
*/
form.$setPristine = function () {
form.$setPristine = function() {
$animate.setClass(element, PRISTINE_CLASS, DIRTY_CLASS + ' ' + SUBMITTED_CLASS);
form.$dirty = false;
form.$pristine = true;
Expand All @@ -255,7 +255,7 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
* Setting a form controls back to their untouched state is often useful when setting the form
* back to its pristine state.
*/
form.$setUntouched = function () {
form.$setUntouched = function() {
forEach(controls, function(control) {
control.$setUntouched();
});
Expand All @@ -268,7 +268,7 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
* @description
* Sets the form to its submitted state.
*/
form.$setSubmitted = function () {
form.$setSubmitted = function() {
$animate.addClass(element, SUBMITTED_CLASS);
form.$submitted = true;
parentForm.$setSubmitted();
Expand Down
12 changes: 6 additions & 6 deletions src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
* state (ng-pristine class). A model is considered to be pristine when the model has not been changed
* from when first compiled within then form.
*/
this.$setPristine = function () {
this.$setPristine = function() {
ctrl.$dirty = false;
ctrl.$pristine = true;
$animate.removeClass($element, DIRTY_CLASS);
Expand Down Expand Up @@ -1922,13 +1922,13 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
* angular.module('cancel-update-example', [])
*
* .controller('CancelUpdateController', ['$scope', function($scope) {
* $scope.resetWithCancel = function (e) {
* $scope.resetWithCancel = function(e) {
* if (e.keyCode == 27) {
* $scope.myForm.myInput1.$rollbackViewValue();
* $scope.myValue = '';
* }
* };
* $scope.resetWithoutCancel = function (e) {
* $scope.resetWithoutCancel = function(e) {
* if (e.keyCode == 27) {
* $scope.myValue = '';
* }
Expand Down Expand Up @@ -2419,7 +2419,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
.controller('ExampleController', ['$scope', function($scope) {
var _name = 'Brian';
$scope.user = {
name: function (newName) {
name: function(newName) {
if (angular.isDefined(newName)) {
_name = newName;
}
Expand Down Expand Up @@ -2921,7 +2921,7 @@ var ngValueDirective = function() {
.controller('ExampleController', ['$scope', function($scope) {
$scope.user = { name: 'say', data: '' };
$scope.cancel = function (e) {
$scope.cancel = function(e) {
if (e.keyCode == 27) {
$scope.userForm.userName.$rollbackViewValue();
}
Expand Down Expand Up @@ -2995,7 +2995,7 @@ var ngValueDirective = function() {
.controller('ExampleController', ['$scope', function($scope) {
var _name = 'Brian';
$scope.user = {
name: function (newName) {
name: function(newName) {
return angular.isDefined(newName) ? (_name = newName) : _name;
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/ng/directive/ngBind.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var ngBindDirective = ['$compile', function($compile) {
<file name="index.html">
<script>
angular.module('bindExample', [])
.controller('ExampleController', ['$scope', function ($scope) {
.controller('ExampleController', ['$scope', function($scope) {
$scope.salutation = 'Hello';
$scope.name = 'World';
}]);
Expand Down
2 changes: 1 addition & 1 deletion src/ng/directive/ngClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function classDirective(name, selector) {
function digestClassCounts(classes, count) {
var classCounts = element.data('$classCounts') || {};
var classesToUpdate = [];
forEach(classes, function (className) {
forEach(classes, function(className) {
if (count > 0 || classCounts[className]) {
classCounts[className] = (classCounts[className] || 0) + count;
if (classCounts[className] === +(count > 0)) {
Expand Down
4 changes: 2 additions & 2 deletions src/ng/directive/ngIf.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ var ngIfDirective = ['$animate', function($animate) {
terminal: true,
restrict: 'A',
$$tlb: true,
link: function ($scope, $element, $attr, ctrl, $transclude) {
link: function($scope, $element, $attr, ctrl, $transclude) {
var block, childScope, previousElements;
$scope.$watch($attr.ngIf, function ngIfWatchAction(value) {

if (value) {
if (!childScope) {
$transclude(function (clone, newScope) {
$transclude(function(clone, newScope) {
childScope = newScope;
clone[clone.length++] = document.createComment(' end ngIf: ' + $attr.ngIf + ' ');
// Note: We only need the first/last node of the cloned nodes.
Expand Down
6 changes: 3 additions & 3 deletions src/ng/directive/ngRepeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
if (trackByExp) {
trackByExpGetter = $parse(trackByExp);
} else {
trackByIdArrayFn = function (key, value) {
trackByIdArrayFn = function(key, value) {
return hashKey(value);
};
trackByIdObjFn = function (key) {
trackByIdObjFn = function(key) {
return key;
};
}
Expand Down Expand Up @@ -361,7 +361,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
nextBlockOrder[index] = block;
} else if (nextBlockMap[trackById]) {
// if collision detected. restore lastBlockMap and throw an error
forEach(nextBlockOrder, function (block) {
forEach(nextBlockOrder, function(block) {
if (block && block.scope) lastBlockMap[block.id] = block;
});
throw ngRepeatMinErr('dupes',
Expand Down
4 changes: 2 additions & 2 deletions src/ng/directive/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
updateLabelMap(labelMap, option.label, false);
option.element.remove();
}
forEach(labelMap, function (count, label) {
forEach(labelMap, function(count, label) {
if (count > 0) {
selectCtrl.addOption(label);
} else if (count < 0) {
Expand Down Expand Up @@ -701,7 +701,7 @@ var optionDirective = ['$interpolate', function($interpolate) {
}
}

return function (scope, element, attr) {
return function(scope, element, attr) {
var selectCtrlName = '$selectController',
parent = element.parent(),
selectCtrl = parent.data(selectCtrlName) ||
Expand Down
4 changes: 2 additions & 2 deletions src/ng/exceptionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* ## Example:
*
* ```js
* angular.module('exceptionOverride', []).factory('$exceptionHandler', function () {
* return function (exception, cause) {
* angular.module('exceptionOverride', []).factory('$exceptionHandler', function() {
* return function(exception, cause) {
* exception.message += ' (caused by "' + cause + '")';
* throw exception;
* };
Expand Down
2 changes: 1 addition & 1 deletion src/ng/httpBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
statusText);
};

var requestError = function () {
var requestError = function() {
// The response is always empty
// See https://xhr.spec.whatwg.org/#request-error-steps and https://fetch.spec.whatwg.org/#concept-network-error
completeRequest(callback, -1, null, null, '');
Expand Down
6 changes: 3 additions & 3 deletions src/ng/interpolate.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,13 @@ function $InterpolateProvider() {
return concat.join('');
};

var getValue = function (value) {
var getValue = function(value) {
return trustedContext ?
$sce.getTrusted(trustedContext, value) :
$sce.valueOf(value);
};

var stringify = function (value) {
var stringify = function(value) {
if (value == null) { // null || undefined
return '';
}
Expand Down Expand Up @@ -281,7 +281,7 @@ function $InterpolateProvider() {
// all of these properties are undocumented for now
exp: text, //just for compatibility with regular watchers created via $watch
expressions: expressions,
$$watchDelegate: function (scope, listener, objectEquality) {
$$watchDelegate: function(scope, listener, objectEquality) {
var lastValue;
return scope.$watchGroup(parseFns, function interpolateFnWatcher(values, oldValues) {
var currValue = compute(values);
Expand Down
2 changes: 1 addition & 1 deletion src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ var locationPrototype = {
}
};

forEach([LocationHashbangInHtml5Url, LocationHashbangUrl, LocationHtml5Url], function (Location) {
forEach([LocationHashbangInHtml5Url, LocationHashbangUrl, LocationHtml5Url], function(Location) {
Location.prototype = Object.create(locationPrototype);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ng/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function $LogProvider() {
* @description
* Write a debug message
*/
debug: (function () {
debug: (function() {
var fn = consoleLog('debug');

return function() {
Expand Down
22 changes: 11 additions & 11 deletions src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ var ESCAPE = {"n":"\n", "f":"\f", "r":"\r", "t":"\t", "v":"\v", "'":"'", '"':'"'
/**
* @constructor
*/
var Lexer = function (options) {
var Lexer = function(options) {
this.options = options;
};

Lexer.prototype = {
constructor: Lexer,

lex: function (text) {
lex: function(text) {
this.text = text;
this.index = 0;
this.ch = undefined;
Expand Down Expand Up @@ -384,13 +384,13 @@ function isConstant(exp) {
/**
* @constructor
*/
var Parser = function (lexer, $filter, options) {
var Parser = function(lexer, $filter, options) {
this.lexer = lexer;
this.$filter = $filter;
this.options = options;
};

Parser.ZERO = extend(function () {
Parser.ZERO = extend(function() {
return 0;
}, {
sharedGetter: true,
Expand All @@ -400,7 +400,7 @@ Parser.ZERO = extend(function () {
Parser.prototype = {
constructor: Parser,

parse: function (text) {
parse: function(text) {
this.text = text;
this.tokens = this.lexer.lex(text);

Expand All @@ -416,7 +416,7 @@ Parser.prototype = {
return value;
},

primary: function () {
primary: function() {
var primary;
if (this.expect('(')) {
primary = this.filterChain();
Expand Down Expand Up @@ -770,7 +770,7 @@ Parser.prototype = {
},

// This is used with json array declaration
arrayDeclaration: function () {
arrayDeclaration: function() {
var elementFns = [];
if (this.peekToken().text !== ']') {
do {
Expand All @@ -797,7 +797,7 @@ Parser.prototype = {
});
},

object: function () {
object: function() {
var keys = [], valueFns = [];
if (this.peekToken().text !== '}') {
do {
Expand Down Expand Up @@ -1164,7 +1164,7 @@ function $ParseProvider() {
listener.apply(this, arguments);
}
if (isDefined(value)) {
scope.$$postDigest(function () {
scope.$$postDigest(function() {
if (isDefined(lastValue)) {
unwatch();
}
Expand All @@ -1183,15 +1183,15 @@ function $ParseProvider() {
listener.call(this, value, old, scope);
}
if (isAllDefined(value)) {
scope.$$postDigest(function () {
scope.$$postDigest(function() {
if (isAllDefined(lastValue)) unwatch();
});
}
}, objectEquality);

function isAllDefined(value) {
var allDefined = true;
forEach(value, function (val) {
forEach(value, function(val) {
if (!isDefined(val)) allDefined = false;
});
return allDefined;
Expand Down
4 changes: 2 additions & 2 deletions src/ng/rootScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ function $RootScopeProvider() {
if (!watchExpressions.length) {
// No expressions means we call the listener ASAP
var shouldCall = true;
self.$evalAsync(function () {
self.$evalAsync(function() {
if (shouldCall) listener(newValues, newValues, self);
});
return function deregisterWatchGroup() {
Expand All @@ -441,7 +441,7 @@ function $RootScopeProvider() {
});
}

forEach(watchExpressions, function (expr, i) {
forEach(watchExpressions, function(expr, i) {
var unwatchFn = self.$watch(expr, function watchGroupSubAction(value, oldValue) {
newValues[i] = value;
oldValues[i] = oldValue;
Expand Down
Loading

0 comments on commit 74b23c8

Please sign in to comment.