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

Implement SIA-R70 #839

Closed
wants to merge 11 commits into from
Prev Previous commit
changes implemented
elenamongelli authored and Jym77 committed Jul 21, 2021
commit 2ee9b98e2a26030ebe721ad2c18f0ceab3635147
23 changes: 11 additions & 12 deletions packages/alfa-rules/src/sia-r70/rule.ts
Original file line number Diff line number Diff line change
@@ -94,40 +94,39 @@ class DeprecatedElements extends Diagnostic implements Iterable<Element> {
return new DeprecatedElements(message, Array.from(errors));
}

private _errors: ReadonlyArray<Element>;
private constructor(message: string, errors: Array<Element>) {
super(message);
this._errors = errors;
}

public *[Symbol.iterator](): Iterator<Element> {
yield* this._errors;
public get errors(): ReadonlyArray<Element> {
return this._errors;
}

private _errors: ReadonlyArray<Element>;

public equalsError(value: unknown, errors: ReadonlyArray<Element>): boolean {
public equals(value: DeprecatedElements): boolean;
public equals(value: unknown): value is this;
public equals(value: unknown): boolean {
return (
value instanceof DeprecatedElements &&
value._message === this._message &&
Array.equals(value._errors, this._errors)
);
}

public *[Symbol.iterator](): Iterator<Element> {
yield* this._errors;
}
public toJSON(): DeprecatedElements.JSON {
return {
...super.toJSON(),
errors: Array.toJSON(this._errors),
errors: this._errors.map((element) => element.path()),
};
}

public get errors(): ReadonlyArray<Element> {
return this._errors;
}
}

namespace DeprecatedElements {
export interface JSON extends Diagnostic.JSON {
errors: List.JSON<Element>;
errors: Array<string>;
}

export function isDeprecatedElements(