obsidianTokenOnlyStylelintConfig
An opt-in stylelint configuration that allows only theme tokens in an Obsidian plugin’s CSS.
- No hex colors, no named colors, no
rgb(),rgba(),hsl(),hsla()orhwb(): colors come from tokens. - No!important. - Nopxon the width, height, inline-size and block-size properties. - Color, background, border, outline, shadow, font, line-height,fill,stroke,gap, padding, margin, border-radius andz-indexvalues are a space-separated list of atoms. An atom is avar(), acalc()overvar()s and plain numbers, acolor-mix()overvar()s, or one of0,auto,inherit,transparent,currentColorandnone. Avar()fallback is anothervar()or one of those keywords, never a raw length or color.
A fixed size a plugin really needs is named: declare it once as a custom property on the component (--my-cover-width: 64px) and use width: var(--my-cover-width). The value allow-list does not check custom property declarations, so the name is the allow-list entry and the raw number lives in one place. The color bans still apply there: a color is derived from a theme variable (with color-mix()), never defined as a literal.
Use it as the whole configuration (export default obsidianTokenOnlyStylelintConfig; in stylelint.config.mjs), or spread it into one that extends a standard configuration.
Import:
import { obsidianTokenOnlyStylelintConfig } from '@mnaoumov/obsidian-dev-toolkit/linters/stylelint-config';Signature:
const obsidianTokenOnlyStylelintConfig: ObsidianTokenOnlyStylelintConfigType: ObsidianTokenOnlyStylelintConfig
Links to this page: