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 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-html-a11y

v0.2.4

Published

ESLint plugin for WCAG accessibility checks on HTML templates parsed with @html-eslint/parser

Readme

eslint-plugin-html-a11y

npm License: MIT Node.js ESLint

WCAG 2.2 accessibility linting for HTML-like template languages that @html-eslint/parser can parse natively: plain HTML, Jinja2, Handlebars, Twig, Django, Nunjucks, and any other language whose template syntax is transparent enough that the parser can produce a valid AST out of it.

Introduction

Most accessibility linters, such as eslint-plugin-jsx-a11y for React, or eslint-plugin-vuejs-accessibility for Vue, target a specific framework, usually the most popular frontend frameworks and libraries; they don't work on plain HTML templates, and they don't work on other template languages, even though the underlying set of WCAG 2.2 rules is generic, so potentially framework-agnostic.

This plugin aims to fill the gap by bringing the same set of WCAG Level A and AA checks to any HTML-like template language that @html-eslint/parser can parse to an AST, enabling static analysis before compilation.

Dynamically evaluated template expressions like {{ name }} or {% if cond %} are sanitized and get then treated as text in the AST, so the parser does not choke on them and rules still fire on the surrounding HTML structure.

By design, this package is meant to be extended into new ones to enable the hereby shipped rules to work on other template languages whose syntax is not natively supported by @html-eslint/parser, such as ISML.

An adapter package is expected to provide a preprocessor that sanitizes any template-specific (non-HTML) syntax, before handing it to the parser. For this purpose, this plugin exposes buildRulesFor(prefix, rulesMap, config) so adapters can inherit the hereby supported engine and rule set without reimplementing them. The sole responsibility of the adapters is to carry out the reduction operations.

Installation

Requires Node.js ≥ 18, ESLint ≥ 8, and @html-eslint/parser >= 0.23.

# npm
npm install --save-dev eslint-plugin-html-a11y @html-eslint/parser eslint

# yarn
yarn add --dev eslint-plugin-html-a11y @html-eslint/parser eslint

# pnpm
pnpm add -D eslint-plugin-html-a11y @html-eslint/parser eslint

Setup

ESLint v9 — eslint.config.js (recommended)

import htmlA11y from 'eslint-plugin-html-a11y';

export default [...htmlA11y.configs.recommended];

The recommended config applies @html-eslint/parser to **/*.html files and enables all 25 rules as "warn".

ESLint v8 — .eslintrc.json

This plugin cannot ship a legacy .eslintrc config. Please configure the parser and rules manually:

{
  "plugins": ["html-a11y"],
  "overrides": [
    {
      "files": ["**/*.html"],
      "parser": "@html-eslint/parser",
      "rules": {
        "html-a11y/img-alt": "warn",
        "html-a11y/button-name": "warn",
        "html-a11y/link-name": "warn"
      }
    }
  ]
}

For the full rule list, see Rules below and prefix each name with html-a11y/.

Override with custom configurations

import htmlA11y from 'eslint-plugin-html-a11y';
import htmlParser from '@html-eslint/parser';

export default [
  ...htmlA11y.configs.recommended,
  {
    files: ['**/*.html', '**/*.jinja2'],
    plugins: { 'html-a11y': htmlA11y },
    languageOptions: { parser: htmlParser },
    rules: {
      'html-a11y/img-alt': 'error',     // or 2
      'html-a11y/button-name': 'warn',  // or 1
      'html-a11y/no-autofocus': 'off',  // or 0
    },
  },
];

Dynamic template values

If you run a preprocessor that replaces template expressions with a sentinel string before the file gets parsed, configure the sentinel so rules know to treat those attribute values and text nodes as non-empty runtime values rather than flagging them as violations:

export default [
  ...htmlA11y.configs.recommended,
  {
    files: ['**/*.html'],
    settings: {
      'html-a11y': {
        dynamicValueMarker: '__EXPR__',    // skip attributes whose value contains this string
        dynamicContentMarker: '__CONTENT__', // treat text nodes containing this string as non-empty
      },
    },
  },
];

Without a preprocessor — if template expressions appear literally in the source (e.g., alt="{{ image.alt }}") — no configuration is needed. The parser sees the expression as a non-empty string and rules pass without false positives in the common case.

Adapter packages handle this automatically. eslint-plugin-sfcc-a11y, for example, replaces ISML ${...} expressions with __ISML_EXPR__ and configures that marker in the recommended settings, so no manual setup is required.

Rules

| Rule | WCAG SC | Level | Description | |---|---|---|---| | img-alt | 1.1.1 | A | <img> and <input type="image"> must have a non-empty alt | | object-alt | 1.1.1 | A | <object> must have an accessible text alternative | | media-has-caption | 1.2.2 | A | <video> must have a <track kind="captions"> child | | label | 1.3.1 | A | Form controls must have an associated accessible label | | scope-attr-valid | 1.3.1 | A | scope on <th> must be col, row, colgroup, or rowgroup | | autocomplete-valid | 1.3.5 | AA | autocomplete attribute must use valid tokens | | interactive-supports-focus | 2.1.1 | A | Elements with interactive ARIA roles must be keyboard-focusable | | no-noninteractive-tabindex | 2.1.1 | A | tabindex >= 0 must not appear on non-interactive elements | | no-access-key | 2.1.4 | A | Forbid accesskey attribute | | no-distracting-elements | 2.2.2 | A | Forbid <marquee> and <blink> | | no-autofocus | 2.4.3 | AA | Forbid autofocus attribute | | tabindex-no-positive | 2.4.3 | AA | tabindex must not be greater than 0 | | link-name | 2.4.4 | A | <a> and <area href> must have discernible text or aria-label | | anchor-is-valid | 2.4.4 | A | <a> must have a navigating href (not #, javascript:, empty) | | heading-has-content | 2.4.6 | AA | <h1><h6> must have non-empty text content | | html-has-lang | 3.1.1 | A | <html> must have a non-empty lang attribute | | lang-value | 3.1.1 | A | lang attribute must be a valid BCP 47 language tag | | aria-role | 4.1.2 | A | role value must be a valid, non-abstract ARIA role | | aria-props | 4.1.2 | A | aria-* attribute names must be valid ARIA properties | | aria-required-attr | 4.1.2 | A | Required ARIA attributes for the element's role must be present | | aria-proptypes | 4.1.2 | A | aria-* values must match the expected ARIA type | | aria-hidden-on-focusable | 4.1.2 | A | aria-hidden="true" must not appear on focusable elements | | button-name | 4.1.2 | A | <button> must have discernible text or aria-label | | no-redundant-role | 4.1.2 | AA | Explicit role must not duplicate the element's implicit ARIA role | | role-supports-aria-props | 4.1.2 | A | aria-* attributes must be in the element's role's supported set |

License

MIT © Nicola Carkaxhija