Create rule S6849: HTML elements should have a valid language attribute (#3439)
This commit is contained in:
parent
c8c52e8716
commit
05040d20fe
25
rules/S6849/javascript/metadata.json
Normal file
25
rules/S6849/javascript/metadata.json
Normal 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"
|
||||
}
|
||||
}
|
29
rules/S6849/javascript/rule.adoc
Normal file
29
rules/S6849/javascript/rule.adoc
Normal 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]
|
2
rules/S6849/metadata.json
Normal file
2
rules/S6849/metadata.json
Normal file
@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user