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

Commit d3b1f50

Browse files
hzoocaitp
authored andcommitted
style(*): add rule disallowSpacesInAnonymousFunctionExpression beforeOpeningRoundBrace, including i18n generator
1 parent 94f5a28 commit d3b1f50

File tree

798 files changed

+1139
-1529
lines changed

Some content is hidden

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

798 files changed

+1139
-1529
lines changed

.jscs.json

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"disallowSpaceAfterObjectKeys": true,
77
"disallowSpaceAfterPrefixUnaryOperators": ["!"],
88
"disallowSpaceBeforeBinaryOperators": [","],
9+
"disallowSpacesInAnonymousFunctionExpression": {
10+
"beforeOpeningRoundBrace": true
11+
},
912
"disallowSpacesInFunctionDeclaration": {
1013
"beforeOpeningRoundBrace": true
1114
},

i18n/closure/currencySymbols.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ goog.i18n.currency.adjustPrecision = function(pattern, currencyCode) {
267267
* 18: two decimals precision (2), currency sign last (16), no space (0)
268268
* 50: two decimals precision (2), currency sign last (16), space (32)
269269
*
270-
* @type {!Object.<!Array>}
270+
* @type {!Object.<!Array.<?>>}
271271
*/
272272
goog.i18n.currency.CurrencyInfo = {
273273
'AED': [2, 'dh', '\u062f.\u0625.', 'DH'],
@@ -334,7 +334,7 @@ goog.i18n.currency.CurrencyInfo = {
334334

335335
/**
336336
* Tier 2 currency information.
337-
* @type {!Object.<!Array>}
337+
* @type {!Object.<!Array.<?>>}
338338
*/
339339
goog.i18n.currency.CurrencyInfoTier2 = {
340340
'AFN': [48, 'Af.', 'AFN'],

i18n/spec/closureI18nExtractorSpec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function newTestLocaleInfo() {
5656
}
5757

5858

59-
describe("findLocaleId", function () {
59+
describe("findLocaleId", function() {
6060
it("should find the id from numbers", function() {
6161
expect(findLocaleId("NumberFormatSymbols_en_GB", "num")).toEqual("en_GB");
6262
});
@@ -74,7 +74,7 @@ describe("findLocaleId", function () {
7474
});
7575
});
7676

77-
describe("extractNumberSymbols", function () {
77+
describe("extractNumberSymbols", function() {
7878
it("should extract number data", function() {
7979
var CONTENT = [
8080
"goog.provide('goog.i18n.NumberFormatSymbols_en_GB');",
@@ -117,7 +117,7 @@ describe("extractNumberSymbols", function () {
117117
})
118118
});
119119

120-
describe("extractCurrencySymbols", function () {
120+
describe("extractCurrencySymbols", function() {
121121
it("should extract currency data", function() {
122122
var CONTENT = [
123123
"goog.i18n.currency.CurrencyInfo = {",
@@ -137,7 +137,7 @@ describe("extractCurrencySymbols", function () {
137137
});
138138

139139

140-
describe("extractDateTimeSymbols", function () {
140+
describe("extractDateTimeSymbols", function() {
141141
it("should extract date time data", function() {
142142
var CONTENT = [
143143
"goog.i18n.DateTimeSymbols_fr_CA = {",

i18n/src/closureI18nExtractor.js

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function pluralExtractor(content, localeInfo) {
8787
continue;
8888
}
8989
var temp = goog.i18n.pluralRules.select.toString().
90+
replace(/function\s+\(/g, 'function(').
9091
replace(/goog\.i18n\.pluralRules\.Keyword/g, 'PLURAL_CATEGORY').
9192
replace(/goog\.i18n\.pluralRules\.get_vf_/g, 'getVF').
9293
replace(/goog\.i18n\.pluralRules\.get_wt_/g, 'getWT').

i18n/src/closureSlurper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function writeLocaleFiles() {
8080
var filename = NG_LOCALE_DIR + 'angular-locale_' + correctedLocaleId + '.js'
8181
console.log('Writing ' + filename);
8282
return qfs.write(filename, content)
83-
.then(function () {
83+
.then(function() {
8484
console.log('Wrote ' + filename);
8585
++num_files;
8686
});

src/jqLite.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ forEach({
637637
if (isUndefined(value)) {
638638
if (element.multiple && nodeName_(element) === 'select') {
639639
var result = [];
640-
forEach(element.options, function (option) {
640+
forEach(element.options, function(option) {
641641
if (option.selected) {
642642
result.push(option.value || option.text);
643643
}
@@ -710,7 +710,7 @@ forEach({
710710
});
711711

712712
function createEventHandler(element, events) {
713-
var eventHandler = function (event, type) {
713+
var eventHandler = function(event, type) {
714714
// jQuery specific api
715715
event.isDefaultPrevented = function() {
716716
return event.defaultPrevented;

src/minErr.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232

3333
function minErr(module, ErrorConstructor) {
3434
ErrorConstructor = ErrorConstructor || Error;
35-
return function () {
35+
return function() {
3636
var code = arguments[0],
3737
prefix = '[' + (module ? module + ':' : '') + code + '] ',
3838
template = arguments[1],
3939
templateArgs = arguments,
40-
stringify = function (obj) {
40+
stringify = function(obj) {
4141
if (typeof obj === 'function') {
4242
return obj.toString().replace(/ \{[\s\S]*$/, '');
4343
} else if (typeof obj === 'undefined') {
@@ -49,7 +49,7 @@ function minErr(module, ErrorConstructor) {
4949
},
5050
message, i;
5151

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

5555
if (index + 2 < templateArgs.length) {

src/ng/animate.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ var $AnimateProvider = ['$provide', function($provide) {
260260
className = !isString(className)
261261
? (isArray(className) ? className.join(' ') : '')
262262
: className;
263-
forEach(element, function (element) {
263+
forEach(element, function(element) {
264264
jqLiteAddClass(element, className);
265265
});
266266
applyStyles(element, options);
@@ -289,7 +289,7 @@ var $AnimateProvider = ['$provide', function($provide) {
289289
className = !isString(className)
290290
? (isArray(className) ? className.join(' ') : '')
291291
: className;
292-
forEach(element, function (element) {
292+
forEach(element, function(element) {
293293
jqLiteRemoveClass(element, className);
294294
});
295295
applyStyles(element, options);

src/ng/directive/form.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
237237
* Setting a form back to a pristine state is often useful when we want to 'reuse' a form after
238238
* saving or resetting it.
239239
*/
240-
form.$setPristine = function () {
240+
form.$setPristine = function() {
241241
$animate.setClass(element, PRISTINE_CLASS, DIRTY_CLASS + ' ' + SUBMITTED_CLASS);
242242
form.$dirty = false;
243243
form.$pristine = true;
@@ -260,7 +260,7 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
260260
* Setting a form controls back to their untouched state is often useful when setting the form
261261
* back to its pristine state.
262262
*/
263-
form.$setUntouched = function () {
263+
form.$setUntouched = function() {
264264
forEach(controls, function(control) {
265265
control.$setUntouched();
266266
});
@@ -273,7 +273,7 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
273273
* @description
274274
* Sets the form to its submitted state.
275275
*/
276-
form.$setSubmitted = function () {
276+
form.$setSubmitted = function() {
277277
$animate.addClass(element, SUBMITTED_CLASS);
278278
form.$submitted = true;
279279
parentForm.$setSubmitted();

src/ng/directive/input.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1839,7 +1839,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
18391839
* state (ng-pristine class). A model is considered to be pristine when the model has not been changed
18401840
* from when first compiled within then form.
18411841
*/
1842-
this.$setPristine = function () {
1842+
this.$setPristine = function() {
18431843
ctrl.$dirty = false;
18441844
ctrl.$pristine = true;
18451845
$animate.removeClass($element, DIRTY_CLASS);
@@ -1908,13 +1908,13 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
19081908
* angular.module('cancel-update-example', [])
19091909
*
19101910
* .controller('CancelUpdateController', ['$scope', function($scope) {
1911-
* $scope.resetWithCancel = function (e) {
1911+
* $scope.resetWithCancel = function(e) {
19121912
* if (e.keyCode == 27) {
19131913
* $scope.myForm.myInput1.$rollbackViewValue();
19141914
* $scope.myValue = '';
19151915
* }
19161916
* };
1917-
* $scope.resetWithoutCancel = function (e) {
1917+
* $scope.resetWithoutCancel = function(e) {
19181918
* if (e.keyCode == 27) {
19191919
* $scope.myValue = '';
19201920
* }
@@ -2405,7 +2405,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
24052405
.controller('ExampleController', ['$scope', function($scope) {
24062406
var _name = 'Brian';
24072407
$scope.user = {
2408-
name: function (newName) {
2408+
name: function(newName) {
24092409
if (angular.isDefined(newName)) {
24102410
_name = newName;
24112411
}
@@ -2907,7 +2907,7 @@ var ngValueDirective = function() {
29072907
.controller('ExampleController', ['$scope', function($scope) {
29082908
$scope.user = { name: 'say', data: '' };
29092909
2910-
$scope.cancel = function (e) {
2910+
$scope.cancel = function(e) {
29112911
if (e.keyCode == 27) {
29122912
$scope.userForm.userName.$rollbackViewValue();
29132913
}
@@ -2981,7 +2981,7 @@ var ngValueDirective = function() {
29812981
.controller('ExampleController', ['$scope', function($scope) {
29822982
var _name = 'Brian';
29832983
$scope.user = {
2984-
name: function (newName) {
2984+
name: function(newName) {
29852985
return angular.isDefined(newName) ? (_name = newName) : _name;
29862986
}
29872987
};

src/ng/directive/ngBind.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ var ngBindDirective = ['$compile', function($compile) {
9090
<file name="index.html">
9191
<script>
9292
angular.module('bindExample', [])
93-
.controller('ExampleController', ['$scope', function ($scope) {
93+
.controller('ExampleController', ['$scope', function($scope) {
9494
$scope.salutation = 'Hello';
9595
$scope.name = 'World';
9696
}]);

src/ng/directive/ngClass.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function classDirective(name, selector) {
4141
function digestClassCounts(classes, count) {
4242
var classCounts = element.data('$classCounts') || {};
4343
var classesToUpdate = [];
44-
forEach(classes, function (className) {
44+
forEach(classes, function(className) {
4545
if (count > 0 || classCounts[className]) {
4646
classCounts[className] = (classCounts[className] || 0) + count;
4747
if (classCounts[className] === +(count > 0)) {

src/ng/directive/ngIf.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ var ngIfDirective = ['$animate', function($animate) {
8484
terminal: true,
8585
restrict: 'A',
8686
$$tlb: true,
87-
link: function ($scope, $element, $attr, ctrl, $transclude) {
87+
link: function($scope, $element, $attr, ctrl, $transclude) {
8888
var block, childScope, previousElements;
8989
$scope.$watch($attr.ngIf, function ngIfWatchAction(value) {
9090

9191
if (value) {
9292
if (!childScope) {
93-
$transclude(function (clone, newScope) {
93+
$transclude(function(clone, newScope) {
9494
childScope = newScope;
9595
clone[clone.length++] = document.createComment(' end ngIf: ' + $attr.ngIf + ' ');
9696
// Note: We only need the first/last node of the cloned nodes.

src/ng/directive/ngRepeat.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,10 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
278278
if (trackByExp) {
279279
trackByExpGetter = $parse(trackByExp);
280280
} else {
281-
trackByIdArrayFn = function (key, value) {
281+
trackByIdArrayFn = function(key, value) {
282282
return hashKey(value);
283283
};
284-
trackByIdObjFn = function (key) {
284+
trackByIdObjFn = function(key) {
285285
return key;
286286
};
287287
}
@@ -361,7 +361,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
361361
nextBlockOrder[index] = block;
362362
} else if (nextBlockMap[trackById]) {
363363
// if collision detected. restore lastBlockMap and throw an error
364-
forEach(nextBlockOrder, function (block) {
364+
forEach(nextBlockOrder, function(block) {
365365
if (block && block.scope) lastBlockMap[block.id] = block;
366366
});
367367
throw ngRepeatMinErr('dupes',

src/ng/directive/select.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
664664
updateLabelMap(labelMap, option.label, false);
665665
option.element.remove();
666666
}
667-
forEach(labelMap, function (count, label) {
667+
forEach(labelMap, function(count, label) {
668668
if (count > 0) {
669669
selectCtrl.addOption(label);
670670
} else if (count < 0) {
@@ -699,7 +699,7 @@ var optionDirective = ['$interpolate', function($interpolate) {
699699
}
700700
}
701701

702-
return function (scope, element, attr) {
702+
return function(scope, element, attr) {
703703
var selectCtrlName = '$selectController',
704704
parent = element.parent(),
705705
selectCtrl = parent.data(selectCtrlName) ||

src/ng/exceptionHandler.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* ## Example:
1717
*
1818
* ```js
19-
* angular.module('exceptionOverride', []).factory('$exceptionHandler', function () {
20-
* return function (exception, cause) {
19+
* angular.module('exceptionOverride', []).factory('$exceptionHandler', function() {
20+
* return function(exception, cause) {
2121
* exception.message += ' (caused by "' + cause + '")';
2222
* throw exception;
2323
* };

src/ng/httpBackend.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
7979
statusText);
8080
};
8181

82-
var requestError = function () {
82+
var requestError = function() {
8383
// The response is always empty
8484
// See https://xhr.spec.whatwg.org/#request-error-steps and https://fetch.spec.whatwg.org/#concept-network-error
8585
completeRequest(callback, -1, null, null, '');

src/ng/interpolate.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,13 @@ function $InterpolateProvider() {
237237
return concat.join('');
238238
};
239239

240-
var getValue = function (value) {
240+
var getValue = function(value) {
241241
return trustedContext ?
242242
$sce.getTrusted(trustedContext, value) :
243243
$sce.valueOf(value);
244244
};
245245

246-
var stringify = function (value) {
246+
var stringify = function(value) {
247247
if (value == null) { // null || undefined
248248
return '';
249249
}
@@ -281,7 +281,7 @@ function $InterpolateProvider() {
281281
// all of these properties are undocumented for now
282282
exp: text, //just for compatibility with regular watchers created via $watch
283283
expressions: expressions,
284-
$$watchDelegate: function (scope, listener, objectEquality) {
284+
$$watchDelegate: function(scope, listener, objectEquality) {
285285
var lastValue;
286286
return scope.$watchGroup(parseFns, function interpolateFnWatcher(values, oldValues) {
287287
var currValue = compute(values);

src/ng/location.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ var locationPrototype = {
529529
}
530530
};
531531

532-
forEach([LocationHashbangInHtml5Url, LocationHashbangUrl, LocationHtml5Url], function (Location) {
532+
forEach([LocationHashbangInHtml5Url, LocationHashbangUrl, LocationHtml5Url], function(Location) {
533533
Location.prototype = Object.create(locationPrototype);
534534

535535
/**

src/ng/log.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function $LogProvider() {
108108
* @description
109109
* Write a debug message
110110
*/
111-
debug: (function () {
111+
debug: (function() {
112112
var fn = consoleLog('debug');
113113

114114
return function() {

0 commit comments

Comments
 (0)