style: format luna charts source
This commit is contained in:
@@ -9,13 +9,13 @@ export const axeCoreChecker: A11yChecker = {
|
||||
|
||||
return {
|
||||
checkerName: 'axe-core',
|
||||
violations: results.violations.map((violations) => ({
|
||||
violations: results.violations.map(violations => ({
|
||||
id: violations.id,
|
||||
impact: violations.impact ?? null,
|
||||
description: violations.help,
|
||||
helpUrl: violations.helpUrl,
|
||||
nodes: violations.nodes.map((node) => node.target.join(' ')),
|
||||
nodes: violations.nodes.map(node => node.target.join(' ')),
|
||||
})),
|
||||
};
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,4 +14,4 @@ export interface A11yCheckResult {
|
||||
export interface A11yChecker {
|
||||
name: string;
|
||||
run(root: Element): Promise<A11yCheckResult>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import type { A11yChecker, A11yCheckResult } from './checkers/types';
|
||||
import { axeCoreChecker } from './checkers/axe-core.checker';
|
||||
|
||||
const a11yCheckerRegistry: A11yChecker[] = [
|
||||
axeCoreChecker,
|
||||
];
|
||||
const a11yCheckerRegistry: A11yChecker[] = [axeCoreChecker];
|
||||
|
||||
export async function runA11yChecks(rootElement: Element): Promise<A11yCheckResult[]> {
|
||||
return Promise.all(a11yCheckerRegistry.map((a11yChecker) => a11yChecker.run(rootElement)));
|
||||
return Promise.all(a11yCheckerRegistry.map(a11yChecker => a11yChecker.run(rootElement)));
|
||||
}
|
||||
|
||||
export type { A11yChecker, A11yCheckResult, A11yViolation } from './checkers/types';
|
||||
export type { A11yChecker, A11yCheckResult, A11yViolation } from './checkers/types';
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { A11yCheckResult } from './checkers/types';
|
||||
|
||||
expect.extend({
|
||||
toHaveNoA11yViolations(results: A11yCheckResult[]) {
|
||||
const failing = results.filter((results) => results.violations.length > 0);
|
||||
const failing = results.filter(results => results.violations.length > 0);
|
||||
|
||||
if (failing.length === 0) {
|
||||
return {
|
||||
@@ -14,11 +14,9 @@ expect.extend({
|
||||
|
||||
const message = failing
|
||||
.map(
|
||||
(results) =>
|
||||
results =>
|
||||
`[${results.checkerName}] ${results.violations.length} violation(s):\n` +
|
||||
results.violations
|
||||
.map((validation) => ` - ${validation.id} (${validation.impact}): ${validation.description}\n affected: ${validation.nodes.join(', ')}`)
|
||||
.join('\n')
|
||||
results.violations.map(validation => ` - ${validation.id} (${validation.impact}): ${validation.description}\n affected: ${validation.nodes.join(', ')}`).join('\n'),
|
||||
)
|
||||
.join('\n\n');
|
||||
|
||||
@@ -33,4 +31,4 @@ declare module 'vitest' {
|
||||
interface Assertion {
|
||||
toHaveNoA11yViolations(): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user