Skip to content

Commit ae32900

Browse files
christopherthielenmergify[bot]
authored andcommitted
chore(prettier): Just Update Prettier™️
1 parent b41c594 commit ae32900

11 files changed

+84
-94
lines changed

src/directives/stateDirectives.ts

+23-25
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ function clickHook(
9090
type: TypeInfo,
9191
getDef: () => Def
9292
) {
93-
return function(e: JQueryMouseEventObject) {
93+
return function (e: JQueryMouseEventObject) {
9494
const button = e.which || e.button,
9595
target = getDef();
9696

9797
if (!(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || el.attr('target'))) {
9898
// HACK: This is to allow ng-clicks to be processed before the transition is initiated:
99-
const transition = $timeout(function() {
99+
const transition = $timeout(function () {
100100
if (!el.attr('disabled')) {
101101
$state.go(target.uiState, target.uiStateParams, target.uiStateOpts);
102102
}
@@ -106,7 +106,7 @@ function clickHook(
106106
// if the state has no URL, ignore one preventDefault from the <a> directive.
107107
let ignorePreventDefaultCount = type.isAnchor && !target.href ? 1 : 0;
108108

109-
e.preventDefault = function() {
109+
e.preventDefault = function () {
110110
if (ignorePreventDefaultCount-- <= 0) $timeout.cancel(transition);
111111
};
112112
}
@@ -139,7 +139,7 @@ function bindEvents(element: IAugmentedJQuery, scope: IScope, hookFn: EventListe
139139
element[on](event, hookFn);
140140
}
141141

142-
scope.$on('$destroy', function() {
142+
scope.$on('$destroy', function () {
143143
const off = element.off ? 'off' : 'unbind';
144144
for (const event of events) {
145145
element[off](event, hookFn as any);
@@ -290,7 +290,7 @@ uiSrefDirective = [
290290
return {
291291
restrict: 'A',
292292
require: ['?^uiSrefActive', '?^uiSrefActiveEq'],
293-
link: function(scope: IScope, element: IAugmentedJQuery, attrs: any, uiSrefActive: any) {
293+
link: function (scope: IScope, element: IAugmentedJQuery, attrs: any, uiSrefActive: any) {
294294
const type = getTypeInfo(element);
295295
const active = uiSrefActive[1] || uiSrefActive[0];
296296
let unlinkInfoFn: Function = null;
@@ -313,7 +313,7 @@ uiSrefDirective = [
313313
if (ref.paramExpr) {
314314
scope.$watch(
315315
ref.paramExpr,
316-
function(val) {
316+
function (val) {
317317
rawDef.uiStateParams = extend({}, val);
318318
update();
319319
},
@@ -429,7 +429,7 @@ uiStateDirective = [
429429
return {
430430
restrict: 'A',
431431
require: ['?^uiSrefActive', '?^uiSrefActiveEq'],
432-
link: function(scope: IScope, element: IAugmentedJQuery, attrs: any, uiSrefActive: any) {
432+
link: function (scope: IScope, element: IAugmentedJQuery, attrs: any, uiSrefActive: any) {
433433
const type = getTypeInfo(element);
434434
const active = uiSrefActive[1] || uiSrefActive[0];
435435
let unlinkInfoFn: Function = null;
@@ -448,14 +448,14 @@ uiStateDirective = [
448448
if (def.href != null) attrs.$set(type.attr, def.href);
449449
}
450450

451-
inputAttrs.forEach(field => {
451+
inputAttrs.forEach((field) => {
452452
rawDef[field] = attrs[field] ? scope.$eval(attrs[field]) : null;
453453

454-
attrs.$observe(field, expr => {
454+
attrs.$observe(field, (expr) => {
455455
watchDeregFns[field]();
456456
watchDeregFns[field] = scope.$watch(
457457
expr,
458-
newval => {
458+
(newval) => {
459459
rawDef[field] = newval;
460460
update();
461461
},
@@ -587,7 +587,7 @@ uiSrefActiveDirective = [
587587
'$scope',
588588
'$element',
589589
'$attrs',
590-
function($scope: IScope, $element: IAugmentedJQuery, $attrs: any) {
590+
function ($scope: IScope, $element: IAugmentedJQuery, $attrs: any) {
591591
let states: StateData[] = [];
592592
let activeEqClass: string;
593593
let uiSrefActive: any;
@@ -607,7 +607,7 @@ uiSrefActiveDirective = [
607607
setStatesFromDefinitionObject(uiSrefActive);
608608

609609
// Allow uiSref to communicate with uiSrefActive[Equals]
610-
this.$$addStateInfo = function(newState: string, newParams: Obj) {
610+
this.$$addStateInfo = function (newState: string, newParams: Obj) {
611611
// we already got an explicit state provided by ui-sref-active, so we
612612
// shadow the one that comes from ui-sref
613613
if (isObject(uiSrefActive) && states.length > 0) {
@@ -644,9 +644,9 @@ uiSrefActiveDirective = [
644644
function setStatesFromDefinitionObject(statesDefinition: object) {
645645
if (isObject(statesDefinition)) {
646646
states = [];
647-
forEach(statesDefinition, function(stateOrName: StateOrName | Array<StateOrName>, activeClass: string) {
647+
forEach(statesDefinition, function (stateOrName: StateOrName | Array<StateOrName>, activeClass: string) {
648648
// Helper function to abstract adding state.
649-
const addStateForClass = function(stateOrName: string, activeClass: string) {
649+
const addStateForClass = function (stateOrName: string, activeClass: string) {
650650
const ref = parseStateRef(stateOrName);
651651
addState(ref.state, $scope.$eval(ref.paramExpr), activeClass);
652652
};
@@ -656,7 +656,7 @@ uiSrefActiveDirective = [
656656
addStateForClass(stateOrName as string, activeClass);
657657
} else if (isArray(stateOrName)) {
658658
// If state is an array, iterate over it and add each array item individually.
659-
forEach(stateOrName, function(stateOrName: string) {
659+
forEach(stateOrName, function (stateOrName: string) {
660660
addStateForClass(stateOrName, activeClass);
661661
});
662662
}
@@ -682,26 +682,24 @@ uiSrefActiveDirective = [
682682

683683
// Update route state
684684
function update() {
685-
const splitClasses = str => str.split(/\s/).filter(identity);
685+
const splitClasses = (str) => str.split(/\s/).filter(identity);
686686
const getClasses = (stateList: StateData[]) =>
687687
stateList
688-
.map(x => x.activeClass)
688+
.map((x) => x.activeClass)
689689
.map(splitClasses)
690690
.reduce(unnestR, []);
691691

692-
const allClasses = getClasses(states)
693-
.concat(splitClasses(activeEqClass))
694-
.reduce(uniqR, []);
695-
const fuzzyClasses = getClasses(states.filter(x => $state.includes(x.state.name, x.params)));
696-
const exactlyMatchesAny = !!states.filter(x => $state.is(x.state.name, x.params)).length;
692+
const allClasses = getClasses(states).concat(splitClasses(activeEqClass)).reduce(uniqR, []);
693+
const fuzzyClasses = getClasses(states.filter((x) => $state.includes(x.state.name, x.params)));
694+
const exactlyMatchesAny = !!states.filter((x) => $state.is(x.state.name, x.params)).length;
697695
const exactClasses = exactlyMatchesAny ? splitClasses(activeEqClass) : [];
698696

699697
const addClasses = fuzzyClasses.concat(exactClasses).reduce(uniqR, []);
700-
const removeClasses = allClasses.filter(cls => !inArray(addClasses, cls));
698+
const removeClasses = allClasses.filter((cls) => !inArray(addClasses, cls));
701699

702700
$scope.$evalAsync(() => {
703-
addClasses.forEach(className => $element.addClass(className));
704-
removeClasses.forEach(className => $element.removeClass(className));
701+
addClasses.forEach((className) => $element.addClass(className));
702+
removeClasses.forEach((className) => $element.removeClass(className));
705703
});
706704
}
707705

src/directives/viewDirective.ts

+18-21
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@ uiView = [
185185
) {
186186
function getRenderer(attrs: Obj, scope: IScope) {
187187
return {
188-
enter: function(element: JQuery, target: any, cb: Function) {
188+
enter: function (element: JQuery, target: any, cb: Function) {
189189
if (angular.version.minor > 2) {
190190
$animate.enter(element, null, target).then(cb);
191191
} else {
192192
$animate.enter(element, null, target, cb);
193193
}
194194
},
195-
leave: function(element: JQuery, cb: Function) {
195+
leave: function (element: JQuery, cb: Function) {
196196
if (angular.version.minor > 2) {
197197
$animate.leave(element).then(cb);
198198
} else {
@@ -217,8 +217,8 @@ uiView = [
217217
terminal: true,
218218
priority: 400,
219219
transclude: 'element',
220-
compile: function(tElement: JQuery, tAttrs: Obj, $transclude: ITranscludeFunction) {
221-
return function(scope: IScope, $element: IAugmentedJQuery, attrs: Obj) {
220+
compile: function (tElement: JQuery, tAttrs: Obj, $transclude: ITranscludeFunction) {
221+
return function (scope: IScope, $element: IAugmentedJQuery, attrs: Obj) {
222222
const onloadExp = attrs['onload'] || '',
223223
autoScrollExp = attrs['autoscroll'],
224224
renderer = getRenderer(attrs, scope),
@@ -264,7 +264,7 @@ uiView = [
264264
updateView();
265265

266266
unregister = $view.registerUIView(activeUIView);
267-
scope.$on('$destroy', function() {
267+
scope.$on('$destroy', function () {
268268
trace.traceUIViewEvent('Destroying/Unregistering', activeUIView);
269269
unregister();
270270
});
@@ -285,7 +285,7 @@ uiView = [
285285
if (currentEl) {
286286
const _viewData = currentEl.data('$uiViewAnim');
287287
trace.traceUIViewEvent('Animate out', _viewData);
288-
renderer.leave(currentEl, function() {
288+
renderer.leave(currentEl, function () {
289289
_viewData.$$animLeave.resolve();
290290
previousEl = null;
291291
});
@@ -325,7 +325,7 @@ uiView = [
325325
*/
326326
newScope.$emit('$viewContentLoading', name);
327327

328-
const cloned = $transclude(newScope, function(clone) {
328+
const cloned = $transclude(newScope, function (clone) {
329329
clone.data('$uiViewAnim', $uiViewAnim);
330330
clone.data('$uiView', $uiViewData);
331331
renderer.enter(clone, $element, function onUIViewEnter() {
@@ -380,11 +380,11 @@ function $ViewDirectiveFill(
380380
return {
381381
restrict: 'ECA',
382382
priority: -400,
383-
compile: function(tElement: JQuery) {
383+
compile: function (tElement: JQuery) {
384384
const initial = tElement.html();
385385
tElement.empty();
386386

387-
return function(scope: IScope, $element: JQuery) {
387+
return function (scope: IScope, $element: JQuery) {
388388
const data: UIViewData = $element.data('$uiView');
389389
if (!data) {
390390
$element.html(initial);
@@ -438,7 +438,7 @@ function $ViewDirectiveFill(
438438
return directiveEl && angular.element(directiveEl).data(`$${cfg.component}Controller`);
439439
};
440440

441-
const deregisterWatch = scope.$watch(getComponentController, function(ctrlInstance) {
441+
const deregisterWatch = scope.$watch(getComponentController, function (ctrlInstance) {
442442
if (!ctrlInstance) return;
443443
registerControllerCallbacks($q, $transitions, ctrlInstance, scope, cfg);
444444
deregisterWatch();
@@ -465,7 +465,10 @@ function registerControllerCallbacks(
465465
cfg: Ng1ViewConfig
466466
) {
467467
// Call $onInit() ASAP
468-
if (isFunction(controllerInstance.$onInit) && !((cfg.viewDecl.component || cfg.viewDecl.componentProvider) && hasComponentImpl)) {
468+
if (
469+
isFunction(controllerInstance.$onInit) &&
470+
!((cfg.viewDecl.component || cfg.viewDecl.componentProvider) && hasComponentImpl)
471+
) {
469472
controllerInstance.$onInit();
470473
}
471474

@@ -487,14 +490,8 @@ function registerControllerCallbacks(
487490
const toParams = $transition$.params('to') as TypedMap<any>;
488491
const fromParams = $transition$.params<TypedMap<any>>('from') as TypedMap<any>;
489492
const getNodeSchema = (node: PathNode) => node.paramSchema;
490-
const toSchema: Param[] = $transition$
491-
.treeChanges('to')
492-
.map(getNodeSchema)
493-
.reduce(unnestR, []);
494-
const fromSchema: Param[] = $transition$
495-
.treeChanges('from')
496-
.map(getNodeSchema)
497-
.reduce(unnestR, []);
493+
const toSchema: Param[] = $transition$.treeChanges('to').map(getNodeSchema).reduce(unnestR, []);
494+
const fromSchema: Param[] = $transition$.treeChanges('from').map(getNodeSchema).reduce(unnestR, []);
498495

499496
// Find the to params that have different values than the from params
500497
const changedToParams = toSchema.filter((param: Param) => {
@@ -504,7 +501,7 @@ function registerControllerCallbacks(
504501

505502
// Only trigger callback if a to param has changed or is new
506503
if (changedToParams.length) {
507-
const changedKeys: string[] = changedToParams.map(x => x.id);
504+
const changedKeys: string[] = changedToParams.map((x) => x.id);
508505
// Filter the params to only changed/new to params. `$transition$.params()` may be used to get all params.
509506
const newValues = filter(toParams, (val, key) => changedKeys.indexOf(key) !== -1);
510507
controllerInstance.uiOnParamsChanged(newValues, $transition$);
@@ -529,7 +526,7 @@ function registerControllerCallbacks(
529526

530527
if (!prevTruthyAnswer(trans)) {
531528
promise = $q.when(controllerInstance.uiCanExit(trans));
532-
promise.then(val => (ids[id] = val !== false));
529+
promise.then((val) => (ids[id] = val !== false));
533530
}
534531
return promise;
535532
};

src/legacy/resolveService.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ const $resolve = {
5050
context.addResolvables(resolvablesBuilder(<any>{ resolve: invocables }), node.state);
5151

5252
const resolveData = (parentLocals: Obj) => {
53-
const rewrap = (_locals: Obj) => resolvablesBuilder(<any>{ resolve: mapObj(_locals, local => () => local) });
53+
const rewrap = (_locals: Obj) => resolvablesBuilder(<any>{ resolve: mapObj(_locals, (local) => () => local) });
5454
context.addResolvables(rewrap(parentLocals), parentNode.state);
5555
context.addResolvables(rewrap(locals), node.state);
5656

5757
const tuples2ObjR = (acc: Obj, tuple: { token: any; value: any }) => {
5858
acc[tuple.token] = tuple.value;
5959
return acc;
6060
};
61-
return context.resolvePath().then(results => results.reduce(tuples2ObjR, {}));
61+
return context.resolvePath().then((results) => results.reduce(tuples2ObjR, {}));
6262
};
6363

6464
return parent ? parent.then(resolveData) : resolveData({});

src/legacy/stateEvents.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export let $stateChangeError: IAngularEvent;
159159
*/
160160
export let $stateNotFound: IAngularEvent;
161161

162-
(function() {
162+
(function () {
163163
const { isFunction, isString } = angular;
164164

165165
function applyPairs(memo: Obj, keyValTuple: any[]) {
@@ -216,7 +216,7 @@ export let $stateNotFound: IAngularEvent;
216216
const successOpts = { priority: 9999 };
217217
$transition$.onSuccess(
218218
{},
219-
function() {
219+
function () {
220220
$rootScope.$broadcast(
221221
'$stateChangeSuccess',
222222
$transition$.to(),
@@ -232,7 +232,7 @@ export let $stateNotFound: IAngularEvent;
232232
}
233233

234234
if (enabledEvents.$stateChangeError) {
235-
$transition$.promise['catch'](function(error) {
235+
$transition$.promise['catch'](function (error) {
236236
if (error && (error.type === 2 /* RejectType.SUPERSEDED */ || error.type === 3) /* RejectType.ABORTED */)
237237
return;
238238

@@ -294,7 +294,7 @@ export let $stateNotFound: IAngularEvent;
294294

295295
let runtime = false;
296296
const allEvents = ['$stateChangeStart', '$stateNotFound', '$stateChangeSuccess', '$stateChangeError'];
297-
const enabledStateEvents = <IEventsToggle>allEvents.map(e => [e, true]).reduce(applyPairs, {});
297+
const enabledStateEvents = <IEventsToggle>allEvents.map((e) => [e, true]).reduce(applyPairs, {});
298298

299299
function assertNotRuntime() {
300300
if (runtime) throw new Error('Cannot enable events at runtime (use $stateEventsProvider');
@@ -304,20 +304,20 @@ export let $stateNotFound: IAngularEvent;
304304
* Enables the deprecated UI-Router 0.2.x State Events
305305
* [ '$stateChangeStart', '$stateNotFound', '$stateChangeSuccess', '$stateChangeError' ]
306306
*/
307-
this.enable = function(...events: string[]) {
307+
this.enable = function (...events: string[]) {
308308
assertNotRuntime();
309309
if (!events || !events.length) events = allEvents;
310-
events.forEach(event => (enabledStateEvents[event] = true));
310+
events.forEach((event) => (enabledStateEvents[event] = true));
311311
};
312312

313313
/**
314314
* Disables the deprecated UI-Router 0.2.x State Events
315315
* [ '$stateChangeStart', '$stateNotFound', '$stateChangeSuccess', '$stateChangeError' ]
316316
*/
317-
this.disable = function(...events: string[]) {
317+
this.disable = function (...events: string[]) {
318318
assertNotRuntime();
319319
if (!events || !events.length) events = allEvents;
320-
events.forEach(event => delete enabledStateEvents[event]);
320+
events.forEach((event) => delete enabledStateEvents[event]);
321321
};
322322

323323
this.enabled = () => enabledStateEvents;
@@ -341,7 +341,7 @@ export let $stateNotFound: IAngularEvent;
341341
.provider('$stateEvents', ($StateEventsProvider as any) as IServiceProviderFactory)
342342
.run([
343343
'$stateEvents',
344-
function($stateEvents: any) {
344+
function ($stateEvents: any) {
345345
/* Invokes $get() */
346346
},
347347
]);

src/locationServices.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ export class Ng1LocationServices implements LocationConfig, LocationServices {
4343
const pathType: ParamType = router.urlMatcherFactory.type('path');
4444

4545
pathType.encode = (x: any) =>
46-
x != null ? x.toString().replace(/(~|\/)/g, m => ({ '~': '~~', '/': '~2F' }[m])) : x;
46+
x != null ? x.toString().replace(/(~|\/)/g, (m) => ({ '~': '~~', '/': '~2F' }[m])) : x;
4747

4848
pathType.decode = (x: string) =>
49-
x != null ? x.toString().replace(/(~~|~2F)/g, m => ({ '~~': '~', '~2F': '/' }[m])) : x;
49+
x != null ? x.toString().replace(/(~~|~2F)/g, (m) => ({ '~~': '~', '~2F': '/' }[m])) : x;
5050
}
5151

5252
dispose() {}
@@ -86,7 +86,7 @@ export class Ng1LocationServices implements LocationConfig, LocationServices {
8686
this.$window = $window;
8787

8888
// Bind $locationChangeSuccess to the listeners registered in LocationService.onChange
89-
$rootScope.$on('$locationChangeSuccess', evt => this._urlListeners.forEach(fn => fn(evt)));
89+
$rootScope.$on('$locationChangeSuccess', (evt) => this._urlListeners.forEach((fn) => fn(evt)));
9090
const _loc = val($location);
9191

9292
// Bind these LocationService functions to $location

0 commit comments

Comments
 (0)