Skip to content

Lint Rules Reference

Dispersa includes six built-in lint rules. Each rule is configurable with options.

Requires tokens to have a $description field. Descriptions improve token discoverability in design tools and documentation.

rules: {
'dispersa/require-description': 'warn'
}
OptionTypeDefaultDescription
minLengthnumber1Minimum description length
ignorestring[][]Glob patterns to exclude
rules: {
'dispersa/require-description': ['warn', { minLength: 10 }]
}

Enforces consistent token case formatting. Checks each path segment individually, allowing tokens like color.brand.500 where numeric scales are common.

rules: {
'dispersa/case-check': ['error', { format: 'kebab-case' }]
}
OptionTypeDefaultDescription
format'kebab-case' | 'camelCase' | 'PascalCase' | 'snake_case' | 'screaming-snake''kebab-case'Naming format to enforce
ignorestring[][]Glob patterns to exclude
patternstringCustom regex pattern (overrides format)
allowNumericSegmentsbooleantrueAllow numeric segments (e.g., spacing.0)
FormatExample
kebab-casecolor-brand-primary, red-500
camelCasecolorBrandPrimary
PascalCaseColorBrandPrimary
snake_casecolor_brand_primary
screaming-snakeCOLOR_BRAND_PRIMARY
rules: {
'dispersa/case-check': ['error', { pattern: '^[a-z][a-z0-9-]*$' }]
}

Warns when tokens reference deprecated tokens (those with $deprecated). Helps migrate away from deprecated tokens in your design system.

rules: {
'dispersa/no-deprecated-usage': 'warn'
}
OptionTypeDefaultDescription
ignorestring[][]Glob patterns to exclude
{
"color": {
"old-primary": {
"$type": "color",
"$value": "#ff0000",
"$deprecated": "Use color.brand.primary instead"
}
}
}

A token referencing {color.old-primary} will trigger a warning.


Detects tokens with identical values. Consider using aliases instead of duplicate values to maintain a single source of truth.

rules: {
'dispersa/no-duplicate-values': 'warn'
}
OptionTypeDefaultDescription
ignorestring[][]Glob patterns to exclude
typesstring[][]Only check specific token types
rules: {
'dispersa/no-duplicate-values': ['warn', { types: ['color'] }]
}

Validates token path structure using segment definitions and path patterns. Most powerful for enforcing organizational conventions.

rules: {
'dispersa/path-schema': ['warn', {
segments: {
category: { values: ['color', 'spacing'] },
component: { values: ['button', 'input'] },
},
paths: ['{category}.{component}.*'],
}]
}
OptionTypeDefaultDescription
segmentsRecord<string, SegmentDefinition>{}Named segment definitions
pathsstring[][]Valid path patterns with {segment} placeholders
transitionsTransitionRule[][]Context-aware segment transition rules
ignorestring[][]Glob patterns to exclude
{
category: {
values: ['color', 'spacing', 'typography'], // or RegExp
}
}
{
paths: [
'color.base.{brand}',
'color.semantic.{element}.{role}',
'color.component.{component}.{state}',
]
}

Use {segment} for named segments, * for wildcard segments, {name?} for optional segments, and {a|b} for OR syntax (matches segment definitions a OR b).

Alternative to patterns - define which segments can follow which:

{
transitions: [
{ from: 'color', to: ['base', 'semantic', 'component'] },
{ from: 'semantic', to: ['text', 'bg', 'border'] },
{ from: 'semantic', to: 'component', allow: false }, // forbidden
]
}
const lintRules = {
'dispersa/path-schema': [
'warn',
{
segments: {
category: {
values: ['color', 'spacing', 'typography', 'shadow'],
},
component: {
values: ['button'],
},
variant: {
values: ['primary', 'secondary', 'ghost', 'danger'],
},
property: {
values: ['background', 'text', 'border', 'padding'],
},
state: {
values: ['hover', 'active', 'focus', 'disabled'],
},
},
paths: [
'{category}.{component}.{property}',
'{category}.{component}.{property}.{state?}',
'{category}.{component}.{variant?}.{property}',
'{category}.{component}.{variant?}.{property}.{state?}',
],
},
],
}