Create rule S6849: HTML elements should have a valid language attribute (#3439)

This commit is contained in:
github-actions[bot] 2023-11-15 09:47:49 +01:00 committed by GitHub
parent c8c52e8716
commit 05040d20fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,25 @@
{
"title": "HTML elements should have a valid language attribute",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
},
"tags": [
"accessibility",
"react"
],
"defaultSeverity": "Minor",
"ruleSpecification": "RSPEC-6849",
"sqKey": "S6849",
"scope": "All",
"defaultQualityProfiles": ["Sonar way"],
"quickfix": "targeted",
"code": {
"impacts": {
"RELIABILITY": "MEDIUM"
},
"attribute": "LOGICAL"
}
}

View File

@ -0,0 +1,29 @@
HTML documents should have a valid IETF's BCP 47 `lang` attribute.
== Why is this an issue?
Screen readers require a specified language to function correctly. Without it, they default to the user's set language, causing issues for multilingual users. Specifying a valid language ensures correct pronunciation and a less confusing experience.
== How to fix it
Add a `lang` attribute with a valid IETF BCP 47 value.
=== Code examples
==== Noncompliant code example
[source,html,diff-id=1,diff-type=noncompliant]
----
<html></html>
----
==== Compliant solution
[source,html,diff-id=1,diff-type=compliant]
----
<html lang="en"></html>
----
== Resources
=== Documentation
* W3C, https://www.w3.org/International/articles/language-tags/[Language tags in HTML and XML]

View File

@ -0,0 +1,2 @@
{
}