-
Notifications
You must be signed in to change notification settings - Fork 144
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 a lint plugin for detecting common anti-patterns #66
Comments
thus elements that contains empty tags like id="" or class="" could be removed to minimize html size |
@ernestas-poskus that can be extended to other attributes like |
sure, all empty tags could be removed |
Not all of them. |
I have started improving the lint plugin on the better-lints branch. When I'm done, the proc macro will use compile-time "markers" to communicate the structure of the original template to the lint plugin. |
#127 🎉 |
This issue has become a bit of a laundry list of suggestions. It's unclear how half of these can be implemented on stable (given that third-party lints are so far away) and the tractable stuff has already been split out (e.g. #181). So I'm going to close this as wontfix. |
We can lint these things:
Use
maud::DOCTYPE
instead ofPreEscaped("<!DOCTYPE html>")
Rather than writing
output.push_str(&html! { ... }.into_string())
, just implement therender
method insteadUse
format_args!
(or list the values individually) instead offormat!
The following lints inspect the structure of the template itself. It's not clear yet how they can be implemented under the current design. We'll probably need to do some refactoring before these can work.
Use
.foo
instead ofclass="foo"
, and#foo
instead ofid="foo"
.foo[bar]
instead ofclass=@if bar { "foo" }
Warn against
a target="..."
withoutrel="noopener"
Warn against dynamic data in CSS and JS contexts, e.g.
script { "var name = '" (user.name) "'" }
Warn about non-standard elements and attributes
Further suggestions welcome!
The text was updated successfully, but these errors were encountered: