Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic lints to the HTML macro. #1748

Merged
merged 11 commits into from
Nov 21, 2021

Conversation

teymour-aldridge
Copy link
Contributor

@teymour-aldridge teymour-aldridge commented Feb 17, 2021

This adds some basic accessibility-related lints to the HTML macro.

(Part of) #1334

  • I have run cargo make pr-flow
  • I have reviewed my own code
  • I have added tests

@teymour-aldridge
Copy link
Contributor Author

I thought I'd broken something, but this seems to be failing in other pull requests as well :D

@github-actions
Copy link

github-actions bot commented Feb 17, 2021

Visit the preview URL for this PR (updated for commit bfcb04c):

https://yew-rs--pr1748-alt-text-lint-efwbd9d4.web.app

(expires Sun, 28 Nov 2021 13:04:21 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@teymour-aldridge
Copy link
Contributor Author

I'm also confused about the unit tests because they work on my local machine (with the identical toolchain).

Copy link
Member

@siku2 siku2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is amazing!

packages/yew-macro/src/lib.rs Outdated Show resolved Hide resolved
packages/yew-macro/src/html_tree/html_block.rs Outdated Show resolved Hide resolved
packages/yew-macro/src/html_tree/lint/mod.rs Outdated Show resolved Hide resolved
@siku2 siku2 added the macro Issues relating to our procedural or declarative macros label Feb 18, 2021
@siku2
Copy link
Member

siku2 commented Feb 18, 2021

Did you manage to gather some feedback yet?

@teymour-aldridge
Copy link
Contributor Author

Working on it :D

@teymour-aldridge
Copy link
Contributor Author

This is amazing!

Thanks 😊

Copy link
Member

@siku2 siku2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from these relatively small issues I think this initial version is ready to be merged

packages/yew-macro/src/html_tree/html_dashed_name.rs Outdated Show resolved Hide resolved
.github/workflows/pull-request.yml Outdated Show resolved Hide resolved
packages/yew-macro/tests/html_macro_test.rs Outdated Show resolved Hide resolved
packages/yew-macro/src/html_tree/lint/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@ranile ranile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lints look great

packages/yew-macro/src/html_tree/lint/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@lukechu10 lukechu10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really excited for those!

ci/dictionary.txt Outdated Show resolved Hide resolved

fn main() {
let bad_a = html! {
<a>{"I don't have a href attribute"}</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think the official style used by Yew has spaces between the { and the quotes (e.g. <a>{ "I don't have a href attribute" }</a>. Although #1774 would make this redundant.

@teymour-aldridge
Copy link
Contributor Author

This should be ready for another review :D

Copy link
Contributor

@mc1098 mc1098 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, can't wait to see what other lints could spring from these!
Hope the review helps :)

packages/yew-macro/src/html_tree/lint/mod.rs Outdated Show resolved Hide resolved
packages/yew-macro/src/html_tree/lint/mod.rs Outdated Show resolved Hide resolved
@mc1098 mc1098 added the A-yew-macro Area: The yew-macro crate label Sep 20, 2021
@mc1098 mc1098 linked an issue Sep 25, 2021 that may be closed by this pull request
3 tasks
@mc1098
Copy link
Contributor

mc1098 commented Sep 25, 2021

As mentioned in #1334 this is not considered blocked - @teymour-aldridge I know you mentioned about lack of reviewing power but I'm ready and able :)
Resolve the conflicts and ping me and it will be on the top of my review list ❤️

@mc1098 mc1098 added the S-waiting-on-author Status: awaiting action from the author of the issue/PR label Sep 25, 2021
@voidpumpkin voidpumpkin removed the S-waiting-on-author Status: awaiting action from the author of the issue/PR label Nov 20, 2021
@voidpumpkin
Copy link
Member

I had to make yew_router::Link accept queries with this update to the PR but all works now

voidpumpkin
voidpumpkin previously approved these changes Nov 20, 2021
Copy link
Contributor

@mc1098 mc1098 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit-picks from me 🙃

I generally would prefer seeing the router changes in a different PR - seems odd to stick them in a PR adding lints.

examples/router/src/main.rs Outdated Show resolved Hide resolved
examples/router/src/main.rs Outdated Show resolved Hide resolved
packages/yew-router/src/components/link.rs Outdated Show resolved Hide resolved
Copy link
Member

@ranile ranile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also console.warn these lints at runtime when compiled in debug mode? That way, people who don't use nightly will also be able to see the warnings

.github/workflows/pull-request.yml Outdated Show resolved Hide resolved
packages/yew-macro/Makefile.toml Outdated Show resolved Hide resolved
packages/yew-macro/src/html_tree/lint/mod.rs Show resolved Hide resolved
packages/yew-macro/src/html_tree/lint/mod.rs Outdated Show resolved Hide resolved
Comment on lines 66 to 68
"'#' is not a suitable value for the `href` attribute. \
Without a meaningful attribute assistive technologies \
will struggle to understand your webpage."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we link to documentation or add help information like clippy or cargo check do? A link to docs about ARIA roles would be nice to have

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added simple links to https://developer.mozilla.org/en-US/docs/Learn/Accessibility/HTML#onclick_events but i think in the future this can be improved upon

packages/yew-macro/tests/html_lints/fail.rs Outdated Show resolved Hide resolved
@voidpumpkin
Copy link
Member

Can we also console.warn these lints at runtime when compiled in debug mode? That way, people who don't use nightly will also be able to see the warnings

@hamza1311 Since this PR was not my initial idea, i would prefer to merge what we have now, and if you want you can improve it later by making it log to console.warn

@voidpumpkin voidpumpkin enabled auto-merge (squash) November 21, 2021 14:23
@voidpumpkin voidpumpkin merged commit 7e2542c into yewstack:master Nov 21, 2021
@NickHu
Copy link

NickHu commented Dec 22, 2021

Is there any way to opt out of certain lints, like for clippy we have #[allow(clippy::...)]?

@ranile
Copy link
Member

ranile commented Dec 22, 2021

Is there any way to opt out of certain lints, like for clippy we have #[allow(clippy::...)]?

No, not right now.

Also, it would be better if you comment on the tracking issue instead of this already merged PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew-macro Area: The yew-macro crate macro Issues relating to our procedural or declarative macros
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants