├── .eslintignore ├── .eslintrc.js ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── LICENSE.md ├── README.md ├── docs └── rules │ ├── accessible-emoji.md │ ├── alt-text.md │ ├── anchor-has-content.md │ ├── aria-props.md │ ├── aria-role.md │ ├── aria-unsupported-elements.md │ ├── click-events-have-key-events.md │ ├── form-has-label.md │ ├── heading-has-content.md │ ├── iframe-has-title.md │ ├── interactive-supports-focus.md │ ├── label-has-for.md │ ├── media-has-caption.md │ ├── mouse-events-have-key-events.md │ ├── no-access-key.md │ ├── no-autofocus.md │ ├── no-distracting-elements.md │ ├── no-onchange.md │ ├── no-redundant-roles.md │ ├── role-has-required-aria-props.md │ └── tabindex-no-positive.md ├── lib ├── configs │ ├── base.js │ ├── essential.js │ └── recommended.js ├── index.js ├── rules │ ├── accessible-emoji.js │ ├── alt-text.js │ ├── anchor-has-content.js │ ├── aria-props.js │ ├── aria-role.js │ ├── aria-unsupported-elements.js │ ├── click-events-have-key-events.js │ ├── form-has-label.js │ ├── heading-has-content.js │ ├── iframe-has-title.js │ ├── interactive-supports-focus.js │ ├── label-has-for.js │ ├── media-has-caption.js │ ├── mouse-events-have-key-events.js │ ├── no-access-key.js │ ├── no-autofocus.js │ ├── no-distracting-elements.js │ ├── no-onchange.js │ ├── no-redundant-roles.js │ ├── role-has-required-aria-props.js │ └── tabindex-no-positive.js └── utils │ └── index.js ├── package-lock.json ├── package.json ├── scripts ├── create-rule.js ├── create-rule.md └── template │ ├── doc.js │ ├── rule.js │ └── test.js └── tests └── lib └── rules ├── accessible-emoji.js ├── alt-text.js ├── anchor-has-content.js ├── aria-props.js ├── aria-role.js ├── aria-unsupported-elements.js ├── click-events-have-key-events.js ├── form-has-label.js ├── heading-has-content.js ├── iframe-has-title.js ├── interactive-supports-focus.js ├── label-has-for.js ├── media-has-caption.js ├── mouse-events-have-key-events.js ├── no-access-key.js ├── no-autofocus.js ├── no-distracting-elements.js ├── no-onchange.js ├── no-redundant-roles.js ├── role-has-required-aria-props.js └── tabindex-no-positive.js /.eslintignore: -------------------------------------------------------------------------------- 1 | /.nyc_output 2 | /coverage 3 | /node_modules 4 | /tests/ 5 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | root: true, 4 | parserOptions: { 5 | ecmaVersion: 6 6 | }, 7 | env: { 8 | node: true, 9 | mocha: true, 10 | es6: true 11 | }, 12 | extends: [ 13 | "eslint:recommended", 14 | 'plugin:eslint-plugin/recommended' 15 | ], 16 | plugins: [ 17 | 'eslint-plugin' 18 | ], 19 | rules: { 20 | 'eslint-plugin/report-message-format': ['error', '^[A-Z`\'].*\\.$'], 21 | 'eslint-plugin/prefer-placeholders': 'error', 22 | 'eslint-plugin/consistent-output': 'error' 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | /dist/ 4 | npm-debug.log* 5 | /test/unit/coverage/ 6 | /test/e2e/reports/ 7 | .idea/ -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2018 ElemeFE 3 | Copyright (c) 2016 Ethan Cohen 4 | Copyright (c) 2013-present, Yuxi (Evan) You 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # eslint-plugin-vue-a11y 2 | 3 | Static AST checker for accessibility rules on elements in .vue. 4 | 5 | 6 | ## Installation 7 | 8 | You'll first need to install [ESLint](http://eslint.org): 9 | 10 | ``` 11 | $ npm i eslint --save-dev 12 | ``` 13 | 14 | Next, install `eslint-plugin-vue-a11y`: 15 | 16 | ``` 17 | $ npm install eslint-plugin-vue-a11y --save-dev 18 | ``` 19 | 20 | **Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-vue-a11y` globally. 21 | 22 | ## Usage 23 | 24 | Add `vue-a11y` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix: 25 | 26 | ```json 27 | { 28 | "plugins": [ 29 | "vue-a11y" 30 | ] 31 | } 32 | ``` 33 | 34 | 35 | Then configure the rules you want to use under the rules section. 36 | 37 | ```json 38 | { 39 | "rules": { 40 | "vue-a11y/rule-name": 2 41 | } 42 | } 43 | ``` 44 | 45 | also You can enable all the base rules at once. 46 | Add `plugin:vue-a11y/base` in `extends`: 47 | 48 | ```json 49 | { 50 | "extends": [ 51 | "plugin:vue-a11y/base" 52 | ] 53 | } 54 | ``` 55 | 56 | 57 | 58 | ## base Supported Rules 59 | - [accessible-emoji](docs/rules/accessible-emoji.md): wrapping the emoji in a ``, giving it the `role="img"`, and providing a useful description in `aria-label` 60 | - [alt-text](docs/rules/alt-text.md): Enforce all elements that require alternative text have meaningful information to relay back to end user. 61 | - [anchor-has-content](docs/rules/anchor-has-content.md): Enforce all anchors to contain accessible content. 62 | - [click-events-have-key-events](docs/rules/click-events-have-key-events.md): Enforce a clickable non-interactive element has at least one keyboard event listener. 63 | - [label-has-for](docs/rules/label-has-for.md): Enforce that `