+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_js_analyze): complete rule useAriaPropsForRole #3902

Merged
merged 6 commits into from
Dec 2, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/rome_aria/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ use std::str::FromStr;
mod generated;

pub mod constants;
mod macros;
pub mod properties;
pub mod roles;

use crate::generated::{AriaPropertiesEnum, AriaPropertyTypeEnum};
pub use properties::AriaProperties;
pub(crate) use roles::AriaRoleDefinition;
pub use roles::AriaRoles;

/// It checks if an ARIA property is valid
Expand Down
26 changes: 26 additions & 0 deletions crates/rome_aria/src/macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#[macro_export]
macro_rules! define_role {
( $( #[doc = $doc:literal] )+ $id:ident {
PROPS: $p_value:expr,
ROLES: $r_value:expr,
}) => {
$( #[doc = $doc] )*
#[derive(Debug)]
struct $id;

impl $id {
const PROPS: &[(&'static str, bool)] = &$p_value;
const ROLES: &[&'static str] = &$r_value;
}

impl $crate::AriaRoleDefinition for $id {
fn properties<'a>(&self) -> std::slice::Iter<'a, (&str, bool)> {
$id::PROPS.iter()
}

fn roles<'a>(&self) -> std::slice::Iter<'a, &str> {
$id::ROLES.iter()
}
}
};
}
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载