Skip to content

Commit 73232cd

Browse files
committed
add groups
1 parent ba00774 commit 73232cd

File tree

18 files changed

+325
-7985
lines changed

18 files changed

+325
-7985
lines changed

code-pushup.preset.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,19 @@ import {
1717
type TypescriptPluginOptions,
1818
typescriptPlugin,
1919
} from './packages/plugin-typescript/src/index.js';
20-
import { AUDITS } from './packages/plugin-typescript/src/lib/audits.generated.js';
21-
import { BASIC_AUDITS } from './packages/plugin-typescript/src/lib/constants.js';
22-
import { filterAuditsBySlug } from './packages/plugin-typescript/src/lib/utils.js';
20+
import {
21+
BUILD_EMIT_OPTIONS,
22+
CONTROL_FLOW_OPTIONS,
23+
INTEROP_CONSTRAINTS,
24+
LANGUAGE_ENVIRONMENT_OPTIONS,
25+
MODULE_RESOLUTION,
26+
PROJECT_REFERENCES,
27+
STRICT_CHECKS,
28+
TYPE_CHECKING_BEHAVIOR,
29+
WATCH_OPTIONS
30+
} from './packages/plugin-typescript/src/lib/runner/known-ts-error-codes.js';
31+
import {filterAuditsBySlug, filterGroupsByAuditSlug} from './packages/plugin-typescript/src/lib/utils.js';
32+
import {GROUPS} from "./packages/plugin-typescript/src/lib/constants";
2333

