Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions code-pushup.preset.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/* eslint-disable @nx/enforce-module-boundaries */
import { createProjectGraphAsync } from '@nx/devkit';
import type {
CategoryConfig,
CoreConfig,
PluginUrls,
} from './packages/models/src/index.js';
import axePlugin, { axeCategories } from './packages/plugin-axe/src/index.js';
import type { CoreConfig, PluginUrls } from './packages/models/src/index.js';
import axePlugin, { axeGroupRefs } from './packages/plugin-axe/src/index.js';
import coveragePlugin, {
type CoveragePluginConfig,
getNxCoveragePaths,
Expand All @@ -16,8 +12,7 @@ import eslintPlugin, {
import jsPackagesPlugin from './packages/plugin-js-packages/src/index.js';
import jsDocsPlugin from './packages/plugin-jsdocs/src/index.js';
import {
lighthouseCategories,
lighthouseGroupRef,
lighthouseGroupRefs,
lighthousePlugin,
} from './packages/plugin-lighthouse/src/index.js';
import typescriptPlugin, {
Expand Down Expand Up @@ -195,38 +190,43 @@ export async function configureLighthousePlugin(
urls: PluginUrls,
): Promise<CoreConfig> {
const lhPlugin = await lighthousePlugin(urls);
const lhCategories: CategoryConfig[] = [
{
slug: 'performance',
title: 'Performance',
refs: [lighthouseGroupRef('performance')],
},
{
slug: 'a11y',
title: 'Accessibility',
refs: [lighthouseGroupRef('accessibility')],
},
{
slug: 'best-practices',
title: 'Best Practices',
refs: [lighthouseGroupRef('best-practices')],
},
{
slug: 'seo',
title: 'SEO',
refs: [lighthouseGroupRef('seo')],
},
];
return {
plugins: [lhPlugin],
categories: lighthouseCategories(lhPlugin, lhCategories),
categories: [
{
slug: 'performance',
title: 'Performance',
refs: lighthouseGroupRefs(lhPlugin, 'performance'),
},
{
slug: 'a11y',
title: 'Accessibility',
refs: lighthouseGroupRefs(lhPlugin, 'accessibility'),
},
{
slug: 'best-practices',
title: 'Best Practices',
refs: lighthouseGroupRefs(lhPlugin, 'best-practices'),
},
{
slug: 'seo',
title: 'SEO',
refs: lighthouseGroupRefs(lhPlugin, 'seo'),
},
],
};
}

export function configureAxePlugin(urls: PluginUrls): CoreConfig {
const axe = axePlugin(urls);
return {
plugins: [axe],
categories: axeCategories(axe),
categories: [
{
slug: 'axe-a11y',
title: 'Axe Accessibility',
refs: axeGroupRefs(axe),
},
],
};
}
70 changes: 40 additions & 30 deletions packages/models/docs/models-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ _All properties are optional._

_Object containing the following properties:_

| Property | Description | Type |
| :----------------------- | :----------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`slug`** (\*) | Unique ID (human-readable, URL-safe) | [Slug](#slug) |
| **`title`** (\*) | Descriptive name | `string` (_max length: 256_) |
| `docsUrl` | Documentation site | `string` (_url_) (_optional_) _or_ `''` |
| **`scores`** (\*) | Score comparison | _Object with properties:_<ul><li>**`before`** (\*): [Score](#score) - Value between 0 and 1 (source commit)</li><li>**`after`** (\*): [Score](#score) - Value between 0 and 1 (target commit)</li><li>**`diff`** (\*): `number` (_≥-1, ≤1_) - Score change (`scores.after - scores.before`)</li></ul> |
| **`plugin`** (\*) | Plugin which defines it | _Object with properties:_<ul><li>**`slug`** (\*): [Slug](#slug) - Unique plugin slug within core config</li><li>**`title`** (\*): `string` (_max length: 256_) - Descriptive name</li><li>`docsUrl`: `string` (_url_) (_optional_) _or_ `''` - Plugin documentation site</li></ul> |
| **`values`** (\*) | Audit `value` comparison | _Object with properties:_<ul><li>**`before`** (\*): `number` (_≥0_) - Raw numeric value (source commit)</li><li>**`after`** (\*): `number` (_≥0_) - Raw numeric value (target commit)</li><li>**`diff`** (\*): `number` - Value change (`values.after - values.before`)</li></ul> |
| **`displayValues`** (\*) | Audit `displayValue` comparison | _Object with properties:_<ul><li>`before`: `string` - Formatted value (e.g. '0.9 s', '2.1 MB') (source commit)</li><li>`after`: `string` - Formatted value (e.g. '0.9 s', '2.1 MB') (target commit)</li></ul> |
| Property | Description | Type |
| :----------------------- | :----------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`slug`** (\*) | Unique ID (human-readable, URL-safe) | [Slug](#slug) |
| **`title`** (\*) | Descriptive name | `string` (_max length: 256_) |
| `docsUrl` | Documentation site | `string` (_url_) (_optional_) _or_ `''` |
| **`scores`** (\*) | Score comparison | _Object with properties:_<ul><li>**`before`** (\*): [Score](#score) - Value between 0 and 1 (source commit)</li><li>**`after`** (\*): [Score](#score) - Value between 0 and 1 (target commit)</li><li>**`diff`** (\*): `number` (_≥-1, ≤1_) - Score change (`scores.after - scores.before`)</li></ul> |
| **`plugin`** (\*) | Plugin which defines it | _Object with properties:_<ul><li>**`slug`** (\*): [Slug](#slug) - Unique plugin slug within core config</li><li>**`title`** (\*): `string` (_max length: 256_) - Descriptive name</li><li>`docsUrl`: `string` (_url_) (_optional_) _or_ `''` - Plugin documentation site</li></ul> |
| **`values`** (\*) | Audit `value` comparison | _Object with properties:_<ul><li>**`before`** (\*): [NonnegativeNumber](#nonnegativenumber) - Raw numeric value (source commit)</li><li>**`after`** (\*): [NonnegativeNumber](#nonnegativenumber) - Raw numeric value (target commit)</li><li>**`diff`** (\*): `number` - Value change (`values.after - values.before`)</li></ul> |
| **`displayValues`** (\*) | Audit `displayValue` comparison | _Object with properties:_<ul><li>`before`: `string` - Formatted value (e.g. '0.9 s', '2.1 MB') (source commit)</li><li>`after`: `string` - Formatted value (e.g. '0.9 s', '2.1 MB') (target commit)</li></ul> |

_(\*) Required._

Expand All @@ -43,14 +43,14 @@ Audit information

_Object containing the following properties:_

| Property | Description | Type |
| :--------------- | :--------------------------------------- | :---------------------------- |
| **`slug`** (\*) | Reference to audit | [Slug](#slug) |
| `displayValue` | Formatted value (e.g. '0.9 s', '2.1 MB') | `string` |
| **`value`** (\*) | Raw numeric value | `number` (_≥0_) |
| **`score`** (\*) | Value between 0 and 1 | [Score](#score) |
| `scoreTarget` | Pass/fail score threshold (0-1) | `number` (_≥0, ≤1_) |
| `details` | Detailed information | [AuditDetails](#auditdetails) |
| Property | Description | Type |
| :--------------- | :--------------------------------------- | :-------------------------------------- |
| **`slug`** (\*) | Reference to audit | [Slug](#slug) |
| `displayValue` | Formatted value (e.g. '0.9 s', '2.1 MB') | `string` |
| **`value`** (\*) | Raw numeric value | [NonnegativeNumber](#nonnegativenumber) |
| **`score`** (\*) | Value between 0 and 1 | [Score](#score) |
| `scoreTarget` | Pass/fail score threshold (0-1) | `number` (_≥0, ≤1_) |
| `details` | Detailed information | [AuditDetails](#auditdetails) |

_(\*) Required._

Expand All @@ -72,7 +72,7 @@ _Object containing the following properties:_
| `docsUrl` | Link to documentation (rationale) | `string` (_url_) (_optional_) _or_ `''` |
| `isSkipped` | Indicates whether the audit is skipped | `boolean` |
| `displayValue` | Formatted value (e.g. '0.9 s', '2.1 MB') | `string` |
| **`value`** (\*) | Raw numeric value | `number` (_≥0_) |
| **`value`** (\*) | Raw numeric value | [NonnegativeNumber](#nonnegativenumber) |
| **`score`** (\*) | Value between 0 and 1 | [Score](#score) |
| `scoreTarget` | Pass/fail score threshold (0-1) | `number` (_≥0, ≤1_) |
| `details` | Detailed information | [AuditDetails](#auditdetails) |
Expand All @@ -90,7 +90,7 @@ _Object containing the following properties:_
| `docsUrl` | Documentation site | `string` (_url_) (_optional_) _or_ `''` |
| **`plugin`** (\*) | Plugin which defines it | _Object with properties:_<ul><li>**`slug`** (\*): [Slug](#slug) - Unique plugin slug within core config</li><li>**`title`** (\*): `string` (_max length: 256_) - Descriptive name</li><li>`docsUrl`: `string` (_url_) (_optional_) _or_ `''` - Plugin documentation site</li></ul> |
| **`score`** (\*) | Value between 0 and 1 | [Score](#score) |
| **`value`** (\*) | Raw numeric value | `number` (_≥0_) |
| **`value`** (\*) | Raw numeric value | [NonnegativeNumber](#nonnegativenumber) |
| `displayValue` | Formatted value (e.g. '0.9 s', '2.1 MB') | `string` |

_(\*) Required._
Expand Down Expand Up @@ -198,12 +198,12 @@ _(\*) Required._

_Object containing the following properties:_

| Property | Description | Type |
| :---------------- | :----------------------------------------------------------------- | :------------------- |
| **`slug`** (\*) | Slug of an audit or group (depending on `type`) | [Slug](#slug) |
| **`weight`** (\*) | Weight used to calculate score | `number` (_≥0_) |
| **`type`** (\*) | Discriminant for reference kind, affects where `slug` is looked up | `'audit' \| 'group'` |
| **`plugin`** (\*) | Plugin slug (plugin should contain referenced audit or group) | [Slug](#slug) |
| Property | Description | Type |
| :---------------- | :----------------------------------------------------------------- | :-------------------------------------- |
| **`slug`** (\*) | Slug of an audit or group (depending on `type`) | [Slug](#slug) |
| **`weight`** (\*) | Weight used to calculate score | [NonnegativeNumber](#nonnegativenumber) |
| **`type`** (\*) | Discriminant for reference kind, affects where `slug` is looked up | `'audit' \| 'group'` |
| **`plugin`** (\*) | Plugin slug (plugin should contain referenced audit or group) | [Slug](#slug) |

_(\*) Required._

Expand Down Expand Up @@ -332,10 +332,10 @@ Weighted reference to a group

_Object containing the following properties:_

| Property | Description | Type |
| :---------------- | :-------------------------------------------------------------- | :-------------- |
| **`slug`** (\*) | Reference slug to a group within this plugin (e.g. 'max-lines') | [Slug](#slug) |
| **`weight`** (\*) | Weight used to calculate score | `number` (_≥0_) |
| Property | Description | Type |
| :---------------- | :-------------------------------------------------------------- | :-------------------------------------- |
| **`slug`** (\*) | Reference slug to a group within this plugin (e.g. 'max-lines') | [Slug](#slug) |
| **`weight`** (\*) | Weight used to calculate score | [NonnegativeNumber](#nonnegativenumber) |

_(\*) Required._

Expand Down Expand Up @@ -1262,6 +1262,10 @@ _Enum, one of the following possible values:_

</details>

## NonnegativeNumber

_Number which is greater than or equal to 0._

## PersistConfig

_Object containing the following properties:_
Expand Down Expand Up @@ -1374,7 +1378,7 @@ _Union of the following possible types:_

- `string` (_url_)
- `Array<string (_url_)>`
- _Object with dynamic keys of type_ `string` (_url_) _and values of type_ `number` (_≥0_)
- _Object with dynamic keys of type_ `string` (_url_) _and values of type_ [NonnegativeNumber](#nonnegativenumber)

## PositiveInt

Expand Down Expand Up @@ -1574,3 +1578,9 @@ _Object containing the following properties:_
| `timeout` | Request timeout in minutes (default is 5) | `number` (_>0, int_) |

_(\*) Required._

## Weight

Coefficient for the given score (use weight 0 if only for display)

_Number which is greater than or equal to 0._
2 changes: 2 additions & 0 deletions packages/models/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ export {
filePathSchema,
globPathSchema,
materialIconSchema,
nonnegativeNumberSchema,
positiveIntSchema,
scoreSchema,
slugSchema,
weightSchema,
type MaterialIcon,
} from './lib/implementation/schemas.js';
export { exists } from './lib/implementation/utils.js';
Expand Down
Loading