diff --git a/crates/rome_js_analyze/src/aria_analyzers/nursery.rs b/crates/rome_js_analyze/src/aria_analyzers/nursery.rs index 20703f3e60ae..ce89d1973549 100644 --- a/crates/rome_js_analyze/src/aria_analyzers/nursery.rs +++ b/crates/rome_js_analyze/src/aria_analyzers/nursery.rs @@ -1,7 +1,8 @@ //! Generated file, do not edit by hand, see `xtask/codegen` use rome_analyze::declare_group; +mod no_noninteractive_element_to_interactive_role; mod use_aria_prop_types; mod use_aria_props_for_role; mod use_valid_lang; -declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: use_aria_prop_types :: UseAriaPropTypes , self :: use_aria_props_for_role :: UseAriaPropsForRole , self :: use_valid_lang :: UseValidLang ,] } } +declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_noninteractive_element_to_interactive_role :: NoNoninteractiveElementToInteractiveRole , self :: use_aria_prop_types :: UseAriaPropTypes , self :: use_aria_props_for_role :: UseAriaPropsForRole , self :: use_valid_lang :: UseValidLang ,] } } diff --git a/crates/rome_service/src/configuration/linter/rules.rs b/crates/rome_service/src/configuration/linter/rules.rs index 003d9a9915d0..13923b959a3d 100644 --- a/crates/rome_service/src/configuration/linter/rules.rs +++ b/crates/rome_service/src/configuration/linter/rules.rs @@ -184,9 +184,7 @@ impl Rules { None } } - pub(crate) fn is_recommended(&self) -> bool { - !matches!(self.recommended, Some(false)) - } + pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) } #[doc = r" It returns a tuple of filters. The first element of the tuple are the enabled rules,"] #[doc = r" while the second element are the disabled rules."] #[doc = r""] @@ -421,9 +419,7 @@ impl A11y { RuleFilter::Rule("a11y", Self::CATEGORY_RULES[7]), RuleFilter::Rule("a11y", Self::CATEGORY_RULES[8]), ]; - pub(crate) fn is_recommended(&self) -> bool { - !matches!(self.recommended, Some(false)) - } + pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) } pub(crate) fn get_enabled_rules(&self) -> IndexSet { IndexSet::from_iter(self.rules.iter().filter_map(|(key, conf)| { if conf.is_enabled() { @@ -443,9 +439,7 @@ impl A11y { })) } #[doc = r" Checks if, given a rule name, matches one of the rules contained in this category"] - pub(crate) fn has_rule(rule_name: &str) -> bool { - Self::CATEGORY_RULES.contains(&rule_name) - } + pub(crate) fn has_rule(rule_name: &str) -> bool { Self::CATEGORY_RULES.contains(&rule_name) } #[doc = r" Checks if, given a rule name, it is marked as recommended"] pub(crate) fn is_recommended_rule(rule_name: &str) -> bool { Self::RECOMMENDED_RULES.contains(&rule_name) @@ -531,9 +525,7 @@ impl Complexity { RuleFilter::Rule("complexity", Self::CATEGORY_RULES[4]), RuleFilter::Rule("complexity", Self::CATEGORY_RULES[5]), ]; - pub(crate) fn is_recommended(&self) -> bool { - !matches!(self.recommended, Some(false)) - } + pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) } pub(crate) fn get_enabled_rules(&self) -> IndexSet { IndexSet::from_iter(self.rules.iter().filter_map(|(key, conf)| { if conf.is_enabled() { @@ -553,9 +545,7 @@ impl Complexity { })) } #[doc = r" Checks if, given a rule name, matches one of the rules contained in this category"] - pub(crate) fn has_rule(rule_name: &str) -> bool { - Self::CATEGORY_RULES.contains(&rule_name) - } + pub(crate) fn has_rule(rule_name: &str) -> bool { Self::CATEGORY_RULES.contains(&rule_name) } #[doc = r" Checks if, given a rule name, it is marked as recommended"] pub(crate) fn is_recommended_rule(rule_name: &str) -> bool { Self::RECOMMENDED_RULES.contains(&rule_name) @@ -664,9 +654,7 @@ impl Correctness { RuleFilter::Rule("correctness", Self::CATEGORY_RULES[9]), RuleFilter::Rule("correctness", Self::CATEGORY_RULES[10]), ]; - pub(crate) fn is_recommended(&self) -> bool { - !matches!(self.recommended, Some(false)) - } + pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) } pub(crate) fn get_enabled_rules(&self) -> IndexSet { IndexSet::from_iter(self.rules.iter().filter_map(|(key, conf)| { if conf.is_enabled() { @@ -686,9 +674,7 @@ impl Correctness { })) } #[doc = r" Checks if, given a rule name, matches one of the rules contained in this category"] - pub(crate) fn has_rule(rule_name: &str) -> bool { - Self::CATEGORY_RULES.contains(&rule_name) - } + pub(crate) fn has_rule(rule_name: &str) -> bool { Self::CATEGORY_RULES.contains(&rule_name) } #[doc = r" Checks if, given a rule name, it is marked as recommended"] pub(crate) fn is_recommended_rule(rule_name: &str) -> bool { Self::RECOMMENDED_RULES.contains(&rule_name) @@ -765,6 +751,8 @@ struct NurserySchema { no_invalid_constructor_super: Option, #[doc = "Disallow non-null assertions using the ! postfix operator."] no_non_null_assertion: Option, + #[doc = "Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements."] + no_noninteractive_element_to_interactive_role: Option, #[doc = "Disallow literal numbers that lose precision"] no_precision_loss: Option, #[doc = "Enforce img alt prop does not contain the word \"image\", \"picture\", or \"photo\"."] @@ -816,7 +804,7 @@ struct NurserySchema { } impl Nursery { const CATEGORY_NAME: &'static str = "nursery"; - pub(crate) const CATEGORY_RULES: [&'static str; 38] = [ + pub(crate) const CATEGORY_RULES: [&'static str; 39] = [ "noAccessKey", "noAssignInExpressions", "noBannedTypes", @@ -831,6 +819,7 @@ impl Nursery { "noHeaderScope", "noInvalidConstructorSuper", "noNonNullAssertion", + "noNoninteractiveElementToInteractiveRole", "noPrecisionLoss", "noRedundantAlt", "noRedundantUseStrict", @@ -856,7 +845,7 @@ impl Nursery { "useNumericLiterals", "useValidLang", ]; - const RECOMMENDED_RULES: [&'static str; 29] = [ + const RECOMMENDED_RULES: [&'static str; 30] = [ "noAssignInExpressions", "noBannedTypes", "noClassAssign", @@ -869,6 +858,7 @@ impl Nursery { "noExtraNonNullAssertion", "noHeaderScope", "noInvalidConstructorSuper", + "noNoninteractiveElementToInteractiveRole", "noRedundantAlt", "noSelfCompare", "noSetterReturn", @@ -887,7 +877,7 @@ impl Nursery { "useNumericLiterals", "useValidLang", ]; - const RECOMMENDED_RULES_AS_FILTERS: [RuleFilter<'static>; 29] = [ + const RECOMMENDED_RULES_AS_FILTERS: [RuleFilter<'static>; 30] = [ RuleFilter::Rule("nursery", Self::CATEGORY_RULES[1]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[2]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[3]), @@ -900,8 +890,8 @@ impl Nursery { RuleFilter::Rule("nursery", Self::CATEGORY_RULES[10]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[11]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[12]), - RuleFilter::Rule("nursery", Self::CATEGORY_RULES[15]), - RuleFilter::Rule("nursery", Self::CATEGORY_RULES[18]), + RuleFilter::Rule("nursery", Self::CATEGORY_RULES[14]), + RuleFilter::Rule("nursery", Self::CATEGORY_RULES[16]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[19]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[20]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[21]), @@ -909,18 +899,17 @@ impl Nursery { RuleFilter::Rule("nursery", Self::CATEGORY_RULES[23]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[24]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[25]), - RuleFilter::Rule("nursery", Self::CATEGORY_RULES[27]), - RuleFilter::Rule("nursery", Self::CATEGORY_RULES[29]), + RuleFilter::Rule("nursery", Self::CATEGORY_RULES[26]), + RuleFilter::Rule("nursery", Self::CATEGORY_RULES[28]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[30]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[31]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[32]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[33]), - RuleFilter::Rule("nursery", Self::CATEGORY_RULES[36]), + RuleFilter::Rule("nursery", Self::CATEGORY_RULES[34]), RuleFilter::Rule("nursery", Self::CATEGORY_RULES[37]), + RuleFilter::Rule("nursery", Self::CATEGORY_RULES[38]), ]; - pub(crate) fn is_recommended(&self) -> bool { - !matches!(self.recommended, Some(false)) - } + pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) } pub(crate) fn get_enabled_rules(&self) -> IndexSet { IndexSet::from_iter(self.rules.iter().filter_map(|(key, conf)| { if conf.is_enabled() { @@ -940,14 +929,12 @@ impl Nursery { })) } #[doc = r" Checks if, given a rule name, matches one of the rules contained in this category"] - pub(crate) fn has_rule(rule_name: &str) -> bool { - Self::CATEGORY_RULES.contains(&rule_name) - } + pub(crate) fn has_rule(rule_name: &str) -> bool { Self::CATEGORY_RULES.contains(&rule_name) } #[doc = r" Checks if, given a rule name, it is marked as recommended"] pub(crate) fn is_recommended_rule(rule_name: &str) -> bool { Self::RECOMMENDED_RULES.contains(&rule_name) } - pub(crate) fn recommended_rules_as_filters() -> [RuleFilter<'static>; 29] { + pub(crate) fn recommended_rules_as_filters() -> [RuleFilter<'static>; 30] { Self::RECOMMENDED_RULES_AS_FILTERS } } @@ -1000,9 +987,7 @@ impl Performance { const RECOMMENDED_RULES: [&'static str; 1] = ["noDelete"]; const RECOMMENDED_RULES_AS_FILTERS: [RuleFilter<'static>; 1] = [RuleFilter::Rule("performance", Self::CATEGORY_RULES[0])]; - pub(crate) fn is_recommended(&self) -> bool { - !matches!(self.recommended, Some(false)) - } + pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) } pub(crate) fn get_enabled_rules(&self) -> IndexSet { IndexSet::from_iter(self.rules.iter().filter_map(|(key, conf)| { if conf.is_enabled() { @@ -1022,9 +1007,7 @@ impl Performance { })) } #[doc = r" Checks if, given a rule name, matches one of the rules contained in this category"] - pub(crate) fn has_rule(rule_name: &str) -> bool { - Self::CATEGORY_RULES.contains(&rule_name) - } + pub(crate) fn has_rule(rule_name: &str) -> bool { Self::CATEGORY_RULES.contains(&rule_name) } #[doc = r" Checks if, given a rule name, it is marked as recommended"] pub(crate) fn is_recommended_rule(rule_name: &str) -> bool { Self::RECOMMENDED_RULES.contains(&rule_name) @@ -1092,9 +1075,7 @@ impl Security { RuleFilter::Rule("security", Self::CATEGORY_RULES[0]), RuleFilter::Rule("security", Self::CATEGORY_RULES[1]), ]; - pub(crate) fn is_recommended(&self) -> bool { - !matches!(self.recommended, Some(false)) - } + pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) } pub(crate) fn get_enabled_rules(&self) -> IndexSet { IndexSet::from_iter(self.rules.iter().filter_map(|(key, conf)| { if conf.is_enabled() { @@ -1114,9 +1095,7 @@ impl Security { })) } #[doc = r" Checks if, given a rule name, matches one of the rules contained in this category"] - pub(crate) fn has_rule(rule_name: &str) -> bool { - Self::CATEGORY_RULES.contains(&rule_name) - } + pub(crate) fn has_rule(rule_name: &str) -> bool { Self::CATEGORY_RULES.contains(&rule_name) } #[doc = r" Checks if, given a rule name, it is marked as recommended"] pub(crate) fn is_recommended_rule(rule_name: &str) -> bool { Self::RECOMMENDED_RULES.contains(&rule_name) @@ -1225,9 +1204,7 @@ impl Style { RuleFilter::Rule("style", Self::CATEGORY_RULES[11]), RuleFilter::Rule("style", Self::CATEGORY_RULES[12]), ]; - pub(crate) fn is_recommended(&self) -> bool { - !matches!(self.recommended, Some(false)) - } + pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) } pub(crate) fn get_enabled_rules(&self) -> IndexSet { IndexSet::from_iter(self.rules.iter().filter_map(|(key, conf)| { if conf.is_enabled() { @@ -1247,9 +1224,7 @@ impl Style { })) } #[doc = r" Checks if, given a rule name, matches one of the rules contained in this category"] - pub(crate) fn has_rule(rule_name: &str) -> bool { - Self::CATEGORY_RULES.contains(&rule_name) - } + pub(crate) fn has_rule(rule_name: &str) -> bool { Self::CATEGORY_RULES.contains(&rule_name) } #[doc = r" Checks if, given a rule name, it is marked as recommended"] pub(crate) fn is_recommended_rule(rule_name: &str) -> bool { Self::RECOMMENDED_RULES.contains(&rule_name) @@ -1387,9 +1362,7 @@ impl Suspicious { RuleFilter::Rule("suspicious", Self::CATEGORY_RULES[14]), RuleFilter::Rule("suspicious", Self::CATEGORY_RULES[15]), ]; - pub(crate) fn is_recommended(&self) -> bool { - !matches!(self.recommended, Some(false)) - } + pub(crate) fn is_recommended(&self) -> bool { !matches!(self.recommended, Some(false)) } pub(crate) fn get_enabled_rules(&self) -> IndexSet { IndexSet::from_iter(self.rules.iter().filter_map(|(key, conf)| { if conf.is_enabled() { @@ -1409,9 +1382,7 @@ impl Suspicious { })) } #[doc = r" Checks if, given a rule name, matches one of the rules contained in this category"] - pub(crate) fn has_rule(rule_name: &str) -> bool { - Self::CATEGORY_RULES.contains(&rule_name) - } + pub(crate) fn has_rule(rule_name: &str) -> bool { Self::CATEGORY_RULES.contains(&rule_name) } #[doc = r" Checks if, given a rule name, it is marked as recommended"] pub(crate) fn is_recommended_rule(rule_name: &str) -> bool { Self::RECOMMENDED_RULES.contains(&rule_name)