open-index/open-npm huggingface dataset:
npm package: @sa11y/assert
Description: Provides assertAccessible API to check DOM for accessibility issues
Latest version: 8.0.27

# `@sa11y/assert`

Provides assertAccessible API to check DOM for accessibility issues

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Usage](#usage)
  - [Basic Usage](#basic-usage)
  - [Getting Results](#getting-results)
  - [Environment Variables](#environment-variables)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Usage

### Basic Usage

```javascript
import { assertAccessible } from '@sa11y/assert';
import { full } from '@sa11y/preset-rules';

// Setup DOM in the state to be tested for accessibility
// ...
// Assert that the current dom has no a11y issues
// Defaults to using
//  - default document context e.g. JSDOM in Jest
//  - base ruleset from @sa11y/preset-rules and
//  - A11yError.checkAndThrow from @sa11y/format
await assertAccessible();

// Can be used to test accessibility of a specific HTML element
const elem = document.getElementById('foo');
await assertAccessible(elem);

// Can be overridden to use custom dom, ruleset or formatter
//  - Specifying null for formatter will result in using JSON stringify
await assertAccessible(document, full, null);
```

### Getting Results

For advanced use cases where you want to get the accessibility results without throwing an error:

```javascript
import { getA11yResultsJSDOM, getViolationsJSDOM, getIncompleteJSDOM } from '@sa11y/assert';
import { extended } from '@sa11y/preset-rules';

// Get both violations and incomplete results
const allResults = await getA11yResultsJSDOM(document, extended, true);

// Get only violations (default behavior)
const violations = await getViolationsJSDOM(document, extended);

// Get only incomplete results
const incomplete = await getIncompleteJSDOM(document, extended);
```

### Environment Variables

-   `SELECTOR_FILTER_KEYWORDS`: Comma-separated list of keywords to filter out violations by CSS selector
npm package: @sa11y/common
Description: Common utilities, constants, error messages for @sa11y
Latest version: 8.0.27

# `@sa11y/common`

Common utilities, constants, error messages, and helper functions for `@sa11y` packages.

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Overview](#overview)
- [Utilities](#utilities)
  - [Environment Detection](#environment-detection)
  - [Custom Rules](#custom-rules)
  - [File Processing](#file-processing)
  - [Result Processing](#result-processing)
- [Environment Variables](#environment-variables)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Overview

This package provides shared functionality used across all `@sa11y` packages. It includes utilities for environment detection, custom rule management, file processing, and result handling.

## Utilities

### Environment Detection

```javascript
import { log, isFakeTimerUsed } from '@sa11y/common';

// Debug logging (only outputs when SA11Y_DEBUG is set)
log('Debug message');

// Check if fake timers are being used
if (isFakeTimerUsed()) {
    // Handle fake timer scenario
}
```

### Custom Rules

```javascript
import { useCustomRules, registerCustomRules } from '@sa11y/common';

// Load custom rules from environment
const customRules = useCustomRules();

// Register custom axe rules
registerCustomRules(changesData, rulesData, checkData);
```

### File Processing

```javascript
import { processFiles, writeHtmlFileInPath } from '@sa11y/common';

// Process files in a directory
const results = [];
processFiles('/path/to/directory', results, '.json', JSON.parse);

// Write HTML file for debugging
writeHtmlFileInPath('/output/path', 'test.html', '<html>...</html>');
```

### Result Processing

```javascript
import { getViolations, getIncomplete } from '@sa11y/common';

// Get violations using a custom checker function
const violations = await getViolations(async () => {
    const results = await axe.run();
    return results.violations;
});

// Get incomplete results
const incomplete = await getIncomplete(async () => {
    const results = await axe.run();
    return results.incomplete;
});
```

## Environment Variables

-   `SA11Y_DEBUG`: Enable debug logging
-   `SA11Y_CUSTOM_RULES`: Path to custom rules JSON file
-   `SA11Y_AUTO_FILTER_LIST_PACKAGE_NAME`: Package name for auto-filter list
-   `SA11Y_AUTO_FILTER_LIST_PACKAGE_REQUIREMENT`: Package requirement for auto-filter
npm package: @sa11y/format
Description: Accessibility results re-formatter
Latest version: 8.0.27

# `@sa11y/format`

Format accessibility results from axe

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Usage](#usage)
  - [Basic Formatting](#basic-formatting)
  - [Exception List Filtering](#exception-list-filtering)
  - [Result Processing](#result-processing)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Usage

### Basic Formatting

```javascript
import axe from 'axe-core';
import { A11yError } from '@sa11y/format';

const results = await axe.run();
console.log(A11yError.checkAndThrow(results.violations));
```

### Exception List Filtering

Filter out specific accessibility violations based on rule ID and CSS selectors:

```javascript
import { exceptionListFilter, exceptionListFilterSelectorKeywords } from '@sa11y/format';

// Filter by rule ID and specific CSS selectors
const exceptionList = {
    'color-contrast': ['.btn-secondary', '.text-muted'],
    'landmark-one-main': ['body'],
};
const filteredResults = exceptionListFilter(violations, exceptionList);

// Filter by selector keywords
const keywords = ['known-issue', 'legacy-component'];
const keywordFilteredResults = exceptionListFilterSelectorKeywords(violations, keywords);
```

### Result Processing

Process and enhance accessibility results with WCAG metadata:

```javascript
import { A11yResult, appendWcag } from '@sa11y/format';

// Process individual result
const processedResult = new A11yResult(violationData);

// Add WCAG metadata to results
const resultsWithWcag = appendWcag(violations);
```