Skip to content

Add a lint plugin for detecting common anti-patterns #66

@lambda-fairy

Description

@lambda-fairy

We can lint these things:

  • Use maud::DOCTYPE instead of PreEscaped("<!DOCTYPE html>")

  • Rather than writing output.push_str(&html! { ... }.into_string()), just implement the render method instead

  • Use format_args! (or list the values individually) instead of format!

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 of class="foo", and #foo instead of id="foo"

    • Use .foo[bar] instead of class=@if bar { "foo" }
  • Warn against a target="..." without rel="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!

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions