jsx-eslint / eslint-plugin-jsx-a11y

Static AST checker for a11y rules on JSX elements.
MIT License
3.38k stars 637 forks source link

Eslint "control-has-associated-label" error on non-label tag #996

Closed ashtonisher closed 1 month ago

ashtonisher commented 1 month ago

Inappropriate eslint error

There's no

I think this comes from " "part, but i have to use   or empty space ' ' in thtag cause of layout. And also there's no label in this code!

Is this bug ? or can i fix this?

<table>
      <thead>
          <tr>
              <th>&nbsp;</th> /* no content. just for table layout */
              <th>content</th>
              <th>price</th>
          </tr>
      </thead>
      <tbody>
          <tr>
              <td>
                <img src="icon.png" alt="" />
              </td>
              <td>content1</td>
              <td>content2</td>
          </tr>
     </tbody>
</table>
ljharb commented 1 month ago

This is a duplicate of #959. When I take a look at it, I'll include your repro code.