Skip to content

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() or hwb(): colors come from tokens. - No !important. - No px on the width, height, inline-size and block-size properties. - Color, background, border, outline, shadow, font, line-height, fill, stroke, gap, padding, margin, border-radius and z-index values are a space-separated list of atoms. An atom is a var(), a calc() over var()s and plain numbers, a color-mix() over var()s, or one of 0, auto, inherit, transparent, currentColor and none. A var() fallback is another var() 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: ObsidianTokenOnlyStylelintConfig

Type: ObsidianTokenOnlyStylelintConfig


Links to this page: