It’s not the value of the attribute role='img' that triggers Sonar, it’s the single quotes around the value in your example. When you replace the single quotes with double quotes (role="img"), the issue goes away.
That’s what the error message means:
Attribute charset must use " instead of ' .
So the real false positive is that Sonar flags single quotes that are used as attribute value delimiters, something that the HTML specification perfectly allows.
That’s not my experience. For me, the S6819 error is reported regardless of quote style.
I also don’t see the charset error message you mention (which wouldn’t make sense anyway since my code sample used double quotes for the charset property). I wonder if there was a copy-paste error when you tested my code?
The following code uses double quotes and reproduces the false positive:
With VS Code 1.89.1 and SonarLint v4.5.1, I don’t get a false positive, regardless of attribute syntax (role="img", role='img' or role=img).
In VSCodium, I get a warning for role='img' and role=img, but I now notice that this error is not generated by SonarLint but by the extension HTML-validate.
But whatever the cause of these results, role=img is a correct attribute.