Skip to content

Commit f4a9746

Browse files
committed
build: align formatting config with other repos
Aligns the Prettier config with the other Angular projects.
1 parent 9637b24 commit f4a9746

File tree

123 files changed

+1333
-2178
lines changed

Some content is hidden

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

123 files changed

+1333
-2178
lines changed

.prettierrc.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
2-
"semi": true,
3-
"trailingComma": "es5",
2+
"printWidth": 100,
43
"singleQuote": true,
5-
"printWidth": 80,
6-
"tabWidth": 2,
4+
"trailingComma": "all",
5+
"quoteProps": "preserve",
6+
"bracketSpacing": false,
7+
"arrowParens": "avoid",
8+
"embeddedLanguageFormatting": "off",
79
"overrides": [
810
{
911
"files": "*.html",

report-app/report-server.ts

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ import {
55
writeResponseToNodeResponse,
66
} from '@angular/ssr/node';
77
import express from 'express';
8-
import { dirname, isAbsolute, join, resolve } from 'node:path';
9-
import { fileURLToPath } from 'node:url';
10-
import {
11-
FetchedLocalReports,
12-
fetchReportsFromDisk,
13-
} from '../runner/reporting/report-local-disk';
14-
import { RunInfo } from '../runner/shared-interfaces';
15-
import { convertV2ReportToV3Report } from '../runner/reporting/migrations/v2_to_v3';
8+
import {dirname, isAbsolute, join, resolve} from 'node:path';
9+
import {fileURLToPath} from 'node:url';
10+
import {FetchedLocalReports, fetchReportsFromDisk} from '../runner/reporting/report-local-disk';
11+
import {RunInfo} from '../runner/shared-interfaces';
12+
import {convertV2ReportToV3Report} from '../runner/reporting/migrations/v2_to_v3';
1613

1714
const app = express();
1815
const reportsLoader = await getReportLoader();
@@ -50,7 +47,7 @@ app.get('/api/reports/:id', async (req, res) => {
5047
}
5148

5249
// Convert potential older v2 reports.
53-
result = result.map((r) => convertV2ReportToV3Report(r));
50+
result = result.map(r => convertV2ReportToV3Report(r));
5451

5552
res.json(result);
5653
});
@@ -60,13 +57,13 @@ app.use(
6057
maxAge: '1y',
6158
index: false,
6259
redirect: false,
63-
})
60+
}),
6461
);
6562

