Skip to content

Commit f9781f9

Browse files
josephperrottdylhunn
authored andcommitted
refactor: migrate modules to prettier formatting (angular#53954)
Migrate formatting to prettier for modules directory from clang-format PR Close angular#53954
1 parent 616df43 commit f9781f9

File tree

100 files changed

+1511
-1168
lines changed

Some content is hidden

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

100 files changed

+1511
-1168
lines changed

.ng-dev/format.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const format: FormatConfig = {
88
'matchers': [
99
'**/*.{yaml,yml}',
1010
'tools/**/*.{js,ts}',
11+
'modules/**/*.{js,ts}',
1112
],
1213
},
1314
'clang-format': {
@@ -37,6 +38,7 @@ export const format: FormatConfig = {
3738

3839
// Migrated to prettier
3940
'!tools/**/*.{js,ts}',
41+
'!modules/**/*.{js,ts}',
4042
],
4143
},
4244
'buildifier': true,

modules/benchmarks/src/change_detection/change_detection.e2e-spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {openBrowser, verifyNoBrowserErrors} from '@angular/build-tooling/bazel/benchmark/driver-utilities';
9+
import {
10+
openBrowser,
11+
verifyNoBrowserErrors,
12+
} from '@angular/build-tooling/bazel/benchmark/driver-utilities';
1013
import {$} from 'protractor';
1114

1215
describe('change detection benchmark', () => {

modules/benchmarks/src/change_detection/change_detection.perf-spec.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {runBenchmark, verifyNoBrowserErrors} from '@angular/build-tooling/bazel/benchmark/driver-utilities';
9+
import {
10+
runBenchmark,
11+
verifyNoBrowserErrors,
12+
} from '@angular/build-tooling/bazel/benchmark/driver-utilities';
1013
import {$} from 'protractor';
1114

1215
interface Worker {
@@ -22,7 +25,7 @@ const InsertionNotDirtyWorker: Worker = {
2225
$('#destroyDom').click();
2326
$('#createDom').click();
2427
},
25-
work: () => $('#detectChanges').click()
28+
work: () => $('#detectChanges').click(),
2629
};
2730

2831
// Used to benchmark performance when both declaration and insertion trees are dirty.
@@ -33,10 +36,9 @@ const AllComponentsDirtyWorker: Worker = {
3336
$('#createDom').click();
3437
$('#markInsertionComponentForCheck').click();
3538
},
36-
work: () => $('#detectChanges').click()
39+
work: () => $('#detectChanges').click(),
3740
};
3841

39-
4042
// In order to make sure that we don't change the ids of the benchmarks, we need to
4143
// determine the current test package name from the Bazel target. This is necessary
4244
// because previous to the Bazel conversion, the benchmark test ids contained the test
@@ -55,21 +57,25 @@ describe('change detection benchmark perf', () => {
5557
id: `change_detection.${testPackageName}.${worker.id}`,
5658
url: '/',
5759
ignoreBrowserSynchronization: true,
58-
worker: worker
60+
worker: worker,
5961
});
6062
});
6163
});
6264
});
6365
});
6466

65-
function runChangeDetectionBenchmark(
66-
config: {id: string, url: string, ignoreBrowserSynchronization?: boolean, worker: Worker}) {
67+
function runChangeDetectionBenchmark(config: {
68+
id: string;
69+
url: string;
70+
ignoreBrowserSynchronization?: boolean;
71+
worker: Worker;
72+
}) {
6773
return runBenchmark({
6874
id: config.id,
6975
url: config.url,
7076
ignoreBrowserSynchronization: config.ignoreBrowserSynchronization,
7177
params: [{name: 'viewCount', value: 10}],
7278
prepare: config.worker.prepare,
73-
work: config.worker.work
79+
work: config.worker.work,
7480
});
7581
}

modules/benchmarks/src/change_detection/transplanted_views/transplanted_views.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77
*/
88

99
import {NgForOfContext} from '@angular/common';
10-
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, NgModule, TemplateRef, ViewChild} from '@angular/core';
10+
import {
11+
ChangeDetectionStrategy,
12+
ChangeDetectorRef,
13+
Component,
14+
Input,
15+
NgModule,
16+
TemplateRef,
17+
ViewChild,
18+
} from '@angular/core';
1119
import {BrowserModule} from '@angular/platform-browser';
1220

