diff --git a/.jscs.json b/.jscs.json index af1ef2e8f769..ac8fc68f6b04 100644 --- a/.jscs.json +++ b/.jscs.json @@ -6,6 +6,9 @@ "disallowSpaceAfterObjectKeys": true, "disallowSpaceAfterPrefixUnaryOperators": ["!"], "disallowSpaceBeforeBinaryOperators": [","], + "disallowSpacesInAnonymousFunctionExpression": { + "beforeOpeningRoundBrace": true + }, "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, diff --git a/i18n/src/closureI18nExtractor.js b/i18n/src/closureI18nExtractor.js index 67ea5ff76313..7ab5b0a01818 100644 --- a/i18n/src/closureI18nExtractor.js +++ b/i18n/src/closureI18nExtractor.js @@ -79,7 +79,7 @@ function pluralExtractor(content, localeInfo) { goog.LOCALE = localeIds[i].match(/[^_]+/)[0]; try { eval(contentText); - } catch(e) { + } catch (e) { console.log("Error in eval(contentText): " + e.stack); } if (!goog.i18n.pluralRules.select) { @@ -91,7 +91,8 @@ function pluralExtractor(content, localeInfo) { replace(/goog\.i18n\.pluralRules\.get_vf_/g, 'getVF'). replace(/goog\.i18n\.pluralRules\.get_wt_/g, 'getWT'). replace(/goog\.i18n\.pluralRules\.decimals_/g, 'getDecimals'). - replace(/\n/g, ''); + replace(/\n/g, '') + replace(/function \(n/, 'function(n'); ///@@ is a crazy place holder to be replaced before writing to file localeInfo[localeIds[i]].pluralCat = "@@" + temp + "@@"; diff --git a/i18n/src/closureSlurper.js b/i18n/src/closureSlurper.js index 3dd5ce0358f6..764818373cbb 100755 --- a/i18n/src/closureSlurper.js +++ b/i18n/src/closureSlurper.js @@ -80,7 +80,7 @@ function writeLocaleFiles() { var filename = NG_LOCALE_DIR + 'angular-locale_' + correctedLocaleId + '.js' console.log('Writing ' + filename); return qfs.write(filename, content) - .then(function () { + .then(function() { console.log('Wrote ' + filename); ++num_files; }); diff --git a/src/jqLite.js b/src/jqLite.js index e7be752a694c..c3fdc7ecc68b 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -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); } @@ -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; diff --git a/src/minErr.js b/src/minErr.js index 489608582d29..c0d39a14149f 100644 --- a/src/minErr.js +++ b/src/minErr.js @@ -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') { @@ -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) { diff --git a/src/ng/animate.js b/src/ng/animate.js index 65280f764466..752ed0e15f6f 100644 --- a/src/ng/animate.js +++ b/src/ng/animate.js @@ -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); @@ -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); diff --git a/src/ng/directive/form.js b/src/ng/directive/form.js index 86115a81bcca..f6ae57809442 100644 --- a/src/ng/directive/form.js +++ b/src/ng/directive/form.js @@ -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; @@ -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(); }); @@ -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(); diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index b6ec372c6e1c..698e0692cf3a 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -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); @@ -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 = ''; * } @@ -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; } @@ -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(); } @@ -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; } }; diff --git a/src/ng/directive/ngBind.js b/src/ng/directive/ngBind.js index 8385ee491658..8ddd11f1ad5b 100644 --- a/src/ng/directive/ngBind.js +++ b/src/ng/directive/ngBind.js @@ -90,7 +90,7 @@ var ngBindDirective = ['$compile', function($compile) {