djLint icon indicating copy to clipboard operation
djLint copied to clipboard

[BUG] [Linter]Space before '=' sign following `id` or `class` thinks the value is "empty" and gives `(H026)`

Open ssteinerx opened this issue 11 months ago • 0 comments

System Info

  • OS: ubuntu 23.04
  • Python Version: 3.12.2
  • djLint Version: 1.34.1
  • template language: jinja

Issue

Empty id and class tags can be removed. (H026) is generated if there's a space between id or class and the = sign.

A space before the attribute value has no effect. The spec says "zero or more spaces" between the attribute and the = sign. The only restriction after the = is for unquoted values which may not contain a space e.g. <div id=foo> vs <div id= foo> where the second is invalid as it attempts to have a space within the id's value.

   <div id="foo"></div>  <!-- no space, no error -->
    <div id ="foo"></div> <!-- space before '=', error -->

How To Reproduce

Put the code above somewhere, run djlint on it.

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

none

ssteinerx avatar Feb 26 '24 07:02 ssteinerx