Skip to content

Commit b472450

Browse files
committed
refactor: migrate to latest prettier
Signed-off-by: Vojtech Masek <[email protected]>
1 parent 5d31afc commit b472450

File tree

33 files changed

+114
-111
lines changed

33 files changed

+114
-111
lines changed

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"singleQuote": true,
33
"arrowParens": "avoid",
44
"trailingComma": "all",
5+
"plugins": ["@trivago/prettier-plugin-sort-imports"],
56
"importOrder": [
67
"^@code-pushup/portal-client$",
78
"^@code-pushup/(.*)$",

CONTRIBUTING.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ npm install
1616

1717
This table provides a quick overview of the environmental setup, with detailed explanations in the corresponding sections.
1818

19-
| Feature | Local Default | CI Default | Description |
20-
| -------------------------------- | ------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
21-
| `env.INCLUDE_SLOW_TESTS` **❗️** | `false` | `true` | Controls inclusion of long-running tests. Overridden by setting. Details in the [Testing](#Testing) section. |
22-
| `env.CUSTOM_CHROME_PATH` | N/A | Windows **❗️❗️** | Path to Chrome executable. See [plugin-lighthouse/CONTRIBUTING.md](./packages/plugin-lighthouse/CONTRIBUTING.md#chrome-path). |
23-
| Quality Pipeline | Off | On | Runs all plugins against the codebase. |
19+
| Feature | Local Default | CI Default | Description |
20+
| ------------------------------- | ------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------- |
21+
| `env.INCLUDE_SLOW_TESTS` **❗️** | `false` | `true` | Controls inclusion of long-running tests. Overridden by setting. Details in the [Testing](#Testing) section. |
22+
| `env.CUSTOM_CHROME_PATH` | N/A | Windows **❗️❗️** | Path to Chrome executable. See [plugin-lighthouse/CONTRIBUTING.md](./packages/plugin-lighthouse/CONTRIBUTING.md#chrome-path). |
23+
| Quality Pipeline | Off | On | Runs all plugins against the codebase. |
2424

2525
**❗️** Test Inclusion Logic
2626

docs/e2e.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Root/
102102
// nx.json
103103
{
104104
// ...
105-
"plugins": ["tools/src/npm/npm.plugin.ts", "tools/src/publish/publish.plugin.ts", "tools/src/verdaccio/verdaccio.plugin.ts"]
105+
"plugins": ["tools/src/npm/npm.plugin.ts", "tools/src/publish/publish.plugin.ts", "tools/src/verdaccio/verdaccio.plugin.ts"],
106106
}
107107
```
108108

@@ -115,10 +115,10 @@ Root/
115115
"e2e": {
116116
"executor": "@nx/vite:test",
117117
"options": {
118-
"configFile": "e2e/<project-name>-e2e/vite.config.e2e.ts"
119-
}
120-
}
121-
}
118+
"configFile": "e2e/<project-name>-e2e/vite.config.e2e.ts",
119+
},
120+
},
121+
},
122122
}
123123
```
124124

e2e/cli-e2e/tests/collect.e2e.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('CLI collect', () => {
3232
audits: audits.map(
3333
pluginReport.slug === 'lighthouse' ? omitVariableAuditData : p => p,
3434
) as AuditReport[],
35-
} as PluginReport);
35+
}) as PluginReport;
3636
const omitVariableReportData = ({
3737
commit,
3838
date,

examples/react-todos-app/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"@swc/core": "^1.3.99",
6868
"@testing-library/jest-dom": "^6.4.2",
6969
"@testing-library/react": "^14.0.0",
70-
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
70+
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
7171
"@types/benchmark": "^2.1.5",
7272
"@types/debug": "^4.1.12",
7373
"@types/eslint": "^8.44.2",
@@ -106,7 +106,7 @@
106106
"knip": "^5.9.4",
107107
"memfs": "^4.5.0",
108108
"moment": "^2.29.4",
109-
"prettier": "^2.6.2",
109+
"prettier": "^3.3.3",
110110
"react": "^18.2.0",
111111
"react-dom": "^18.2.0",
112112
"tsconfig-paths": "^4.2.0",

packages/cli/src/lib/implementation/core-config.integration.test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ vi.mock('@code-pushup/core', async () => {
3838
return filepath.includes('all-persist-options')
3939
? allPersistOptions
4040
: filepath.includes('persist-only-filename')
41-
? persistOnlyFilename
42-
: filepath.includes('no-persist')
43-
? noPersist
44-
: filepath.includes('no-category')
45-
? noCategory
46-
: filepath.includes('no-upload')
47-
? noUpload
48-
: CORE_CONFIG_MOCK;
41+
? persistOnlyFilename
42+
: filepath.includes('no-persist')
43+
? noPersist
44+
: filepath.includes('no-category')
45+
? noCategory
46+
: filepath.includes('no-upload')
47+
? noUpload
48+
: CORE_CONFIG_MOCK;
4949
}),
5050
};
5151
});

packages/cli/src/lib/implementation/global.utils.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export function filterKebabCaseKeys<T extends Record<string, unknown>>(
1313
(typeof value === 'object' && Array.isArray(obj[key]))
1414
? { ...acc, [key]: value }
1515
: typeof value === 'object' && !Array.isArray(value) && value != null
16-
? {
17-
...acc,
18-
[key]: filterKebabCaseKeys(value as Record<string, unknown>),
19-
}
20-
: { ...acc, [key]: value },
16+
? {
17+
...acc,
18+
[key]: filterKebabCaseKeys(value as Record<string, unknown>),
19+
}
20+
: { ...acc, [key]: value },
2121
{},
2222
) as T;
2323
}

packages/cli/src/lib/implementation/validate-filter-options.utils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export function validateFilterOption(
1818
const validItems = isCategoryOption(option)
1919
? categories
2020
: isPluginOption(option)
21-
? plugins
22-
: [];
21+
? plugins
22+
: [];
2323
const invalidItems = itemsToFilter.filter(
2424
item => !validItems.some(({ slug }) => slug === item),
2525
);
@@ -94,8 +94,8 @@ export function getItemType(option: FilterOptionType, count: number): string {
9494
const itemType = isCategoryOption(option)
9595
? 'category'
9696
: isPluginOption(option)
97-
? 'plugin'
98-
: 'item';
97+
? 'plugin'
98+
: 'item';
9999
return pluralize(itemType, count);
100100
}
101101

packages/models/src/lib/implementation/utils.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ export function getMissingRefsForCategories(
8989
.filter(({ type }) => type === 'group')
9090
.map(({ plugin, slug }) => `${plugin}#${slug} (group)`),
9191
);
92-
const groupRefsFromPlugins = plugins.flatMap(({ groups, slug: pluginSlug }) =>
93-
Array.isArray(groups)
94-
? groups.map(({ slug }) => `${pluginSlug}#${slug} (group)`)
95-
: [],
92+
const groupRefsFromPlugins = plugins.flatMap(
93+
({ groups, slug: pluginSlug }) =>
94+
Array.isArray(groups)
95+
? groups.map(({ slug }) => `${pluginSlug}#${slug} (group)`)
96+
: [],
9697
);
9798
const missingGroupRefs = hasMissingStrings(
9899
groupRefsFromCategory,

packages/nx-plugin/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Register this plugin in your `nx.json` to leverage a set of generators and execu
1010
// nx.json
1111
{
1212
//...
13-
"plugins": ["@code-pushup/nx-plugin"]
13+
"plugins": ["@code-pushup/nx-plugin"],
1414
}
1515
```
1616

packages/nx-plugin/src/executors/cli/README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Configure a target in your project json.
1515
"name": "my-project",
1616
"targets": {
1717
"code-pushup": {
18-
"executor": "@code-pushup/nx-plugin:cli"
19-
}
20-
}
18+
"executor": "@code-pushup/nx-plugin:cli",
19+
},
20+
},
2121
}
2222
```
2323

@@ -54,11 +54,11 @@ The following things happen:
5454
"options": {
5555
"projectPrefix": "cli", // upload.project = cli-my-project
5656
"verbose": true,
57-
"progress": false
57+
"progress": false,
5858
// persist and upload options as defined in CoreConfig
59-
}
60-
}
61-
}
59+
},
60+
},
61+
},
6262
}
6363
```
6464

packages/nx-plugin/src/plugin/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Why should you use this plugin?
1515
// nx.json
1616
{
1717
//...
18-
"plugins": ["@code-pushup/nx-plugin"]
18+
"plugins": ["@code-pushup/nx-plugin"],
1919
}
2020
```
2121

