GitHub - maranran/eslint-plugin-vue-a11y: Static AST checker for accessibility rules on elements in .vue (original) (raw)

eslint-plugin-vue-a11y

Static AST checker for accessibility rules on elements in .vue.

Installation

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.

Usage

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" ] }

base Supported Rules

👫 FAQ

What is the "Use the latest vue-eslint-parser" error?

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:

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:

Why doesn't it work on .vue file?

  1. Make sure you don't have 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",

eslint-disable functionality in <template> ?

  1. Make sure you have used eslint-plugin-vue and you can use like HTML comments in of .vue files. For example: