Common utilities, constants, error messages, and helper functions for @sa11y
packages.
This package provides shared functionality used across all @sa11y
packages. It includes utilities for environment detection, custom rule management, file processing, and result handling.
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
}
import { useCustomRules, registerCustomRules } from '@sa11y/common';
// Load custom rules from environment
const customRules = useCustomRules();
// Register custom axe rules
registerCustomRules(changesData, rulesData, checkData);
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>');
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;
});
-
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