Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(d.ts): RawNodesResult issues #4229

Merged
merged 5 commits into from Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 19 additions & 6 deletions axe.d.ts
@@ -1,6 +1,5 @@
// Type definitions for axe-core
// Project: https://github.com/dequelabs/axe-core
// Definitions by: Marcy Sutton <https://github.com/marcysutton>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record. Removing this because Marcy should not be the person someone reaches out to for issues with this file as this comment might suggest. No other code file in axe-core includes info on who did the initial commit. It has been updated and expanded on since then many times. I'm removing this line because its out of place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other past employees should also be removed from package.json.


declare namespace axe {
type ImpactValue = 'minor' | 'moderate' | 'serious' | 'critical' | null;
Expand Down Expand Up @@ -333,6 +332,14 @@ declare namespace axe {
xpath: string[];
ancestry: UnlabelledFrameSelector;
}
interface DqElement extends SerialDqElement {
element: Element;
toJSON(): SerialDqElement;
mergeSpecs(
childSpec: SerialDqElement,
parentSpec: SerialDqElement
): SerialDqElement;
}
interface PartialRuleResult {
id: string;
result: 'inapplicable';
Expand All @@ -351,16 +358,21 @@ declare namespace axe {
frameContext: FrameContextObject;
}

interface RawCheckResult extends Omit<CheckResult, 'relatedNodes'> {
relatedNodes?: Array<SerialDqElement | DqElement>;
}

interface RawNodeResult<T extends 'passed' | 'failed' | 'incomplete'> {
any: CheckResult[];
all: CheckResult[];
none: CheckResult[];
node: SerialDqElement | DqElement;
any: RawCheckResult[];
all: RawCheckResult[];
none: RawCheckResult[];
impact: ImpactValue | null;
result: T;
}

interface RawResult extends Omit<Result, 'nodes'> {
inapplicable: [];
inapplicable: Array<never>;
passes: RawNodeResult<'passed'>[];
incomplete: RawNodeResult<'incomplete'>[];
violations: RawNodeResult<'failed'>[];
Expand All @@ -383,6 +395,7 @@ declare namespace axe {
attr(attr: string): string | null;
hasAttr(attr: string): boolean;
props: { [key: string]: unknown };
boundingClientRect: DOMRect;
}

interface Utils {
Expand All @@ -396,7 +409,7 @@ declare namespace axe {
DqElement: new (
elm: Element,
options?: { absolutePaths?: boolean }
) => SerialDqElement;
) => DqElement;
uuid: (
options?: { random?: Uint8Array | Array<number> },
buf?: Uint8Array | Array<number>,
Expand Down
38 changes: 38 additions & 0 deletions typings/axe-core/axe-core-tests.ts
Expand Up @@ -344,6 +344,44 @@ axe.configure({
}
});

const results: axe.RawResult[] = [
{
id: 'the-best-rule',
result: 'passed',
pageLevel: false,
impact: null,
tags: ['best-practice'],
description: 'Be cool',
help: 'No, cooler',
helpUrl:
'https://dequeuniversity.com/rules/axe/4.8/the-best-rule?application=axeAPI',
inapplicable: [],
passes: [
{
any: [
{
id: 'the-best-check',
data: null,
impact: 'serious',
message: 'Element has sufficient color contrast of 21',
relatedNodes: [
new axe.utils.DqElement(document.body),
new axe.utils.DqElement(document.body).toJSON()
]
}
],
all: [],
none: [],
impact: null,
result: 'passed',
node: new axe.utils.DqElement(document.body)
}
],
incomplete: [],
violations: []
}
];

// Reporters
let fooReporter = (
results: axe.RawResult[],
Expand Down