npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-vue-a11y

v0.0.31

Published

Static AST checker for accessibility rules on elements in .vue

Downloads

15,093

Readme

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

  • accessible-emoji: wrapping the emoji in a <span>, giving it the role="img", and providing a useful description in aria-label
  • alt-text: Enforce all elements that require alternative text have meaningful information to relay back to end user.
  • anchor-has-content: Enforce all anchors to contain accessible content.
  • click-events-have-key-events: Enforce a clickable non-interactive element has at least one keyboard event listener.
  • label-has-for: Enforce that <label> elements nesting input and has id for it .
  • mouse-events-have-key-events: Enforce that onMouseOver/onMouseOut are accompanied by onFocus/onBlur for keyboard-only users.
  • no-autofocus: Enforce autoFocus prop is not used.
  • no-onchange: Enforce usage of onBlur over onChange on select menus for accessibility.
  • tabindex-no-positive: Avoid positive tabIndex property values to synchronize the flow of the page with keyboard tab order.
  • no-distracting-elements: Enforces that no distracting elements are used. Elements that can be visually distracting can cause accessibility issues with visually impaired users. Such elements are most likely deprecated, and should be avoided. By default, the following elements are visually distracting: <marquee> and <blink>.
  • heading-has-content: Enforce that heading elements (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.
  • media-has-caption: Providing captions for media is essential for deaf users to follow along. Captions should be a transcription or translation of the dialogue, sound effects, relevant musical cues, and other relevant audio information.
  • iframe-has-title: <iframe> elements must have a unique title property to indicate its content to the user.
  • no-access-key: Enforce no accessKey prop on element. Access keys are HTML attributes that allow web developers to assign keyboard shortcuts to elements. Inconsistencies between keyboard shortcuts and keyboard commands used by screenreader and keyboard only users create accessibility complications so to avoid complications, access keys should not be used.
  • form-has-label: Each form element must have a programmatically associated label element. You can do so by using an implicit , explicit , aria-label or aria-labelledby.

recommended Supported Rules

:couple: 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:

  • "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?

  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",
-   "html"
  ]

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:
<template>
  <!-- eslint-disable-next-line vue-a11y/anchor-has-content -->
  <a></a>
  <h1></h1>  <!-- eslint-disable-line -->
</template>