@bridge-ds/stylelint-plugin 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,48 @@
1
- # Temporary Holding Version
1
+ # @bridge-ds/stylelint-plugin
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Stylelint rule for product apps that use a Bridge design system: raw colors, lengths, radii, borders, shadows,
4
+ durations, easings, z-index and fonts are reported where a design token exists, with the token to use.
5
+ `stylelint --fix` replaces values that equal a token with `var(--token)`; nothing else is rewritten.
6
+
7
+ It reads the tokens (every brand, theme and density) through `@bridge-ds/core` and the design system's
8
+ `bridge.config.json`, so the suggestions are the same as `bridge audit` and the `bridge_audit` MCP tool.
9
+
10
+ > Not published to npm yet: build it from this repo (`npm run plugins:build`) and install the folder, or use
11
+ > the path to `packages/stylelint-plugin/dist/index.js` in `plugins`.
12
+
13
+ ## Install
14
+
15
+ ```sh
16
+ npm install --save-dev stylelint @bridge-ds/stylelint-plugin
17
+ ```
18
+
19
+ ```json
20
+ // .stylelintrc.json in the product app
21
+ {
22
+ "plugins": ["@bridge-ds/stylelint-plugin"],
23
+ "rules": {
24
+ "bridge/use-tokens": [true, { "designSystem": "../design-system" }]
25
+ }
26
+ }
27
+ ```
28
+
29
+ ## bridge/use-tokens
30
+
31
+ ```css
32
+ .card {
33
+ color: #1c2735; /* Use var(--color-text-default) instead of #1c2735: it is the same color (#1c2735). */
34
+ padding: 13px; /* Use a token instead of the raw spacing 13px: closest is var(--space-3) (12px, high match). */
35
+ z-index: 1000; /* fixed to var(--layer-dropdown) */
36
+ }
37
+ ```
38
+
39
+ | Option | Default | |
40
+ | --- | --- | --- |
41
+ | `designSystem` | `BRIDGE_DS`, else the nearest folder with `bridge.config.json` | Design system repo root. |
42
+ | `minConfidence` | `"medium"` | Report a value only when a token is at least this close: `exact`, `high`, `medium`, `low`. |
43
+ | `categories` | all | `color`, `spacing`, `size`, `radius`, `border-width`, `shadow`, `duration`, `easing`, `z-index`, `font-family`, `font-size`, `font-weight`, `line-height`. |
44
+ | `ignoreProperties` | none | Property names or `/regex/` strings to skip. |
45
+
46
+ Colors are matched by perceptual distance (deltaE in OKLab) across every mode; semantic tokens and tokens
47
+ that fit the property (a background gets a surface token) win near-ties. Lengths go to the nearest scale step.
48
+ `var()` fallbacks, percentages, `0`, `auto` and local stacking (`z-index` 0, 1, -1) are not reported.
@@ -0,0 +1,18 @@
1
+ import stylelint from 'stylelint';
2
+ import { type Confidence, type FindingCategory } from '@bridge-ds/core/audit';
3
+ export declare const ruleName = "bridge/use-tokens";
4
+ export interface UseTokensOptions {
5
+ /** Design system repo with bridge.config.json. Default: BRIDGE_DS, else the nearest one above the working directory. */
6
+ designSystem?: string;
7
+ /** Report a value only when a token is at least this close. Default "medium". */
8
+ minConfidence?: Confidence;
9
+ /** Categories to check. Default: all. */
10
+ categories?: FindingCategory[];
11
+ /** Properties to skip (strings or /regex/ strings). */
12
+ ignoreProperties?: string[];
13
+ }
14
+ export declare const messages: {
15
+ rejected: (value: string, category: string, token: string, tokenValue: string, level: string) => string;
16
+ };
17
+ declare const plugin: stylelint.Plugin;
18
+ export default plugin;