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, including i18n generator
  • Loading branch information
hzoo committed Oct 23, 2014
1 parent 961eb6f commit d2d18f0
Show file tree
Hide file tree
Showing 798 changed files with 1,139 additions and 1,529 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 i18n/closure/currencySymbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ goog.i18n.currency.adjustPrecision = function(pattern, currencyCode) {
* 18: two decimals precision (2), currency sign last (16), no space (0)
* 50: two decimals precision (2), currency sign last (16), space (32)
*
* @type {!Object.<!Array>}
* @type {!Object.<!Array.<?>>}
*/
goog.i18n.currency.CurrencyInfo = {
'AED': [2, 'dh', '\u062f.\u0625.', 'DH'],
Expand Down Expand Up @@ -334,7 +334,7 @@ goog.i18n.currency.CurrencyInfo = {

/**
* Tier 2 currency information.
* @type {!Object.<!Array>}
* @type {!Object.<!Array.<?>>}
*/
goog.i18n.currency.CurrencyInfoTier2 = {
'AFN': [48, 'Af.', 'AFN'],
Expand Down
8 changes: 4 additions & 4 deletions i18n/spec/closureI18nExtractorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function newTestLocaleInfo() {
}


describe("findLocaleId", function () {
describe("findLocaleId", function() {
it("should find the id from numbers", function() {
expect(findLocaleId("NumberFormatSymbols_en_GB", "num")).toEqual("en_GB");
});
Expand All @@ -74,7 +74,7 @@ describe("findLocaleId", function () {
});
});

describe("extractNumberSymbols", function () {
describe("extractNumberSymbols", function() {
it("should extract number data", function() {
var CONTENT = [
"goog.provide('goog.i18n.NumberFormatSymbols_en_GB');",
Expand Down Expand Up @@ -117,7 +117,7 @@ describe("extractNumberSymbols", function () {
})
});

describe("extractCurrencySymbols", function () {
describe("extractCurrencySymbols", function() {
it("should extract currency data", function() {
var CONTENT = [
"goog.i18n.currency.CurrencyInfo = {",
Expand All @@ -137,7 +137,7 @@ describe("extractCurrencySymbols", function () {
});


describe("extractDateTimeSymbols", function () {
describe("extractDateTimeSymbols", function() {
it("should extract date time data", function() {
var CONTENT = [
"goog.i18n.DateTimeSymbols_fr_CA = {",
Expand Down
1 change: 1 addition & 0 deletions i18n/src/closureI18nExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function pluralExtractor(content, localeInfo) {
continue;
}
var temp = goog.i18n.pluralRules.select.toString().
replace(/function\s+\(/g, 'function(').
replace(/goog\.i18n\.pluralRules\.Keyword/g, 'PLURAL_CATEGORY').
replace(/goog\.i18n\.pluralRules\.get_vf_/g, 'getVF').
replace(/goog\.i18n\.pluralRules\.get_wt_/g, 'getWT').
Expand Down
2 changes: 1 addition & 1 deletion i18n/src/closureSlurper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
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 @@ -237,7 +237,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 @@ -260,7 +260,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 @@ -273,7 +273,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 @@ -1839,7 +1839,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 @@ -1908,13 +1908,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 @@ -2405,7 +2405,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 @@ -2907,7 +2907,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 @@ -2981,7 +2981,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 @@ -664,7 +664,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 @@ -699,7 +699,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
Loading

0 comments on commit d2d18f0

Please sign in to comment.