Static AST checker for accessibility rules on elements in .vue.
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-vue-a11y
:
$ npm install eslint-plugin-vue-a11y --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-vue-a11y
globally.
Add vue-a11y
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{ "plugins": [ "vue-a11y" ] }
Then configure the rules you want to use under the rules section.
{ "rules": { "vue-a11y/rule-name": 2 } }
also You can enable all the base rules at once. Add plugin:vue-a11y/base
in extends
:
{ "extends": [ "plugin:vue-a11y/base" ] }
<span>
, giving it the role="img"
, and providing a useful description in aria-label
<label>
elements nesting input and has id for it .onMouseOver
/onMouseOut
are accompanied by onFocus
/onBlur
for keyboard-only users.onBlur
over onChange
on select menus for accessibility.<marquee>
and <blink>
.h1
, h2
, etc.) have content and that the content is accessible to screen readers. Accessible means that it is not hidden using the aria-hidden
prop. Refer to the references to learn about why this is important.<iframe>
elements must have a unique title property to indicate its content to the user.The most rules of eslint-plugin-vue-a11y
require vue-eslint-parser
to check <template>
ASTs.
Make sure you have one of the following settings in your .eslintrc:
"extends": ["plugin:vue-a11y/recommended"]
"extends": ["plugin:vue-a11y/base"]
If you already use other parser (e.g. "parser": "babel-eslint"
), please move it into parserOptions
, so it doesn't collide with the vue-eslint-parser
used by this plugin's configuration:
- "parser": "babel-eslint", "parserOptions": { + "parser": "babel-eslint", "ecmaVersion": 2018, "sourceType": "module" }Why doesn't it work on .vue file?
eslint-plugin-html
in your config. The eslint-plugin-html
extracts the content from <script>
tags, but eslint-vue-plugin
requires <script>
tags and <template>
tags in order to distinguish template and script in single file components."plugins": [ "vue", - "html" ]eslint-disable functionality in
<template>
?
<template> <!-- eslint-disable-next-line vue-a11y/anchor-has-content --> <a></a> <h1></h1> <!-- eslint-disable-line --> </template>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4