-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename diagnostic
WithAccessibleName
to WithName
and property `ac…
…cessibleName` to `name` (#1537) * Rename `accessibleName` to `name` * Extract API * Add changeset
- Loading branch information
1 parent
4019dff
commit a6024eb
Showing
15 changed files
with
158 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@siteimprove/alfa-rules": minor | ||
--- | ||
|
||
**Breaking:** Diagnostic `WithAccessibleName` has been renamed to `WithName` and the property `accessibleName` to `name`. | ||
|
||
This is to conform to existing diagnostics that refer to accessible name as name and clients that are expecting this convention. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 0 additions & 71 deletions
71
packages/alfa-rules/src/common/diagnostic/with-accessible-name.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Diagnostic } from "@siteimprove/alfa-act"; | ||
import { Device } from "@siteimprove/alfa-device"; | ||
import { Node } from "@siteimprove/alfa-aria"; | ||
import { Element } from "@siteimprove/alfa-dom"; | ||
import { Option } from "@siteimprove/alfa-option"; | ||
|
||
/** | ||
* @public | ||
*/ | ||
export class WithName extends Diagnostic { | ||
public static of(message: string): Diagnostic; | ||
|
||
public static of(message: string, name: string): Diagnostic; | ||
|
||
public static of(message: string, name?: string): Diagnostic { | ||
return name === undefined | ||
? new Diagnostic(message) | ||
: new WithName(message, name); | ||
} | ||
|
||
private readonly _name: string; | ||
|
||
protected constructor(message: string, name: string) { | ||
super(message); | ||
this._name = name; | ||
} | ||
|
||
public get name(): string { | ||
return this._name; | ||
} | ||
|
||
public toJSON(): WithName.JSON { | ||
return { | ||
...super.toJSON(), | ||
name: this._name, | ||
}; | ||
} | ||
} | ||
|
||
/** | ||
* @public | ||
*/ | ||
export namespace WithName { | ||
export interface JSON extends Diagnostic.JSON { | ||
name: string; | ||
} | ||
|
||
export function isWithName(value: Diagnostic): value is WithName; | ||
|
||
export function isWithName(value: unknown): value is WithName; | ||
|
||
/** | ||
* @public | ||
*/ | ||
export function isWithName(value: unknown): value is WithName { | ||
return value instanceof WithName; | ||
} | ||
|
||
export function getName(element: Element, device: Device): Option<string> { | ||
return Node.from(element, device).name.map((x) => x.value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.