Skip to content

Commit

Permalink
fix: fix lint suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiyamaorange committed Jun 2, 2024
1 parent cd6124b commit 207c4f4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2,215 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b
- Add [nursery/useGenericFontNames](https://biomejs.dev/linter/rules/use-generic-font-names). [#2573](https://github.com/biomejs/biome/pull/2573) Contributed by @togami2864
- Add [nursery/noYodaExpression](https://biomejs.dev/linter/rules/no-yoda-expression/). Contributed by @michellocana
- Add [nursery/noUnusedFunctionParameters](https://biomejs.dev/linter/rules/no-unused-function-parameters/) Contributed by @printfn
- Add [nursery/UseSemanticElements](https://biomejs.dev/linter/rules/use-semantic-elements/). Contributed by @fujiyamaorange
#### Enhancements
Expand Down
17 changes: 10 additions & 7 deletions crates/biome_js_analyze/src/lint/nursery/use_semantic_elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use biome_analyze::{context::RuleContext, declare_rule, Rule, RuleDiagnostic, Ru
use biome_aria::AriaRoles;
use biome_console::markup;
use biome_js_syntax::{JsxAttribute, JsxOpeningElement};
use biome_rowan::TextRange;

use crate::services::aria::Aria;

Expand Down Expand Up @@ -112,18 +113,20 @@ impl Rule for UseSemanticElements {
}
}

let span = TextRange::new(
role_attribute.name_value_token()?.text_range().start(),
role_attribute.as_static_value()?.range().end(),
);

Some(
RuleDiagnostic::new(
rule_category!(),
role_attribute.name_value_token()?.text_range(),
span,
error_message,
)
.footer_list(
markup! {
"For examples and more information, see " <Hyperlink href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles">"WAI-ARIA Roles"</Hyperlink>
},
&["<button>", "<input>", "<textarea>", "<a>", "<img>", "<table>", "<article>", "<section>", "<nav>", "<aside>", "<header>", "<footer>", "<main>", "<figure>", "<figcaption>", "<details>", "<summary>", "<dialog>", "<menu>", "<menuitem>", "<fieldset>", "<legend>", "<caption>", "<colgroup>", "<col>", "<optgroup>", "<option>", "<select>", "<datalist>", "<output>", "<progress>", "<meter>", "<time>", "<audio>", "<video>", "<track>", "<source>", "<embed>", "<object>", "<param>", "<iframe>", "<canvas>", "<map>", "<area>", "<svg>", "<math>"]
),
.note(markup! {
"For examples and more information, see " <Hyperlink href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles">"WAI-ARIA Roles"</Hyperlink>
}),
)
}
}
Loading

0 comments on commit 207c4f4

Please sign in to comment.