Skip to content

linters/stylelint-config

An opt-in stylelint configuration for an Obsidian plugin’s CSS that allows only theme tokens: colors, fonts and spacing come from var(--...) custom properties, never from hex, named or rgb() / hsl() colors, raw pixel sizes or !important. A plugin styled that way follows whatever theme the user runs.

It is plain data and imports nothing from stylelint, so loading it needs no optional peer.

Adapted from stylelint.config.mjs of @insurgently/obsidian-ui 0.4.0 (https://www.npmjs.com/package/@insurgently/obsidian-ui), MIT License, Copyright (c) 2026 Insurgently.

Interface Description
ObsidianTokenOnlyStylelintConfig The shape of obsidianTokenOnlyStylelintConfig, a stylelint Config with only rules set.
ObsidianTokenOnlyStylelintRules The stylelint rules of obsidianTokenOnlyStylelintConfig.
Variable Description
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.