-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rule to check if the lang
attribute is used on html
element
#45
Conversation
report: sinon.spy() | ||
}; | ||
|
||
const window = await getDOM(path.join(__dirname, 'fixtures', filePath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@molant IMHO, having the fixtures right next to the test file is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I was thinking yesterday while doing some tests. I'll refactor the other ones today.
@@ -74,7 +74,7 @@ export class RuleContext { | |||
this.id, | |||
this.severity, | |||
descriptor, | |||
location, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a leftover from when the "find element" related refactoring was done.
|
||
import { Rule, RuleBuilder, ElementFoundEvent } from '../../../../lib/types'; // eslint-disable-line no-unused-vars | ||
|
||
const getDOM = async (filePath) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@molant This will probably go into a separate file as it will be needed in a few places.
* Add index page in each folder according to #45 * A PR will be submitted in sonarwhal to process the index pages
* Add index page in each folder according to #45 * Another PR is submitted in sonarwhal to process the index pages
Rule Details
This rule warns against not using the
lang
attribute on thehtml
element, or using it on thehtml
element but with the value of empty string.It's indicated to always set the
lang
attribute on thehtml
element so that it's inherited by all other elements (even the ones in the<head>
), and it sets the primary language of the document.Setting the
lang
attribute provides an explicit indicate to user agents about the language of the content, which can help, among other:screen readers and similar assistive technologies with voice output and pronunciation of content using the correct voice/language library
determine the appropriate language dictionary, the types of quotation marks for
q
elements, the styling such as the one for hyphenation, case conversion, line-breaking, and spell-checkingfont selection where different alphabets are mixed
improve localization (e.g. what numeric software keyboard will be opened for
<input type="number">
)Resources
Note: This rule does not check if the value of the
lang
attribute is valid or not (that will be covered by a different rule).Close #16