6663
app.use('/**', (req, res, next) => {
6764
angularApp
6865
.handle(req)
69-
.then((response) => {
66+
.then(response => {
7067
return response ? writeResponseToNodeResponse(response, res) : next();
7168
})
7269
.catch(next);
@@ -85,22 +82,19 @@ export const reqHandler = createNodeRequestHandler(app);
8582

8683
interface ReportLoader {
8784
getGroupedReports: (groupId: string) => Promise<RunInfo[]>;
88-
getGroupsList: () => Promise<{ id: string }[]>;
85+
getGroupsList: () => Promise<{id: string}[]>;
8986
configureEndpoints?: (expressApp: typeof app) => Promise<void>;
9087
}
9188

9289
/** Gets the server options from the command line. */
9390
function getOptions() {
9491
const defaultPort = 4200;
9592
const envPort = process.env['CODEGEN_REPORTS_PORT'];
96-
const reportsRoot =
97-
process.env['CODEGEN_REPORTS_DIR'] || './.web-codegen-scorer/reports';
93+
const reportsRoot = process.env['CODEGEN_REPORTS_DIR'] || './.web-codegen-scorer/reports';
9894

9995
return {
10096
port: envPort ? parseInt(envPort) || defaultPort : defaultPort,
101-
reportsRoot: isAbsolute(reportsRoot)
102-
? reportsRoot
103-
: join(process.cwd(), reportsRoot),
97+
reportsRoot: isAbsolute(reportsRoot) ? reportsRoot : join(process.cwd(), reportsRoot),
10498
};
10599
}
106100

@@ -118,9 +112,7 @@ async function getReportLoader() {
118112
const loaderImportPath = isAbsolute(reportLoaderPath)
119113
? reportLoaderPath
120114
: join(process.cwd(), reportLoaderPath);
121-
const importResult: { default: ReportLoader } = await import(
122-
/* @vite-ignore */ loaderImportPath
123-
);
115+
const importResult: {default: ReportLoader} = await import(/* @vite-ignore */ loaderImportPath);
124116

125117
if (
126118
!importResult.default ||
@@ -129,7 +121,7 @@ async function getReportLoader() {
129121
) {
130122
throw new Error(
131123
'Invalid remote import loader. The file must have a default export ' +
132-
'with `getGroupedReports` and `getGroupsList` functions.'
124+
'with `getGroupedReports` and `getGroupsList` functions.',
133125
);
134126
}
135127

@@ -140,7 +132,7 @@ async function resolveLocalData(directory: string) {
140132
// Reuse the same promise so that concurrent requests get the same response.
141133
if (!localDataPromise) {
142134
let resolveFn: (data: FetchedLocalReports) => void;
143-
localDataPromise = new Promise((resolve) => (resolveFn = resolve));
135+
localDataPromise = new Promise(resolve => (resolveFn = resolve));
144136
resolveFn!(await fetchReportsFromDisk(directory));
145137
}
146138

report-app/src/app/app.config.server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { provideServerRendering, RenderMode, withRoutes } from '@angular/ssr';
2-
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
3-
import { appConfig } from './app.config';
1+
import {provideServerRendering, RenderMode, withRoutes} from '@angular/ssr';
2+
import {mergeApplicationConfig, ApplicationConfig} from '@angular/core';
3+
import {appConfig} from './app.config';
44

55
const ssrAppConfig: ApplicationConfig = {
66
providers: [
@@ -11,7 +11,7 @@ const ssrAppConfig: ApplicationConfig = {
1111
path: '**',
1212
renderMode: RenderMode.Server,
1313
},
14-
])
14+
]),
1515
),
1616
],
1717
};

report-app/src/app/app.config.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@ import {
55
provideBrowserGlobalErrorListeners,
66
provideZoneChangeDetection,
77
} from '@angular/core';
8-
import {
9-
provideRouter,
10-
withComponentInputBinding,
11-
withViewTransitions,
12-
} from '@angular/router';
8+
import {provideRouter, withComponentInputBinding, withViewTransitions} from '@angular/router';
139

14-
import { routes } from './app.routes';
15-
import { provideHttpClient, withFetch } from '@angular/common/http';
16-
import { GoogleChartsLoader } from './services/google-charts-loader';
10+
import {routes} from './app.routes';
11+
import {provideHttpClient, withFetch} from '@angular/common/http';
12+
import {GoogleChartsLoader} from './services/google-charts-loader';
1713

1814
export const appConfig: ApplicationConfig = {
1915
providers: [
2016
provideBrowserGlobalErrorListeners(),
21-
provideZoneChangeDetection({ eventCoalescing: true }),
17+
provideZoneChangeDetection({eventCoalescing: true}),
2218
provideRouter(routes, withComponentInputBinding(), withViewTransitions()),
2319
provideHttpClient(withFetch()),
2420
provideAppInitializer(() => inject(GoogleChartsLoader).initialize()),

report-app/src/app/app.routes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Routes } from '@angular/router';
2-
import { ReportViewer } from './pages/report-viewer/report-viewer';
3-
import { ComparisonPage } from './pages/comparison/comparison';
4-
import { ReportListComponent } from './pages/report-list/report-list';
1+
import {Routes} from '@angular/router';
2+
import {ReportViewer} from './pages/report-viewer/report-viewer';
3+
import {ComparisonPage} from './pages/comparison/comparison';
4+
import {ReportListComponent} from './pages/report-list/report-list';
55

66
export const routes: Routes = [
77
{

report-app/src/app/app.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { TestBed } from '@angular/core/testing';
2-
import { App } from './app';
1+
import {TestBed} from '@angular/core/testing';
2+
import {App} from './app';
33

44
describe('App', () => {
55
beforeEach(async () => {
@@ -18,8 +18,6 @@ describe('App', () => {
1818
const fixture = TestBed.createComponent(App);
1919
fixture.detectChanges();
2020
const compiled = fixture.nativeElement as HTMLElement;
21-
expect(compiled.querySelector('h1')?.textContent).toContain(
22-
'Hello, report-app'
23-
);
21+
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, report-app');
2422
});
2523
});

report-app/src/app/app.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Component, inject, PLATFORM_ID } from '@angular/core';
2-
import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
3-
import { ReportsFetcher } from './services/reports-fetcher';
4-
import { isPlatformServer } from '@angular/common';
5-
import { AppColorMode } from './services/app-color-mode';
1+
import {Component, inject, PLATFORM_ID} from '@angular/core';
2+
import {RouterLink, RouterLinkActive, RouterOutlet} from '@angular/router';
3+
import {ReportsFetcher} from './services/reports-fetcher';
4+
import {isPlatformServer} from '@angular/common';
5+
import {AppColorMode} from './services/app-color-mode';
66

77
@Component({
88
selector: 'app-root',
@@ -21,8 +21,6 @@ export class App {
2121
protected groupsError = this.reportsFetcher.reportGroupsError;
2222

2323
protected toggleColorMode() {
24-
this.colorModeService.setColorMode(
25-
this.colorMode() === 'light' ? 'dark' : 'light'
26-
);
24+
this.colorModeService.setColorMode(this.colorMode() === 'light' ? 'dark' : 'light');
2725
}
2826
}

report-app/src/app/pages/comparison/comparison.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { Component, computed, inject, linkedSignal } from '@angular/core';
2-
import { toSignal } from '@angular/core/rxjs-interop';
3-
import { map } from 'rxjs';
4-
import { ComparisonScoreDistribution } from '../../shared/comparison/comparison-score-distribution';
5-
import { ComparisonBuildDistribution } from '../../shared/comparison/comparison-build-distribution';
6-
import { ModelComparisonData } from '../../shared/comparison/comparison-data';
7-
import { ReportsFetcher } from '../../services/reports-fetcher';
8-
import { ReportSelect } from '../../shared/report-select/report-select';
9-
import { ComparisonRuntimeDistribution } from '../../shared/comparison/comparison-runtime-distribution';
10-
import { ActivatedRoute } from '@angular/router';
1+
import {Component, computed, inject, linkedSignal} from '@angular/core';
2+
import {toSignal} from '@angular/core/rxjs-interop';
3+
import {map} from 'rxjs';
4+
import {ComparisonScoreDistribution} from '../../shared/comparison/comparison-score-distribution';
5+
import {ComparisonBuildDistribution} from '../../shared/comparison/comparison-build-distribution';
6+
import {ModelComparisonData} from '../../shared/comparison/comparison-data';
7+
import {ReportsFetcher} from '../../services/reports-fetcher';
8+
import {ReportSelect} from '../../shared/report-select/report-select';
9+
import {ComparisonRuntimeDistribution} from '../../shared/comparison/comparison-runtime-distribution';
10+
import {ActivatedRoute} from '@angular/router';
1111

1212
@Component({
1313
templateUrl: './comparison.html',
@@ -31,10 +31,10 @@ export class ComparisonPage {
3131
}),
3232
computation: () => {
3333
const allGroups = this.groups();
34-
const results: { reportName: string; groupId: string | null }[] = [];
34+
const results: {reportName: string; groupId: string | null}[] = [];
3535

36-
this.selectedGroups().forEach((id) => {
37-
const correspondingGroup = allGroups.find((group) => group.id === id);
36+
this.selectedGroups().forEach(id => {
37+
const correspondingGroup = allGroups.find(group => group.id === id);
3838

3939
if (correspondingGroup) {
4040
results.push({
@@ -50,34 +50,33 @@ export class ComparisonPage {
5050

5151
readonly selectedGroups = toSignal<string[]>(
5252
this.route.queryParams.pipe(
53-
map((params) => {
53+
map(params => {
5454
const ids = params['groups'];
5555
return ids && Array.isArray(ids) ? ids : [];
56-
})
56+
}),
5757
),
58-
{ requireSync: true }
58+
{requireSync: true},
5959
);
6060

6161
readonly comparisonModelData = computed(() => {
6262
const allGroups = this.groups();
6363
const selectedGroups = this.groupsToCompare()
64-
.map((g) => ({
64+
.map(g => ({
6565
reportName: g.reportName,
66-
group: allGroups.find((current) => current.id === g.groupId)!,
66+
group: allGroups.find(current => current.id === g.groupId)!,
6767
}))
68-
.filter((g) => !!g.group);
68+
.filter(g => !!g.group);
6969

7070
if (selectedGroups.length < 2) {
7171
return null;
7272
}
7373

7474
return {
7575
averageAppsCount: Math.floor(
76-
selectedGroups.reduce((acc, r) => r.group.appsCount + acc, 0) /
77-
selectedGroups.length
76+
selectedGroups.reduce((acc, r) => r.group.appsCount + acc, 0) / selectedGroups.length,
7877
),
7978
series: [
80-
...selectedGroups.map((r) => ({
79+
...selectedGroups.map(r => ({
8180
name: r.reportName,
8281
stats: r.group.stats,
8382
appsCount: r.group.appsCount,
@@ -86,15 +85,15 @@ export class ComparisonPage {
8685
} satisfies ModelComparisonData;
8786
});
8887

89-
protected updateReportName(report: { reportName: string }, newName: string) {
88+
protected updateReportName(report: {reportName: string}, newName: string) {
9089
report.reportName = newName;
9190
this.groupsToCompare.set([...this.groupsToCompare()]);
9291
}
9392

9493
protected setSelectedGroup(index: number, groupId: string | undefined) {
9594
const allGroups = this.groups();
9695
const current = this.groupsToCompare();
97-
const correspondingGroup = allGroups.find((group) => group.id === groupId);
96+
const correspondingGroup = allGroups.find(group => group.id === groupId);
9897

9998
if (correspondingGroup) {
10099
current[index] = {

0 commit comments

Comments
 (0)