Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added SVGLint * Added SVGLint to CI * Upgraded Node version used by CI * Upgraded SVGLint to latest version * Moved SVGLint configuration file * Upgraded SVGLint 1.0.1 -> 1.0.2 Adds support for globs on Windows * Added SVGLint check for aria-labelledby and title ID
- Loading branch information
1 parent
7d037d9
commit 289d188
Showing
4 changed files
with
941 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module.exports = { | ||
rules: { | ||
elm: { | ||
"svg": 1, | ||
"svg > title": 1, | ||
"g": false, | ||
}, | ||
attr: [ | ||
{ // ensure that the SVG elm has the appropriate attrs | ||
"aria-labelledby": /^simpleicons-.+-icon$/, | ||
"role": "img", | ||
"viewBox": "0 0 24 24", | ||
"xmlns": "http://www.w3.org/2000/svg", | ||
|
||
"rule::selector": "svg", | ||
"rule::whitelist": true, | ||
}, | ||
{ // ensure that the title elm has the appropriate attr | ||
"id": /^simpleicons-.+-icon$/, | ||
|
||
"rule::selector": "svg > title", | ||
"rule::whitelist": true, | ||
} | ||
], | ||
custom: [ | ||
// ensure that aria-labelledby and id match | ||
function checkValidAria(reporter, $, ast) { | ||
const labelledByValue = $.find("svg").attr("aria-labelledby"); | ||
const $title = $.find("svg > title"); | ||
const titleIdValue = $title.attr("id"); | ||
if (labelledByValue !== titleIdValue) { | ||
reporter.error( | ||
`'aria-labelledby' and 'id' should match, were '${labelledByValue}' and '${titleIdValue}'`, | ||
$title[0], | ||
ast | ||
); | ||
} | ||
} | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.