From eaaf945301b962634542008922977db3a5840385 Mon Sep 17 00:00:00 2001 From: Muhammad Hamza Date: Sat, 24 Sep 2022 19:23:58 +0500 Subject: [PATCH 1/5] Add compiler flag for Yew lints --- packages/yew-macro/src/html_tree/lint/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/yew-macro/src/html_tree/lint/mod.rs b/packages/yew-macro/src/html_tree/lint/mod.rs index 77fd51d96a3..f925f3a15ef 100644 --- a/packages/yew-macro/src/html_tree/lint/mod.rs +++ b/packages/yew-macro/src/html_tree/lint/mod.rs @@ -26,6 +26,9 @@ pub fn lint(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 { From bcc3a429d544c2bef38e160fbf2392242b38a351 Mon Sep 17 00:00:00 2001 From: Muhammad Hamza Date: Sat, 24 Sep 2022 19:49:34 +0500 Subject: [PATCH 2/5] Use --cfg yew_lints in CI --- .github/workflows/main-checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main-checks.yml b/.github/workflows/main-checks.yml index 66fc8b43d71..41645bda148 100644 --- a/.github/workflows/main-checks.yml +++ b/.github/workflows/main-checks.yml @@ -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 From ca43884253ef2699650b48d662f6dff10658dcf4 Mon Sep 17 00:00:00 2001 From: Muhammad Hamza Date: Sat, 24 Sep 2022 19:57:49 +0500 Subject: [PATCH 3/5] Remove lints feature --- packages/yew-macro/Cargo.toml | 5 ----- packages/yew-macro/tests/html_lints_test.rs | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/yew-macro/Cargo.toml b/packages/yew-macro/Cargo.toml index 51d3adccfe2..d9eef17b6a3 100644 --- a/packages/yew-macro/Cargo.toml +++ b/packages/yew-macro/Cargo.toml @@ -29,8 +29,3 @@ prettyplease = "0.1.1" rustversion = "1" trybuild = "1" yew = { path = "../yew" } - -[build-dependencies] - -[features] -lints = [] diff --git a/packages/yew-macro/tests/html_lints_test.rs b/packages/yew-macro/tests/html_lints_test.rs index af71e2d826f..35ba0496c6d 100644 --- a/packages/yew-macro/tests/html_lints_test.rs +++ b/packages/yew-macro/tests/html_lints_test.rs @@ -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(); From f293288ad97c035d6e4c00c6a005fb646b31856d Mon Sep 17 00:00:00 2001 From: Muhammad Hamza Date: Sat, 24 Sep 2022 20:00:42 +0500 Subject: [PATCH 4/5] bless the fail.stderr --- .../yew-macro/tests/html_lints/fail.stderr | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/packages/yew-macro/tests/html_lints/fail.stderr b/packages/yew-macro/tests/html_lints/fail.stderr index 54698329b1d..64551afcdc0 100644 --- a/packages/yew-macro/tests/html_lints/fail.stderr +++ b/packages/yew-macro/tests/html_lints/fail.stderr @@ -1,27 +1,3 @@ -warning: All `` 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 | { "I don't have a href attribute" } - | ^ - -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 | { "I have a malformed href attribute" } - | ^^^ - -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 | { "I have a malformed href attribute" } - | ^^^^^^^^^^^^^^^^^^^^ - -warning: All `` tags should have an `alt` attribute which provides a human-readable description - --> tests/html_lints/fail.rs:14:10 - | -14 | - | ^^^ - 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 | From faf477a1bc945b420b9eeb08652b4d302c188d24 Mon Sep 17 00:00:00 2001 From: Muhammad Hamza Date: Sun, 25 Sep 2022 00:24:58 +0500 Subject: [PATCH 5/5] Fix CI --- .github/workflows/main-checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main-checks.yml b/.github/workflows/main-checks.yml index 41645bda148..bcf986342e3 100644 --- a/.github/workflows/main-checks.yml +++ b/.github/workflows/main-checks.yml @@ -219,4 +219,4 @@ jobs: 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