2434
export const jsPackagesCategories: CategoryConfig[] = [
2535
{
@@ -78,14 +88,14 @@ export const eslintCategories: CategoryConfig[] = [
7888
slug: 'bug-prevention',
7989
title: 'Bug prevention',
8090
description: 'Lint rules that find **potential bugs** in your code.',
81-
refs: [{ type: 'group', plugin: 'eslint', slug: 'problems', weight: 1 }],
91+
refs: [{type: 'group', plugin: 'eslint', slug: 'problems', weight: 1}],
8292
},
8393
{
8494
slug: 'code-style',
8595
title: 'Code style',
8696
description:
8797
'Lint rules that promote **good practices** and consistency in your code.',
88-
refs: [{ type: 'group', plugin: 'eslint', slug: 'suggestions', weight: 1 }],
98+
refs: [{type: 'group', plugin: 'eslint', slug: 'suggestions', weight: 1}],
8999
},
90100
];
91101

@@ -140,7 +150,6 @@ export const typescriptPluginConfigNx = async (
140150
options: TypescriptPluginOptions,
141151
): Promise<CoreConfig> => {
142152
const opt: TypescriptPluginOptions = {
143-
onlyAudits: BASIC_AUDITS,
144153
...options,
145154
};
146155

@@ -150,10 +159,10 @@ export const typescriptPluginConfigNx = async (
150159
{
151160
slug: 'typescript',
152161
title: 'Typescript',
153-
refs: AUDITS.filter(filterAuditsBySlug(opt.onlyAudits)).map(
154-
({ slug }) => ({
162+
refs: GROUPS.filter(filterGroupsByAuditSlug(opt.onlyAudits)).map(
163+
({slug}) => ({
155164
plugin: 'typescript',
156-
type: 'audit' as const,
165+
type: 'group' as const,
157166
slug,
158167
weight: 1,
159168
}),

packages/plugin-typescript/README.md

Lines changed: 7 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
[![downloads](https://img.shields.io/npm/dm/%40code-pushup%2Ftypescript-plugin)](https://npmtrends.com/@code-pushup/typescript-plugin)
55
[![dependencies](https://img.shields.io/librariesio/release/npm/%40code-pushup/typescript-plugin)](https://www.npmjs.com/package/@code-pushup/typescript-plugin?activeTab=dependencies)
66

7-
🕵️ **Code PushUp plugin for measuring web performance and quality with Lighthouse.** 🔥
7+
🕵️ **Code PushUp plugin for measuring TypeScript quality with compiler diagnostics.** 🔥
88

99
---
1010

11-
The plugin parses your Lighthouse configuration and lints all audits of the official [Lighthouse](https://github.com/GoogleChrome/typescript/blob/main/readme.md#typescript-------) CLI.
12-
13-
Detected Lighthouse audits are mapped to Code PushUp audits. Audit reports are calculated based on the [original implementation](https://googlechrome.github.io/typescript/scorecalc/).
14-
Additionally, Lighthouse categories are mapped to Code PushUp groups which can make it easier to assemble the categories.
11+
The plugin parses your TypeScript and JavaScript code and lints all audits of the official [TypeScript Compiler]().
1512

1613
For more infos visit the [official docs](https://developer.chrome.com/docs/typescript/overview).
1714

@@ -44,7 +41,9 @@ For more infos visit the [official docs](https://developer.chrome.com/docs/types
4441
// ...
4542
plugins: [
4643
// ...
47-
await typescriptPlugin('https://example.com'),
44+
await typescriptPlugin({
45+
tsConfigPath: './tsconfig.json'
46+
}),
4847
],
4948
};
5049
```
@@ -66,39 +65,14 @@ import { typescriptGroupRef } from './utils';
6665
export default {
6766
// ...
6867
categories: [
69-
{
70-
slug: 'performance',
71-
title: 'Performance',
72-
refs: [typescriptGroupRef('performance')],
73-
},
74-
{
75-
slug: 'a11y',
76-
title: 'Accessibility',
77-
refs: [typescriptGroupRef('accessibility')],
78-
},
79-
{
80-
slug: 'best-practices',
81-
title: 'Best Practices',
82-
refs: [typescriptGroupRef('best-practices')],
83-
},
84-
{
85-
slug: 'seo',
86-
title: 'SEO',
87-
refs: [typescriptGroupRef('seo')],
88-
},
89-
{
90-
slug: 'pwa',
91-
title: 'PWA',
92-
isBinary: true,
93-
refs: [typescriptGroupRef('pwa')],
94-
},
68+
9569
],
9670
};
9771
```
9872

9973
#### Reference groups with `typescriptAuditRef`
10074

101-
The Lighthouse categories are reflected as groups.
75+
The TypeScript categories are reflected as groups.
10276
Referencing individual audits offers more granularity. However, keep maintenance costs of a higher number of audits in mind as well.
10377

10478
```ts
@@ -116,124 +90,3 @@ export default {
11690
],
11791
};
11892
```
119-
120-
## Flags
121-
122-
The plugin accepts an optional second argument, `flags`.
123-
124-
`flags` is a JavaScript object containing Lighthouse [CLI flags](https://github.com/GoogleChrome/typescript/blob/7d80178c37a1b600ea8f092fc0b098029799a659/cli/cli-flags.js#L80).
125-
126-
Within the `flags` object, external configuration files can be referenced using options like `configPath` , `preset`, or `budgetPath`. These options allow Lighthouse to load custom configurations, audit presets, or performance budgets from external `json` or JavaScript files.
127-
128-
For a complete list of available options, refer to [the official Lighthouse documentation](https://github.com/GoogleChrome/typescript/blob/main/readme.md#cli-options).
129-
130-
> [!TIP]
131-
> If you are new to working with the Lighthouse CLI, flags can be passed like this:
132-
> `typescript https://example.com --output=json --chromeFlags='--headless=shell'`
133-
>
134-
> With the plugin, the configuration would be:
135-
>
136-
> ```ts
137-
> // code-pushup.config.ts
138-
> ...
139-
> typescriptPlugin('https://example.com', {
140-
> output: 'json',
141-
> chromeFlags: ['--headless=shell'],
142-
> });
143-
> ```
144-
145-
> [!note]
146-
> The following flags are **not supported** in the current implementation:
147-
>
148-
> - `list-all-audits` - Prints a list of all available audits and exits. Alternative: `npx code-pushup print-config --onlyPlugins typescript`
149-
> - `list-locales` - Prints a list of all supported locales and exits.
150-
> - `list-trace-categories` - Prints a list of all required trace categories and exits.
151-
> - `view` - Open HTML report in your browser
152-
153-
## Chrome Flags for Tooling
154-
155-
We recommend using Chrome flags for more stable runs in a tooling environment. The [`chrome-launcher`](https://www.npmjs.com/package/chrome-launcher) package offers a well-documented set of flags specifically designed to ensure reliable execution.
156-
157-
The latest version of `@code-pushup/typescript-plugin` provides `DEFAULT_CHROME_FLAGS`, a pre-configured constant that includes Chrome’s default flags for stable, headless execution out of the box. This means you do not need to specify `chromeFlags` manually unless you want to modify them.
158-
159-
### Default Usage
160-
161-
If no `chromeFlags` are provided, the plugin automatically applies the default configuration:
162-
163-
> ```ts
164-
> import typescriptPlugin from '@code-pushup/typescript-plugin';
165-
>
166-
> typescriptPlugin('https://example.com', {
167-
> output: 'json',
168-
> // Defaults to DEFAULT_CHROME_FLAGS internally
169-
> });
170-
> ```
171-
172-
### Adding Extra Flags
173-
174-
If additional Chrome flags are required (e.g., verbose logging or debugging), they can be appended to the default flags:
175-
176-
> ```ts
177-
> import typescriptPlugin, { DEFAULT_CHROME_FLAGS } from '@code-pushup/typescript-plugin';
178-
>
179-
> typescriptPlugin('https://example.com', {
180-
> output: 'json',
181-
> chromeFlags: DEFAULT_CHROME_FLAGS.concat(['--verbose']),
182-
> });
183-
> ```
184-
185-
### Overriding Default Flags
186-
187-
To completely override the default flags and provide a custom configuration:
188-
189-
> ```ts
190-
> import typescriptPlugin from '@code-pushup/typescript-plugin';
191-
>
192-
> typescriptPlugin('https://example.com', {
193-
> output: 'json',
194-
> chromeFlags: ['--verbose'],
195-
> });
196-
> ```
197-
198-
## Config
199-
200-
The plugin accepts a third optional argument, `config`.
201-
202-
`config` is the Lighthouse [configuration](https://github.com/GoogleChrome/typescript/blob/7d80178c37a1b600ea8f092fc0b098029799a659/types/config.d.ts#L21) as a JS object.
203-
204-
For a complete guide on Lighthouse configuration read the [official documentation on configuring](https://github.com/GoogleChrome/typescript/blob/main/docs/configuration.md)
205-
206-
> [!TIP]
207-
> If you are not used to work with the Lighthouse CLI you would pass a config like this:
208-
> `typescript --config-path=path/to/custom-config.js https://example.com`
209-
>
210-
> And in a separate file you would place the following object:
211-
>
212-
> ```typescript
213-
> // custom-config.js file
214-
> export default {
215-
> extends: 'typescript:default',
216-
> settings: {
217-
> onlyAudits: ['first-meaningful-paint', 'speed-index', 'interactive'],
218-
> },
219-
> };
220-
> ```
221-
>
222-
> Now with the plugin it would look like this:
223-
>
224-
> ```ts
225-
> // code-pushup.config.ts
226-
> ...
227-
> typescriptPlugin('https://example.com', undefined, {
228-
> extends: 'typescript:default',
229-
> settings: {
230-
> onlyAudits: [
231-
> 'first-meaningful-paint',
232-
> 'speed-index',
233-
> 'interactive',
234-
> ],
235-
> }
236-
> })
237-
> ```
238-
239-
If you want to contribute, please refer to [CONTRIBUTING.md](./CONTRIBUTING.md).

packages/plugin-typescript/project.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
"options": {
3636
"configFile": "packages/plugin-typescript/vite.config.integration.ts"
3737
}
38-
},
39-
"generate-audits": {
40-
"command": "tsx --tsconfig=packages/plugin-typescript/tsconfig.tools.json packages/plugin-typescript/tools/generate-audits/bin.ts"
4138
}
4239
},
4340
"tags": ["scope:plugin", "type:feature", "publishable"]

0 commit comments

Comments
 (0)