1321
import {newArray} from '../util';
@@ -17,7 +25,7 @@ import {newArray} from '../util';
1725
template: `
1826
<ng-container *ngFor="let n of views; template: template; trackBy: trackByIndex"></ng-container>
1927
`,
20-
changeDetection: ChangeDetectionStrategy.OnPush
28+
changeDetection: ChangeDetectionStrategy.OnPush,
2129
})
2230
export class InsertionComponent {
2331
@Input() template!: TemplateRef<NgForOfContext<any, any[]>>;
@@ -38,8 +46,8 @@ export class InsertionComponent {
3846
@Component({
3947
selector: 'declaration-component',
4048
template: `
41-
<ng-template #template>{{trackTemplateRefresh()}}</ng-template>
42-
<insertion-component [template]="template" [viewCount]="viewCount"></insertion-component>
49+
<ng-template #template>{{ trackTemplateRefresh() }}</ng-template>
50+
<insertion-component [template]="template" [viewCount]="viewCount"></insertion-component>
4351
`,
4452
})
4553
export class DeclarationComponent {
@@ -57,7 +65,6 @@ export class DeclarationComponent {
5765
@NgModule({
5866
declarations: [DeclarationComponent, InsertionComponent],
5967
bootstrap: [DeclarationComponent],
60-
imports: [BrowserModule]
68+
imports: [BrowserModule],
6169
})
62-
export class TransplantedViewsModule {
63-
}
70+
export class TransplantedViewsModule {}

modules/benchmarks/src/class_bindings/app.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ import {Component} from '@angular/core';
1313
<button id="create" (click)="create()">Create</button>
1414
<button id="update" (click)="update()">Update</button>
1515
<button id="destroy" (click)="destroy()">Destroy</button>
16-
<class-bindings *ngIf="show" [msg]="msg" [list]="list"><class-bindings>
17-
`
16+
<class-bindings *ngIf="show" [msg]="msg" [list]="list"
17+
><class-bindings> </class-bindings
18+
></class-bindings>
19+
`,
1820
})
1921
export class AppComponent {
2022
show = false;
2123
msg = 'hello';
22-
list: {i: number, text: string}[] = [];
24+
list: {i: number; text: string}[] = [];
2325

2426
constructor() {
2527
for (let i = 0; i < 1000; i++) {

modules/benchmarks/src/class_bindings/app.module.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {ClassBindingsComponent} from './class_bindings.component';
1515
declarations: [AppComponent, ClassBindingsComponent],
1616
imports: [BrowserModule],
1717
providers: [],
18-
bootstrap: [AppComponent]
18+
bootstrap: [AppComponent],
1919
})
20-
export class AppModule {
21-
}
20+
export class AppModule {}

modules/benchmarks/src/class_bindings/class_bindings.component.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,27 @@ import {Component, Input} from '@angular/core';
1010
@Component({
1111
selector: 'class-bindings',
1212
template: `
13-
<div>
14-
<p>{{ msg }}</p>
15-
<div *ngFor="let obj of list; let i = index" [title]="msg + i">
16-
<span [class]="msg">{{ obj.text }}</span>
17-
<span class="baz">one</span>
18-
<span class="qux">two</span>
1913
<div>
20-
<span class="qux">three</span>
21-
<span class="qux">four</span>
22-
<span class="baz">five</span>
23-
<div>
24-
<span class="qux">six</span>
25-
<span class="baz">seven</span>
26-
<span [class]="msg">eight</span>
14+
<p>{{ msg }}</p>
15+
<div *ngFor="let obj of list; let i = index" [title]="msg + i">
16+
<span [class]="msg">{{ obj.text }}</span>
17+
<span class="baz">one</span>
18+
<span class="qux">two</span>
19+
<div>
20+
<span class="qux">three</span>
21+
<span class="qux">four</span>
22+
<span class="baz">five</span>
23+
<div>
24+
<span class="qux">six</span>
25+
<span class="baz">seven</span>
26+
<span [class]="msg">eight</span>
27+
</div>
28+
</div>
2729
</div>
2830
</div>
29-
</div>
30-
</div>
31-
`
31+
`,
3232
})
3333
export class ClassBindingsComponent {
3434
@Input() msg: string = '';
35-
@Input() list: string[]|null = null;
35+
@Input() list: string[] | null = null;
3636
}

modules/benchmarks/src/class_bindings/class_bindings.perf-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('class bindings perf', () => {
1818
ignoreBrowserSynchronization: true,
1919
params: [],
2020
prepare: () => $('#destroy').click(),
21-
work: () => $('#create').click()
21+
work: () => $('#create').click(),
2222
});
2323
});
2424

@@ -30,7 +30,7 @@ describe('class bindings perf', () => {
3030
ignoreBrowserSynchronization: true,
3131
params: [],
3232
prepare: () => $('#create').click(),
33-
work: () => $('#update').click()
33+
work: () => $('#update').click(),
3434
});
3535
});
3636
});

modules/benchmarks/src/defer/baseline/app.component.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@ let trustedGreyColor: SafeStyle;
2121
<table>
2222
<tbody>
2323
@for (row of data; track $index) {
24-
<tr>
25-
@for (cell of row; track $index) {
26-
<td [style.backgroundColor]="getColor(cell.row)">
27-
@if (condition) {
28-
<!--
24+
<tr>
25+
@for (cell of row; track $index) {
26+
<td [style.backgroundColor]="getColor(cell.row)">
27+
@if (condition) {
28+
<!--
2929
Use static text in cells to avoid the need
3030
to run a new change detection cycle.
3131
-->
32-
Cell
33-
}
34-
</td>
35-
}
36-
</tr>
32+
Cell }
33+
</td>
34+
}
35+
</tr>
3736
}
3837
</tbody>
3938
</table>

modules/benchmarks/src/defer/baseline/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,5 @@ import {AppComponent} from './app.component';
1515
syncUrlParamsToForm();
1616

1717
bootstrapApplication(AppComponent, {
18-
providers: [
19-
provideProtractorTestingSupport(),
20-
],
18+
providers: [provideProtractorTestingSupport()],
2119
}).then(init);

0 commit comments

Comments
 (0)