@code-pushup/axe-plugin 0.105.0 → 0.106.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -163,51 +163,105 @@ Use `npx code-pushup print-config --onlyPlugins=axe` to list all audits and grou
163
163
 
164
164
  The plugin provides helpers to integrate Axe results into your categories.
165
165
 
166
- ### Auto-generate accessibility category
166
+ ### Building categories with ref helpers
167
167
 
168
- Use `axeCategories` to automatically create an accessibility category from all plugin groups:
168
+ Use `axeGroupRefs` and `axeAuditRefs` to build categories. These helpers automatically handle multi-URL expansion:
169
169
 
170
170
  ```ts
171
- import axePlugin, { axeCategories } from '@code-pushup/axe-plugin';
171
+ import axePlugin, { axeGroupRefs } from '@code-pushup/axe-plugin';
172
172
 
173
173
  const axe = axePlugin('https://example.com');
174
174
 
175
175
  export default {
176
176
  plugins: [axe],
177
- categories: axeCategories(axe),
177
+ categories: [
178
+ {
179
+ slug: 'a11y',
180
+ title: 'Accessibility',
181
+ refs: axeGroupRefs(axe),
182
+ },
183
+ ],
178
184
  };
179
185
  ```
180
186
 
181
- This configuration works with both single-URL and multi-URL configurations. For multi-URL setups, refs are automatically expanded for each URL with appropriate weights.
187
+ For multi-URL setups, refs are automatically expanded for each URL with appropriate weights:
182
188
 
183
- ### Custom categories
189
+ ```ts
190
+ import axePlugin, { axeGroupRefs } from '@code-pushup/axe-plugin';
184
191
 
185
- For fine-grained control, provide your own categories with specific groups:
192
+ const axe = axePlugin({
193
+ 'https://example.com': 2,
194
+ 'https://example.com/about': 1,
195
+ });
196
+
197
+ export default {
198
+ plugins: [axe],
199
+ categories: [
200
+ {
201
+ slug: 'a11y',
202
+ title: 'Accessibility',
203
+ refs: axeGroupRefs(axe),
204
+ },
205
+ ],
206
+ };
207
+ ```
208
+
209
+ ### Custom categories with specific groups
210
+
211
+ For fine-grained control, specify which groups to include:
186
212
 
187
213
  ```ts
188
- import axePlugin, { axeCategories, axeGroupRef } from '@code-pushup/axe-plugin';
214
+ import axePlugin, { axeGroupRefs } from '@code-pushup/axe-plugin';
189
215
 
190
- const axe = axePlugin(['https://example.com', 'https://example.com/about']);
216
+ const axe = axePlugin('https://example.com');
191
217
 
192
218
  export default {
193
219
  plugins: [axe],
194
- categories: axeCategories(axe, [
220
+ categories: [
221
+ {
222
+ slug: 'a11y',
223
+ title: 'Accessibility',
224
+ refs: [...axeGroupRefs(axe, 'aria', 2), ...axeGroupRefs(axe, 'color'), ...axeGroupRefs(axe, 'keyboard')],
225
+ },
226
+ ],
227
+ };
228
+ ```
229
+
230
+ ### Combining with Lighthouse
231
+
232
+ For comprehensive accessibility testing, combine Axe with Lighthouse's accessibility group in a single category:
233
+
234
+ ```ts
235
+ import axePlugin, { axeGroupRefs } from '@code-pushup/axe-plugin';
236
+ import lighthousePlugin, { lighthouseGroupRefs } from '@code-pushup/lighthouse-plugin';
237
+
238
+ const urls = ['https://example.com', 'https://example.com/about'];
239
+ const axe = axePlugin(urls);
240
+ const lighthouse = await lighthousePlugin(urls);
241
+
242
+ export default {
243
+ plugins: [axe, lighthouse],
244
+ categories: [
195
245
  {
196
- slug: 'axe-a11y',
197
- title: 'Axe Accessibility',
198
- refs: [axeGroupRef('aria', 2), axeGroupRef('color'), axeGroupRef('keyboard')],
246
+ slug: 'a11y',
247
+ title: 'Accessibility',
248
+ refs: [...lighthouseGroupRefs(lighthouse, 'accessibility'), ...axeGroupRefs(axe)],
199
249
  },
200
- ]),
250
+ ],
201
251
  };
202
252
  ```
203
253
 
254
+ This gives you both Lighthouse's performance-focused accessibility audits and Axe's comprehensive WCAG coverage in one category score.
255
+
204
256
  ### Helper functions
205
257
 
206
- | Function | Description |
207
- | --------------- | -------------------------------------- |
208
- | `axeCategories` | Auto-generates or expands categories |
209
- | `axeGroupRef` | Creates a category ref to an Axe group |
210
- | `axeAuditRef` | Creates a category ref to an Axe audit |
258
+ | Function | Description |
259
+ | -------------- | -------------------------------------------------------- |
260
+ | `axeGroupRefs` | Creates category refs to Axe group(s), handles multi-URL |
261
+ | `axeAuditRefs` | Creates category refs to Axe audit(s), handles multi-URL |
262
+
263
+ > [!TIP]
264
+ > Weights determine each ref's influence on the category score. Use weight `0` to include a ref as info only, without affecting the score.
211
265
 
212
266
  ### Type safety
213
267
 
@@ -219,6 +273,16 @@ import type { AxeGroupSlug } from '@code-pushup/axe-plugin';
219
273
  const group: AxeGroupSlug = 'aria';
220
274
  ```
221
275
 
276
+ ### Deprecated helpers
277
+
278
+ The following helpers are deprecated and will be removed in a future version:
279
+
280
+ | Function | Replacement |
281
+ | --------------- | ------------------------------------------------- |
282
+ | `axeCategories` | Build categories manually with `axeGroupRefs` |
283
+ | `axeGroupRef` | Use `axeGroupRefs` (plural) for multi-URL support |
284
+ | `axeAuditRef` | Use `axeAuditRefs` (plural) for multi-URL support |
285
+
222
286
  ## Resources
223
287
 
224
288
  - **[Axe-core rules](https://github.com/dequelabs/axe-core/blob/develop/doc/rule-descriptions.md)** - Complete list of accessibility rules
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/axe-plugin",
3
- "version": "0.105.0",
3
+ "version": "0.106.0",
4
4
  "license": "MIT",
5
5
  "description": "Code PushUp plugin for detecting accessibility issues using Axe 🌐",
6
6
  "homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-axe#readme",
@@ -42,8 +42,8 @@
42
42
  "type": "module",
43
43
  "dependencies": {
44
44
  "@axe-core/playwright": "^4.11.0",
45
- "@code-pushup/models": "0.105.0",
46
- "@code-pushup/utils": "0.105.0",
45
+ "@code-pushup/models": "0.106.0",
46
+ "@code-pushup/utils": "0.106.0",
47
47
  "axe-core": "^4.11.0",
48
48
  "playwright-core": "^1.56.1",
49
49
  "zod": "^4.1.12"
package/src/index.d.ts CHANGED
@@ -2,5 +2,5 @@ import { axePlugin } from './lib/axe-plugin.js';
2
2
  export default axePlugin;
3
3
  export type { AxePluginOptions, AxePreset } from './lib/config.js';
4
4
  export type { AxeGroupSlug } from './lib/groups.js';
5
- export { axeAuditRef, axeGroupRef } from './lib/utils.js';
5
+ export { axeAuditRef, axeAuditRefs, axeGroupRef, axeGroupRefs, } from './lib/utils.js';
6
6
  export { axeCategories } from './lib/categories.js';
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { axePlugin } from './lib/axe-plugin.js';
2
2
  export default axePlugin;
3
- export { axeAuditRef, axeGroupRef } from './lib/utils.js';
3
+ export { axeAuditRef, axeAuditRefs, axeGroupRef, axeGroupRefs, } from './lib/utils.js';
4
4
  export { axeCategories } from './lib/categories.js';
5
5
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,eAAe,SAAS,CAAC;AAKzB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,eAAe,SAAS,CAAC;AAKzB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,22 +1,20 @@
1
- import type { CategoryConfig, Group, PluginConfig } from '@code-pushup/models';
1
+ import { type CategoryConfig, type PluginConfig } from '@code-pushup/models';
2
2
  import { type PluginUrlContext } from '@code-pushup/utils';
3
- import { type AxeCategoryGroupSlug } from './groups.js';
4
3
  /**
5
- * Creates categories for the Axe plugin.
6
- *
7
- * @public
8
- * @param plugin - {@link PluginConfig} object with groups and context
9
- * @param categories - {@link CategoryConfig} optional user-defined categories
10
- * @returns {CategoryConfig[]} - expanded and aggregated categories
4
+ * @deprecated Use `axeGroupRefs` to build categories manually instead.
11
5
  *
12
6
  * @example
13
- * const axe = await axePlugin(urls);
14
- * const axeCoreConfig = {
15
- * plugins: [axe],
16
- * categories: axeCategories(axe),
17
- * };
7
+ * // Instead of:
8
+ * const categories = axeCategories(axePlugin);
9
+ *
10
+ * // Use:
11
+ * const categories = [
12
+ * {
13
+ * slug: 'a11y',
14
+ * title: 'Accessibility',
15
+ * refs: axeGroupRefs(axePlugin),
16
+ * },
17
+ * ];
18
18
  */
19
19
  export declare function axeCategories(plugin: Pick<PluginConfig, 'groups' | 'context'>, categories?: CategoryConfig[]): CategoryConfig[];
20
- export declare function createAggregatedCategory(groups: Group[], context: PluginUrlContext): CategoryConfig;
21
20
  export declare function expandAggregatedCategory(category: CategoryConfig, context: PluginUrlContext): CategoryConfig;
22
- export declare function extractGroupSlugs(groups: Group[]): AxeCategoryGroupSlug[];
@@ -1,56 +1,52 @@
1
- import { createCategoryRefs, expandCategoryRefs, removeIndex, shouldExpandForUrls, validateUrlContext, } from '@code-pushup/utils';
1
+ import { validate, } from '@code-pushup/models';
2
+ import { expandCategoryRefs, pluginUrlContextSchema, shouldExpandForUrls, } from '@code-pushup/utils';
2
3
  import { AXE_PLUGIN_SLUG } from './constants.js';
3
- import { isAxeGroupSlug } from './groups.js';
4
+ import { axeGroupRefs } from './utils.js';
4
5
  /**
5
- * Creates categories for the Axe plugin.
6
- *
7
- * @public
8
- * @param plugin - {@link PluginConfig} object with groups and context
9
- * @param categories - {@link CategoryConfig} optional user-defined categories
10
- * @returns {CategoryConfig[]} - expanded and aggregated categories
6
+ * @deprecated Use `axeGroupRefs` to build categories manually instead.
11
7
  *
12
8
  * @example
13
- * const axe = await axePlugin(urls);
14
- * const axeCoreConfig = {
15
- * plugins: [axe],
16
- * categories: axeCategories(axe),
17
- * };
9
+ * // Instead of:
10
+ * const categories = axeCategories(axePlugin);
11
+ *
12
+ * // Use:
13
+ * const categories = [
14
+ * {
15
+ * slug: 'a11y',
16
+ * title: 'Accessibility',
17
+ * refs: axeGroupRefs(axePlugin),
18
+ * },
19
+ * ];
18
20
  */
19
21
  export function axeCategories(plugin, categories) {
20
22
  if (!plugin.groups || plugin.groups.length === 0) {
21
23
  return categories ?? [];
22
24
  }
23
- validateUrlContext(plugin.context);
24
25
  if (!categories) {
25
- return createCategories(plugin.groups, plugin.context);
26
+ return createCategories(plugin);
26
27
  }
27
- return expandCategories(categories, plugin.context);
28
+ return expandCategories(plugin, categories);
28
29
  }
29
- function createCategories(groups, context) {
30
- return [createAggregatedCategory(groups, context)];
30
+ function createCategories(plugin) {
31
+ return [
32
+ {
33
+ slug: 'axe-a11y',
34
+ title: 'Axe Accessibility',
35
+ refs: axeGroupRefs(plugin),
36
+ },
37
+ ];
31
38
  }
32
- function expandCategories(categories, context) {
39
+ function expandCategories(plugin, categories) {
40
+ const context = validate(pluginUrlContextSchema, plugin.context);
33
41
  if (!shouldExpandForUrls(context.urlCount)) {
34
42
  return categories;
35
43
  }
36
44
  return categories.map(category => expandAggregatedCategory(category, context));
37
45
  }
38
- export function createAggregatedCategory(groups, context) {
39
- const refs = extractGroupSlugs(groups).flatMap(slug => createCategoryRefs(slug, AXE_PLUGIN_SLUG, context));
40
- return {
41
- slug: 'axe-a11y',
42
- title: 'Axe Accessibility',
43
- refs,
44
- };
45
- }
46
46
  export function expandAggregatedCategory(category, context) {
47
47
  return {
48
48
  ...category,
49
49
  refs: category.refs.flatMap(ref => ref.plugin === AXE_PLUGIN_SLUG ? expandCategoryRefs(ref, context) : [ref]),
50
50
  };
51
51
  }
52
- export function extractGroupSlugs(groups) {
53
- const slugs = groups.map(({ slug }) => removeIndex(slug));
54
- return [...new Set(slugs)].filter(isAxeGroupSlug);
55
- }
56
52
  //# sourceMappingURL=categories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"categories.js","sourceRoot":"","sources":["../../../src/lib/categories.ts"],"names":[],"mappings":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,CAAC;QACjD,OAAO,UAAU,IAAI,EAAE,CAAC;IAC1B,CAAC;IACD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,gBAAgB,CACvB,MAAgD;IAEhD,OAAO;QACL;YACE,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,mBAAmB;YAC1B,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC;SAC3B;KACF,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CACvB,MAAqC,EACrC,UAA4B;IAE5B,MAAM,OAAO,GAAG,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACjE,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3C,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,OAAO,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAC/B,wBAAwB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAC5C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,QAAwB,EACxB,OAAyB;IAEzB,OAAO;QACL,GAAG,QAAQ;QACX,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAChC,GAAG,CAAC,MAAM,KAAK,eAAe,CAAC,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAC1E;KACF,CAAC;AACJ,CAAC"}
package/src/lib/groups.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { axePresetSchema } from './config.js';
3
- /* WCAG presets for rule loading */
3
+ /** WCAG presets for rule loading */
4
4
  const axeWcagTags = [
5
5
  'wcag2a',
6
6
  'wcag21a',
@@ -21,7 +21,7 @@ const WCAG_PRESET_TAGS = {
21
21
  export function getWcagPresetTags(preset) {
22
22
  return WCAG_PRESET_TAGS[preset];
23
23
  }
24
- /* Category groups for all presets */
24
+ /** Category groups for all presets */
25
25
  const axeCategoryGroupSlugs = [
26
26
  'aria',
27
27
  'color',
@@ -58,6 +58,6 @@ export const CATEGORY_GROUPS = {
58
58
  export function isAxeGroupSlug(slug) {
59
59
  return axeCategoryGroupSlugSchema.safeParse(slug).success;
60
60
  }
61
- /* Combined exports */
61
+ // Combined exports
62
62
  export const axeGroupSlugSchema = axeCategoryGroupSlugSchema;
63
63
  //# sourceMappingURL=groups.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"groups.js","sourceRoot":"","sources":["../../../src/lib/groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,mCAAmC;AACnC,MAAM,WAAW,GAAG;IAClB,QAAQ;IACR,SAAS;IACT,SAAS;IACT,UAAU;IACV,UAAU;CACF,CAAC;AAEX,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC;KAC9B,IAAI,CAAC,WAAW,CAAC;KACjB,IAAI,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;AAIjC,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe;KAC/C,OAAO,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;KACjC,IAAI,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC;AAIpC,MAAM,gBAAgB,GAAwC;IAC5D,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC;IACtD,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC;CACnE,CAAC;AAEF,MAAM,UAAU,iBA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yB,EAAE,aAAa;IACxC,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,QAAQ;IAChB,mBAAmB,EAAE,mBAAmB;IACxC,gBAAgB,EAAE,OAAO;CAC1B,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,IAAa;IAC1C,OAAO,0BAA0B,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;AAC5D,CAAC;AAED,mBAAmB;AACnB,MAAM,CAAC,MAAM,kBAAkB,GAAG,0BAA0B,CAAC"}
@@ -1,4 +1,28 @@
1
- import type { CategoryRef } from '@code-pushup/models';
2
- import type { AxeGroupSlug } from './groups.js';
1
+ import { type CategoryRef, type PluginConfig } from '@code-pushup/models';
2
+ import { type AxeGroupSlug } from './groups.js';
3
+ /**
4
+ * @deprecated Use `axeGroupRefs` instead for multi-URL support.
5
+ */
3
6
  export declare function axeGroupRef(groupSlug: AxeGroupSlug, weight?: number): CategoryRef;
7
+ /**
8
+ * @deprecated Use `axeAuditRefs` instead for multi-URL support.
9
+ */
4
10
  export declare function axeAuditRef(auditSlug: string, weight?: number): CategoryRef;
11
+ /**
12
+ * Creates category refs for Axe groups with multi-URL support.
13
+ *
14
+ * @param plugin - Axe plugin instance
15
+ * @param groupSlug - Optional group slug; if omitted, includes all groups
16
+ * @param groupWeight - Optional weight for the ref(s)
17
+ * @returns Array of category refs, expanded for each URL in multi-URL configs
18
+ */
19
+ export declare function axeGroupRefs(plugin: Pick<PluginConfig, 'groups' | 'context'>, groupSlug?: AxeGroupSlug, groupWeight?: number): CategoryRef[];
20
+ /**
21
+ * Creates category refs for Axe audits with multi-URL support.
22
+ *
23
+ * @param plugin - Axe plugin instance
24
+ * @param auditSlug - Optional audit slug; if omitted, includes all audits
25
+ * @param auditWeight - Optional weight for the ref(s)
26
+ * @returns Array of category refs, expanded for each URL in multi-URL configs
27
+ */
28
+ export declare function axeAuditRefs(plugin: Pick<PluginConfig, 'audits' | 'context'>, auditSlug?: string, auditWeight?: number): CategoryRef[];
package/src/lib/utils.js CHANGED
@@ -1,4 +1,10 @@
1
+ import { validate, } from '@code-pushup/models';
2
+ import { expandCategoryRefs, extractGroupSlugs, pluginUrlContextSchema, } from '@code-pushup/utils';
1
3
  import { AXE_PLUGIN_SLUG } from './constants.js';
4
+ import { isAxeGroupSlug } from './groups.js';
5
+ /**
6
+ * @deprecated Use `axeGroupRefs` instead for multi-URL support.
7
+ */
2
8
  export function axeGroupRef(groupSlug, weight = 1) {
3
9
  return {
4
10
  plugin: AXE_PLUGIN_SLUG,
@@ -7,6 +13,9 @@ export function axeGroupRef(groupSlug, weight = 1) {
7
13
  weight,
8
14
  };
9
15
  }
16
+ /**
17
+ * @deprecated Use `axeAuditRefs` instead for multi-URL support.
18
+ */
10
19
  export function axeAuditRef(auditSlug, weight = 1) {
11
20
  return {
12
21
  plugin: AXE_PLUGIN_SLUG,
@@ -15,4 +24,50 @@ export function axeAuditRef(auditSlug, weight = 1) {
15
24
  weight,
16
25
  };
17
26
  }
27
+ /**
28
+ * Creates category refs for Axe groups with multi-URL support.
29
+ *
30
+ * @param plugin - Axe plugin instance
31
+ * @param groupSlug - Optional group slug; if omitted, includes all groups
32
+ * @param groupWeight - Optional weight for the ref(s)
33
+ * @returns Array of category refs, expanded for each URL in multi-URL configs
34
+ */
35
+ export function axeGroupRefs(plugin, groupSlug, groupWeight) {
36
+ const context = validate(pluginUrlContextSchema, plugin.context);
37
+ if (groupSlug) {
38
+ return expandCategoryRefs({
39
+ slug: groupSlug,
40
+ weight: groupWeight,
41
+ type: 'group',
42
+ plugin: AXE_PLUGIN_SLUG,
43
+ }, context);
44
+ }
45
+ return axeGroupSlugs(plugin).flatMap(slug => expandCategoryRefs({ slug, type: 'group', plugin: AXE_PLUGIN_SLUG }, context));
46
+ }
47
+ /**
48
+ * Creates category refs for Axe audits with multi-URL support.
49
+ *
50
+ * @param plugin - Axe plugin instance
51
+ * @param auditSlug - Optional audit slug; if omitted, includes all audits
52
+ * @param auditWeight - Optional weight for the ref(s)
53
+ * @returns Array of category refs, expanded for each URL in multi-URL configs
54
+ */
55
+ export function axeAuditRefs(plugin, auditSlug, auditWeight) {
56
+ const context = validate(pluginUrlContextSchema, plugin.context);
57
+ if (auditSlug) {
58
+ return expandCategoryRefs({
59
+ slug: auditSlug,
60
+ weight: auditWeight,
61
+ type: 'audit',
62
+ plugin: AXE_PLUGIN_SLUG,
63
+ }, context);
64
+ }
65
+ return plugin.audits.flatMap(({ slug }) => expandCategoryRefs({ slug, type: 'audit', plugin: AXE_PLUGIN_SLUG }, context));
66
+ }
67
+ function axeGroupSlugs(plugin) {
68
+ if (!plugin.groups) {
69
+ return [];
70
+ }
71
+ return extractGroupSlugs(plugin.groups).filter(isAxeGroupSlug);
72
+ }
18
73
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,MAAM,UAAU,WAAW,CAAC,SAAuB,EAAE,MAAM,GAAG,CAAC;IAC7D,OAAO;QACL,MAAM,EAAE,eAAe;QACvB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO;QACb,MAAM;KACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,MAAM,GAAG,CAAC;IACvD,OAAO;QACL,MAAM,EAAE,eAAe;QACvB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO;QACb,MAAM;KACP,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC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