Automated WCAG color contrast linter for accessibility compliance in CI/CD pipelines.
Project description
Color Contrast Linter - Automated Accessibility Testing
Color Contrast Linter is a powerful CLI tool designed to automate WCAG 2.1 color contrast compliance checks. It helps developers and designers ensure their color palettes meet AA and AAA accessibility standards directly within their workflow or CI/CD pipeline.
Built on top of cm-colors, this tool prevents accessibility regressions by linting your design tokens and color pairs against strict contrast ratio requirements.
Key Features
- Automated WCAG Compliance: Instantly verify if your color pairs meet WCAG AA (4.5:1) or AAA (7.0:1) standards.
- CI/CD Integration: Seamlessly integrate with GitHub Actions, GitLab CI, and other pipelines to block inaccessible code.
- Design System Friendly: Perfect for linting design tokens, themes, and CSS variables.
- Flexible Configuration: Define custom color pairs and contrast thresholds in a simple YAML file.
- Rich Reporting: Get clear, color-coded output in your terminal identifying passing and failing pairs.
Installation
Install the package via pip:
pip install color-contrast-linter
Usage
1. Initialize Configuration
Start by creating a configuration file. Run the init command to generate a .color_pairs.yml file in your project root:
cc-lint init
This file allows you to define the minimum contrast standard (AA or AAA) and list the color pairs you want to test.
Example .color_pairs.yml:
min_contrast: AA
pairs:
- foreground: "#000000"
background: "#ffffff"
- foreground: "#767676" # Might fail AA for normal text
background: "#ffffff"
2. Run the Linter
Execute the lint command to check your configured color pairs for accessibility issues:
cc-lint lint
The tool will analyze each pair and report:
- Pass/Fail status based on your
min_contrastsetting. - Actual contrast ratio (e.g., 21.0:1).
- WCAG Level achieved (AA, AAA, or Fail).
CI/CD Integration for Accessibility
Automate your accessibility testing by adding color-contrast-linter to your CI/CD workflow. This ensures that no new color combinations violate accessibility standards.
GitHub Actions Example
Add the following step to your .github/workflows/ci.yml:
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install Color Contrast Linter
run: pip install color-contrast-linter
- name: Run Accessibility Lint
run: cc-lint lint
Contributing
We welcome contributions! Please see our Contributing Guide for details on how to submit pull requests, report bugs, and suggest features.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file color_contrast_linter-0.1.1.tar.gz.
File metadata
- Download URL: color_contrast_linter-0.1.1.tar.gz
- Upload date:
- Size: 42.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
282a01d507e474878ac271997309674e4a00426d70163cfb5d846c9824503ea3
|
|
| MD5 |
4d2c5e300a4195d3d5d0af9aeefc7b02
|
|
| BLAKE2b-256 |
a3af643187ae7485573ddf9dff4ea3b08933a7be129030902d3d9f7154411362
|
Provenance
The following attestation bundles were made for color_contrast_linter-0.1.1.tar.gz:
Publisher:
release.yml on comfort-mode-toolkit/color-contrast-linter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
color_contrast_linter-0.1.1.tar.gz -
Subject digest:
282a01d507e474878ac271997309674e4a00426d70163cfb5d846c9824503ea3 - Sigstore transparency entry: 732006328
- Sigstore integration time:
-
Permalink:
comfort-mode-toolkit/color-contrast-linter@5737b5f395dd226728882857de55a1763d664bb8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/comfort-mode-toolkit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5737b5f395dd226728882857de55a1763d664bb8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file color_contrast_linter-0.1.1-py3-none-any.whl.
File metadata
- Download URL: color_contrast_linter-0.1.1-py3-none-any.whl
- Upload date:
- Size: 29.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
050dbc24b5004074be41f1687dcc16ab1d092077b20bc78f9b4ab516d8d20938
|
|
| MD5 |
24862d630f0b7ee79c97feb4f5b9fdda
|
|
| BLAKE2b-256 |
331ff6cb932e98f41498499432dd7d50661407b2beacaca57578ff2ab7256755
|
Provenance
The following attestation bundles were made for color_contrast_linter-0.1.1-py3-none-any.whl:
Publisher:
release.yml on comfort-mode-toolkit/color-contrast-linter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
color_contrast_linter-0.1.1-py3-none-any.whl -
Subject digest:
050dbc24b5004074be41f1687dcc16ab1d092077b20bc78f9b4ab516d8d20938 - Sigstore transparency entry: 732006332
- Sigstore integration time:
-
Permalink:
comfort-mode-toolkit/color-contrast-linter@5737b5f395dd226728882857de55a1763d664bb8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/comfort-mode-toolkit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5737b5f395dd226728882857de55a1763d664bb8 -
Trigger Event:
release
-
Statement type: