Skip to content

Commit

Permalink
apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Oct 1, 2024
1 parent 640a728 commit f723737
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 29 deletions.
12 changes: 6 additions & 6 deletions crates/biome_analyze/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ use biome_deserialize_macros::Deserializable;
#[derive(Clone, Debug, Default, Deserializable)]
pub struct MyRuleOptions {
behavior: Option<Behavior>,
threshold: Option<u8>,
behavior_exceptions: Option<Vec<String>>
behavior: Behavior,
threshold: u8,
behavior_exceptions: Vec<String>
}
#[derive(Clone, Debug, Default, Deserializable)]
Expand Down Expand Up @@ -212,13 +212,13 @@ You can simply use a derive macros:
```rust
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
pub struct MyRuleOptions {
#[serde(default, skip_serializing_if = "is_default")]
main_behavior: Option<Behavior>,
main_behavior: Behavior,
#[serde(default, skip_serializing_if = "is_default")]
extra_behaviors: Option<Vec<Behavior>>,
extra_behaviors: Vec<Behavior>,
}
#[derive(Debug, Default, Clone)]
Expand Down
26 changes: 9 additions & 17 deletions crates/biome_js_analyze/src/lint/a11y/no_label_without_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ impl Rule for NoLabelWithoutControl {
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
pub struct NoLabelWithoutControlOptions {
/// Array of component names that should be considered the same as an `input` element.
pub input_components: Option<Vec<String>>,
pub input_components: Vec<String>,
/// Array of attributes that should be treated as the `label` accessible text content.
pub label_attributes: Option<Vec<String>>,
pub label_attributes: Vec<String>,
/// Array of component names that should be considered the same as a `label` element.
pub label_components: Option<Vec<String>>,
pub label_components: Vec<String>,
}

impl NoLabelWithoutControlOptions {
Expand All @@ -174,10 +174,8 @@ impl NoLabelWithoutControlOptions {
if !DEFAULT_LABEL_ATTRIBUTES.contains(&attribute_name)
&& !self
.label_attributes
.as_ref()
.is_some_and(|label_attributes| {
label_attributes.iter().any(|name| name == attribute_name)
})
.iter()
.any(|name| name == attribute_name)
{
return false;
}
Expand Down Expand Up @@ -246,10 +244,8 @@ impl NoLabelWithoutControlOptions {
if DEFAULT_INPUT_COMPONENTS.contains(&element_name)
|| self
.input_components
.as_ref()
.is_some_and(|input_components| {
input_components.iter().any(|name| name == element_name)
})
.iter()
.any(|name| name == element_name)
{
return true;
}
Expand All @@ -263,12 +259,8 @@ impl NoLabelWithoutControlOptions {

fn has_element_name(&self, element_name: &str) -> bool {
self.label_components
.as_ref()
.is_some_and(|label_components| {
label_components
.iter()
.any(|label_component_name| label_component_name == element_name)
})
.iter()
.any(|label_component_name| label_component_name == element_name)
}
}

Expand Down
12 changes: 6 additions & 6 deletions packages/@biomejs/biome/configuration_schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f723737

Please sign in to comment.