@@ -29,10 +29,10 @@ or with options:
2929
{
3030
"plugin": "@code-pushup/nx-plugin",
3131
"options": {
32-
"projectPrefix": "cli"
33-
}
34-
}
35-
]
32+
"projectPrefix": "cli",
33+
},
34+
},
35+
],
3636
}
3737
```
3838

packages/plugin-coverage/src/lib/runner/runner.integration.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ describe('createRunnerConfig', () => {
3939

4040
await createRunnerConfig('executeRunner.ts', pluginConfig);
4141

42-
const config = await readJsonFile<FinalCoveragePluginConfig>(
43-
PLUGIN_CONFIG_PATH,
44-
);
42+
const config =
43+
await readJsonFile<FinalCoveragePluginConfig>(PLUGIN_CONFIG_PATH);
4544
expect(config).toStrictEqual(pluginConfig);
4645
});
4746
});

packages/plugin-eslint/mocks/fixtures/todos-app/www/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<body>
44
<div id="root" />

packages/plugin-eslint/src/lib/nx/traverse-graph.unit.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { findAllDependencies } from './traverse-graph';
33

44
describe('findAllDependencies', () => {
55
const mockProjectGraph = (dependencies: ProjectGraph['dependencies']) =>
6-
({ dependencies } as ProjectGraph);
6+
({ dependencies }) as ProjectGraph;
77

88
it('should return empty array when a project has no dependencies', () => {
99
expect(

packages/plugin-eslint/src/lib/runner/index.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ export const PLUGIN_CONFIG_PATH = join(
2121
);
2222

2323
export async function executeRunner(): Promise<void> {
24-
const { slugs, targets } = await readJsonFile<ESLintPluginRunnerConfig>(
25-
PLUGIN_CONFIG_PATH,
26-
);
24+
const { slugs, targets } =
25+
await readJsonFile<ESLintPluginRunnerConfig>(PLUGIN_CONFIG_PATH);
2726

2827
const linterOutputs = await targets.reduce(
2928
async (acc, target) => [...(await acc), await lint(target)],

packages/plugin-eslint/src/lib/runner/lint.unit.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class MockESLint {
1717
'max-lines': ['warn', 500],
1818
'@typescript-eslint/no-explicit-any': 'error',
1919
},
20-
} as Linter.Config),
20+
}) as Linter.Config,
2121
);
2222
}
2323

packages/plugin-js-packages/src/lib/package-managers/derive-package-manager.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ export async function derivePackageManagerInPackageJson(
3232
export async function derivePackageManager(
3333
currentDir = process.cwd(),
3434
): Promise<PackageManagerId> {
35-
const pkgManagerFromPackageJson = await derivePackageManagerInPackageJson(
36-
currentDir,
37-
);
35+
const pkgManagerFromPackageJson =
36+
await derivePackageManagerInPackageJson(currentDir);
3837
if (pkgManagerFromPackageJson) {
3938
return pkgManagerFromPackageJson;
4039
}

packages/plugin-js-packages/src/lib/package-managers/npm/audit-result.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function npmToAuditResult(output: string): AuditResult {
1717
name: name.toString(),
1818
severity: detail.severity,
1919
versionRange: detail.range,
20-
directDependency: detail.isDirect ? true : detail.effects[0] ?? '',
20+
directDependency: detail.isDirect ? true : (detail.effects[0] ?? ''),
2121
fixInformation: npmToFixInformation(detail.fixAvailable),
2222
...(advisory != null && {
2323
title: advisory.title,

packages/plugin-js-packages/src/lib/runner/outdated/transform.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ export function outdatedResultToAuditOutput(
3232
neq(dep.current, dep.latest),
3333
);
3434

35-
const outdatedStats = outdatedDependencies.reduce((acc, dep) => {
36-
const outdatedLevel = diff(dep.current, dep.latest);
37-
if (outdatedLevel == null) {
38-
return acc;
39-
}
40-
return { ...acc, [outdatedLevel]: acc[outdatedLevel] + 1 };
41-
}, objectFromEntries(RELEASE_TYPES.map(versionType => [versionType, 0])));
35+
const outdatedStats = outdatedDependencies.reduce(
36+
(acc, dep) => {
37+
const outdatedLevel = diff(dep.current, dep.latest);
38+
if (outdatedLevel == null) {
39+
return acc;
40+
}
41+
return { ...acc, [outdatedLevel]: acc[outdatedLevel] + 1 };
42+
},
43+
objectFromEntries(RELEASE_TYPES.map(versionType => [versionType, 0])),
44+
);
4245

4346
const issues =
4447
outdatedDependencies.length === 0

packages/plugin-js-packages/src/lib/runner/runner.integration.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ describe('createRunnerConfig', () => {
3232
packageJsonPaths: ['package.json'],
3333
};
3434
await createRunnerConfig('executeRunner.ts', pluginConfig);
35-
const config = await readJsonFile<FinalJSPackagesPluginConfig>(
36-
PLUGIN_CONFIG_PATH,
37-
);
35+
const config =
36+
await readJsonFile<FinalJSPackagesPluginConfig>(PLUGIN_CONFIG_PATH);
3837
expect(config).toStrictEqual(pluginConfig);
3938
});
4039
});

packages/plugin-lighthouse/src/lib/runner/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ function formatBaseAuditOutput(lhrAudit: Result): AuditOutput {
5050
? 'passed'
5151
: 'failed'
5252
: score
53-
? `${formatReportScore(score)}%`
54-
: undefined),
53+
? `${formatReportScore(score)}%`
54+
: undefined),
5555
};
5656
}
5757

packages/plugin-lighthouse/src/lib/runner/utils.unit.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ describe('toAuditOutputs', () => {
239239
score: 0,
240240
numericValue: 0,
241241
displayValue: '0 ms',
242-
} as Result),
242+
}) as Result,
243243
),
244244
);
245245
expect(getLogMessages(ui().logger)).toHaveLength(0);
@@ -256,7 +256,7 @@ describe('toAuditOutputs', () => {
256256
score: 0,
257257
numericValue: 0,
258258
displayValue: '0 ms',
259-
} as Result),
259+
}) as Result,
260260
),
261261
{ verbose: true },
262262
);

0 commit comments

Comments
 (0)