GithubHelp home page GithubHelp logo

f1lt3r / ha11y Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 416 KB

⭕ Browserless Parallelized Accessibility HTML Code Sniffer

Home Page: http://f1lt3r.io

License: MIT License

JavaScript 8.35% HTML 91.65%
accessibility ha11y pa11y accesssniff parallel html codesniffer

ha11y's Introduction

ha11y logo

⭕ ha11y

Browserless Parallel Accessibility HTML Code Sniffer

Build Status Coverage Status NPM Version XO code style

👨‍🔬 Experimental

⭕ ha11y is a highly experimental package. The API is subject to rapid change.

Install

npm install --save-dev ha11y

Usage

React

Test:

import React from 'react';
import {shallow} from 'enzyme';
import ha11y from 'ha11y';

import MyImgComp from '../MyImgComp';

it('ha11y test', () => {
    const dom = (
        <html lang="en">
            <head>
                <title>Foo</title>
            </head>
            <body>
                {/* Oops... no ALT tag! */}
                <MyImgComp src="foo.png"/>
            </body>
        </html>
    );

    const html = shallow(dom).html();

    return ha11y.test(html)
        .then(results => {
            const errors = results.filter(result => result.heading === 'ERROR');
            console.log(errors);
            expect(errors.length).toEqual(0);
        });
});

Output:

  FAIL  src/comps/__tests__/MyImgComp.test.js
  ● Console
[
    {
        "heading": "ERROR",
        "issue": "WCAG2AAA.Principle1.Guideline1_1.1_1_1.H37",
        "description": "Img element missing an alt attribute. Use the alt attribute to specify a short text alternative.",
        "position": {
            "lineNumber": 1,
            "columnNumber": 0
        },
        "element": {
            "node": "<img src=\"foo.png\">",
            "class": "", 
            "id": ""
        }
    }
]

Licence

Runs on HTML_CodeSniffer — see licence.txt

ha11y's People

Contributors

f1lt3r avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.