djlint / djLint

✨ HTML Template Linter and Formatter. Django - Jinja - Nunjucks - Handlebars - GoLang
https://djLint.com
GNU General Public License v3.0
686 stars 84 forks source link

[BUG] [Linter] H006 false positive when width, height set via CSS class #821

Open OscarVanL opened 7 months ago

OscarVanL commented 7 months ago

System Info

Issue

There is a false positive for H006: Img tag should have height and width attributes when these are set via a CSS class.

How To Reproduce

Style an image's size via a CSS tag:

<!DOCTYPE HTML>
<html lang="en">

<head>
<style type="text/css">
.logo-img {
        width: 161px;
        height: 41px;
    }
</style>
</head>

<body>
<img class="logo-img" src="{{ foo_logo }}"/>
</body>
</html>

The linter will fail with H006 incorrectly.

Contents of .djlintrc/pyproject.toml [tool.djlint]

[tool.djlint]
ignore="T002,T003,H021,H029,H030,H031"