Skip to content

Commit 5bd7216

Browse files
authored
feat(plugin-axe): implement core plugin functionality (#1141)
1 parent 4a982a5 commit 5bd7216

Some content is hidden

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

61 files changed

+3682
-596
lines changed

code-pushup.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dotenv/config';
22
import {
3+
axeCoreConfig,
34
coverageCoreConfigNx,
45
eslintCoreConfigNx,
56
jsDocsCoreConfig,
@@ -43,4 +44,7 @@ export default mergeConfigs(
4344
'!**/implementation/**',
4445
'!**/internal/**',
4546
]),
47+
axeCoreConfig(
48+
'https://github.com/code-pushup/cli?tab=readme-ov-file#code-pushup-cli/',
49+
),
4650
);

code-pushup.preset.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import type {
33
CategoryConfig,
44
CoreConfig,
5+
PluginUrls,
56
} from './packages/models/src/index.js';
7+
import axePlugin from './packages/plugin-axe/src/index.js';
68
import coveragePlugin, {
79
getNxCoveragePaths,
810
} from './packages/plugin-coverage/src/index.js';
@@ -20,7 +22,6 @@ import {
2022
} from './packages/plugin-jsdocs/src/lib/constants.js';
2123
import { filterGroupsByOnlyAudits } from './packages/plugin-jsdocs/src/lib/utils.js';
2224
import lighthousePlugin, {
23-
type LighthouseUrls,
2425
lighthouseGroupRef,
2526
mergeLighthouseCategories,
2627
} from './packages/plugin-lighthouse/src/index.js';
@@ -137,7 +138,7 @@ export const jsPackagesCoreConfig = async (): Promise<CoreConfig> => ({
137138
});
138139

139140
export const lighthouseCoreConfig = async (
140-
urls: LighthouseUrls,
141+
urls: PluginUrls,
141142
): Promise<CoreConfig> => {
142143
const lhPlugin = await lighthousePlugin(urls);
143144
return {
@@ -216,3 +217,7 @@ export const coverageCoreConfigNx = async (
216217
categories: coverageCategories,
217218
};
218219
};
220+
221+
export const axeCoreConfig = (urls: PluginUrls): CoreConfig => ({
222+
plugins: [axePlugin(urls)],
223+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import tseslint from 'typescript-eslint';
2+
import baseConfig from '../../eslint.config.js';
3+
4+
export default tseslint.config(...baseConfig, {
5+
files: ['**/*.ts'],
6+
languageOptions: {
7+
parserOptions: {
8+
projectService: true,
9+
tsconfigRootDir: import.meta.dirname,
10+
},
11+
},
12+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { join } from 'node:path';
2+
import { pathToFileURL } from 'node:url';
3+
import axePlugin from '@code-pushup/axe-plugin';
4+
import type { CoreConfig } from '@code-pushup/models';
5+
6+
const htmlFile = join(process.cwd(), 'index.html');
7+
const url = pathToFileURL(htmlFile).href;
8+
9+
export default {
10+
plugins: [axePlugin(url)],
11+
} satisfies CoreConfig;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Accessibility Test Page</title>
7+
<style>
8+
/* Poor color contrast for testing */
9+
.low-contrast {
10+
color: #777;
11+
background-color: #999;
12+
padding: 10px;
13+
}
14+
</style>
15+
</head>
16+
<body>
17+
<h1>Accessibility Test Page</h1>
18+
19+
<!-- Missing alt text on image -->
20+
<img src="test-image.jpg" width="200" height="150" />
21+
22+
<!-- Poor color contrast -->
23+
<div class="low-contrast">
24+
This text has poor color contrast and may be hard to read.
25+
</div>
26+
27+
<!-- Invalid ARIA attribute -->
28+
<div role="button" aria-invalid-attribute="true">
29+
Button with invalid ARIA attribute
30+
</div>
31+
32+
<!-- Form input missing label -->
33+
<form>
34+
<input type="text" name="username" placeholder="Enter username" />
35+
<button type="submit">Submit</button>
36+
</form>
37+
38+
<!-- Button without accessible name -->
39+
<button></button>
40+
41+
<!-- Link without accessible name -->
42+
<a href="#"></a>
43+
</body>
44+
</html>

e2e/plugin-axe-e2e/project.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "plugin-axe-e2e",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "e2e/plugin-axe-e2e/src",
5+
"projectType": "application",
6+
"targets": {
7+
"lint": {},
8+
"e2e": {
9+
"executor": "@nx/vite:test",
10+
"options": {
11+
"configFile": "{projectRoot}/vitest.e2e.config.ts"
12+
}
13+
}
14+
},
15+
"implicitDependencies": ["cli", "plugin-axe"],
16+
"tags": ["scope:plugin", "type:e2e"]
17+
}

0 commit comments

Comments
 (0)