mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Make Yew lints opt-in (#2882)
* Add compiler flag for Yew lints * Use --cfg yew_lints in CI * Remove lints feature * bless the fail.stderr * Fix CI
This commit is contained in:
parent
7e24fb3c58
commit
9e0d7966bc
4
.github/workflows/main-checks.yml
vendored
4
.github/workflows/main-checks.yml
vendored
@ -216,7 +216,7 @@ jobs:
|
||||
- name: Run tests
|
||||
uses: actions-rs/cargo@v1
|
||||
env:
|
||||
RUSTFLAGS: --cfg nightly_yew
|
||||
RUSTFLAGS: --cfg nightly_yew --cfg yew_lints
|
||||
with:
|
||||
command: test
|
||||
args: -p yew-macro test_html_lints --features lints
|
||||
args: -p yew-macro test_html_lints
|
||||
|
||||
@ -29,8 +29,3 @@ prettyplease = "0.1.1"
|
||||
rustversion = "1"
|
||||
trybuild = "1"
|
||||
yew = { path = "../yew" }
|
||||
|
||||
[build-dependencies]
|
||||
|
||||
[features]
|
||||
lints = []
|
||||
|
||||
@ -26,6 +26,9 @@ pub fn lint<L>(tree: &HtmlTree)
|
||||
where
|
||||
L: Lint,
|
||||
{
|
||||
#[cfg(not(yew_lints))]
|
||||
let _ = tree;
|
||||
#[cfg(yew_lints)]
|
||||
match tree {
|
||||
HtmlTree::List(list) => {
|
||||
for child in &list.children.0 {
|
||||
|
||||
@ -1,27 +1,3 @@
|
||||
warning: All `<a>` elements should have a `href` attribute. This makes it possible for assistive technologies to correctly interpret what your links point to. https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML#more_on_links
|
||||
--> tests/html_lints/fail.rs:5:10
|
||||
|
|
||||
5 | <a>{ "I don't have a href attribute" }</a>
|
||||
| ^
|
||||
|
||||
warning: '#' is not a suitable value for the `href` attribute. Without a meaningful attribute assistive technologies will struggle to understand your webpage. https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML#onclick_events
|
||||
--> tests/html_lints/fail.rs:8:17
|
||||
|
|
||||
8 | <a href="#">{ "I have a malformed href attribute" }</a>
|
||||
| ^^^
|
||||
|
||||
warning: 'javascript:void(0)' is not a suitable value for the `href` attribute. Without a meaningful attribute assistive technologies will struggle to understand your webpage. https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML#onclick_events
|
||||
--> tests/html_lints/fail.rs:11:17
|
||||
|
|
||||
11 | <a href="javascript:void(0)">{ "I have a malformed href attribute" }</a>
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: All `<img>` tags should have an `alt` attribute which provides a human-readable description
|
||||
--> tests/html_lints/fail.rs:14:10
|
||||
|
|
||||
14 | <img src="img.jpeg"/>
|
||||
| ^^^
|
||||
|
||||
warning: The tag 'tExTAreA' is not matching its normalized form 'textarea'. If you want to keep this form, change this to a dynamic tag `@{"tExTAreA"}`.
|
||||
--> tests/html_lints/fail.rs:17:10
|
||||
|
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#[allow(dead_code)]
|
||||
#[cfg(feature = "lints")]
|
||||
#[cfg(yew_lints)]
|
||||
#[rustversion::attr(nightly, test)]
|
||||
fn test_html_lints() {
|
||||
let t = trybuild::TestCases::new();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user