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

feat(linter): eslint-plugin-jsx-a11y aria-role #1849

Merged
merged 3 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
282 changes: 282 additions & 0 deletions crates/oxc_linter/src/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,285 @@ pub const VALID_ARIA_PROPS: phf::Set<&'static str> = phf_set! {
"aria-valuenow",
"aria-valuetext"
};

/// set of valid ARIA role definitions
/// Reference: <https://www.w3.org/TR/wai-aria/#role_definitions>
pub const VALID_ARIA_ROLES: phf::Set<&'static str> = phf_set! {
"alert",
"alertdialog",
"application",
"article",
"banner",
"blockquote",
"button",
"caption",
"cell",
"checkbox",
"code",
"columnheader",
"combobox",
"complementary",
"contentinfo",
"definition",
"deletion",
"dialog",
"directory",
"document",
"emphasis",
"feed",
"figure",
"form",
"generic",
"grid",
"gridcell",
"group",
"heading",
"img",
"insertion",
"link",
"list",
"listbox",
"listitem",
"log",
"main",
"mark",
"marquee",
"math",
"menu",
"menubar",
"menuitem",
"menuitemcheckbox",
"menuitemradio",
"meter",
"navigation",
"none",
"note",
"option",
"paragraph",
"presentation",
"progressbar",
"radio",
"radiogroup",
"region",
"row",
"rowgroup",
"rowheader",
"scrollbar",
"search",
"searchbox",
"separator",
"slider",
"spinbutton",
"status",
"strong",
"subscript",
"superscript",
"switch",
"tab",
"table",
"tablist",
"tabpanel",
"term",
"textbox",
"time",
"timer",
"toolbar",
"tooltip",
"tree",
"treegrid",
"treeitem",
"doc-abstract",
"doc-acknowledgments",
"doc-afterword",
"doc-appendix",
"doc-backlink",
"doc-biblioentry",
"doc-bibliography",
"doc-biblioref",
"doc-chapter",
"doc-colophon",
"doc-conclusion",
"doc-cover",
"doc-credit",
"doc-credits",
"doc-dedication",
"doc-endnote",
"doc-endnotes",
"doc-epigraph",
"doc-epilogue",
"doc-errata",
"doc-example",
"doc-footnote",
"doc-foreword",
"doc-glossary",
"doc-glossref",
"doc-index",
"doc-introduction",
"doc-noteref",
"doc-notice",
"doc-pagebreak",
"doc-pagelist",
"doc-part",
"doc-preface",
"doc-prologue",
"doc-pullquote",
"doc-qna",
"doc-subtitle",
"doc-tip",
"doc-toc",
"graphics-document",
"graphics-object",
"graphics-symbol"
};

pub const HTML_TAG: phf::Set<&'static str> = phf_set! {
"a",
"abbr",
"acronym",
"address",
"applet",
"area",
"article",
"aside",
"audio",
"b",
"base",
"basefont",
"bdi",
"bdo",
"bgsound",
"big",
"blink",
"blockquote",
"body",
"br",
"button",
"canvas",
"caption",
"center",
"cite",
"code",
"col",
"colgroup",
"command",
"content",
"data",
"datalist",
"dd",
"del",
"details",
"dfn",
"dialog",
"dir",
"div",
"dl",
"dt",
"element",
"em",
"embed",
"fieldset",
"figcaption",
"figure",
"font",
"footer",
"form",
"frame",
"frameset",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"head",
"header",
"hgroup",
"hr",
"html",
"i",
"iframe",
"image",
"img",
"input",
"ins",
"isindex",
"kbd",
"keygen",
"label",
"legend",
"li",
"link",
"listing",
"main",
"map",
"mark",
"marquee",
"math",
"menu",
"menuitem",
"meta",
"meter",
"multicol",
"nav",
"nextid",
"nobr",
"noembed",
"noframes",
"noscript",
"object",
"ol",
"optgroup",
"option",
"output",
"p",
"param",
"picture",
"plaintext",
"pre",
"progress",
"q",
"rb",
"rbc",
"rp",
"rt",
"rtc",
"ruby",
"s",
"samp",
"script",
"search",
"section",
"select",
"shadow",
"slot",
"small",
"source",
"spacer",
"span",
"strike",
"strong",
"style",
"sub",
"summary",
"sup",
"svg",
"table",
"tbody",
"td",
"template",
"textarea",
"tfoot",
"th",
"thead",
"time",
"title",
"tr",
"track",
"tt",
"u",
"ul",
"var",
"video",
"wbr",
"xmp",
};
2 changes: 2 additions & 0 deletions crates/oxc_linter/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ mod jsx_a11y {
pub mod anchor_has_content;
pub mod anchor_is_valid;
pub mod aria_props;
pub mod aria_role;
pub mod heading_has_content;
pub mod html_has_lang;
pub mod iframe_has_title;
Expand Down Expand Up @@ -480,6 +481,7 @@ oxc_macros::declare_all_lint_rules! {
jsx_a11y::no_autofocus,
jsx_a11y::scope,
jsx_a11y::tab_index_no_positive,
jsx_a11y::aria_role,
jsx_a11y::no_distracting_elements,
oxc::approx_constant,
oxc::const_comparisons,
Expand Down
Loading