Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/tokens-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Token Format Validation

on:
workflow_dispatch:
push:
branches:
- production
paths:
- "tokens/*.json"

jobs:
lint-tokens:
runs-on: ubuntu-latest

defaults:
run:
working-directory: tokens/linter

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Run token format validation
run: npm run lint:tokens:format
6 changes: 4 additions & 2 deletions tokens/linter/README.md
Comment thread
aweell marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ You'll be prompted to select which JSON file to validate.
#### Option B: Pass a filename

```
npm run linter my-tokens.json
npm run linter my-tokens.json format
npm run linter my-tokens.json contrast
```

This runs the validation directly on a specific file inside tokens/.
- format mode: checks description ↔ palette reference matches and invalid palette references, without skipping colors with alpha (rgba).
- contrast mode: checks foreground/background pairs for WCAG contrast compliance, skipping gradients and alpha colors. Description mismatches are not shown.

#### Option C: Validate contrast for a specific token

Expand Down
7 changes: 6 additions & 1 deletion tokens/linter/contrastPairs.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const contrastPairs = [
bg: [
"brandHigh",
"backgroundContainerBrandOverInverse",
"badge",
"completedStep",
],
minRatio: 4.5,
Comment thread
aweell marked this conversation as resolved.
Outdated
Expand Down Expand Up @@ -340,4 +339,10 @@ export const contrastPairs = [
bg: "tagBackgroundInfoBrand",
minRatio: 4.5,
},
//Badge
{
fg: "textPrimaryNegative",
bg: "badge",
minRatio: 4.5,
},
];
Loading