@tenphi/eslint-plugin-tasty

August 24, 2026 · View on GitHub

ESLint plugin for validating tasty(), tastyStatic(), useStyles(), useGlobalStyles(), and related APIs from @tenphi/tasty.

Catch typos, invalid syntax, and enforce best practices in your tasty style objects at lint time.

Targets @tenphi/tasty v3. v1 of this plugin validates the v3 style DSL: kebab-case at-rule keys (@property, @font-face, @counter-style, @function), $$name(...) CSS-function calls, and one value per directional group. The v2 at-rule spellings are reported with an auto-fix, so eslint --fix handles most of the upgrade. For tasty v2, pin @tenphi/eslint-plugin-tasty@^0.11.

Installation

pnpm add -D @tenphi/eslint-plugin-tasty

Usage

ESLint Flat Config (ESLint 9+)

// eslint.config.js
import tasty from '@tenphi/eslint-plugin-tasty';

export default [
  tasty.configs.recommended,
  // your other configs...
];

For stricter checks:

import tasty from '@tenphi/eslint-plugin-tasty';

export default [
  tasty.configs.strict,
];

Manual Rule Configuration

import tasty from '@tenphi/eslint-plugin-tasty';

export default [
  {
    plugins: { tasty },
    rules: {
      'tasty/known-property': 'warn',
      'tasty/valid-value': 'error',
      'tasty/valid-color-token': 'error',
      // ...
    },
  },
];

Project Configuration

Create a tasty.config.ts (or .js, .json) at your project root to configure validation:

// tasty.config.ts
export default {
  tokens: ['#primary', '#danger', '#surface', '$spacing', '$gap'],
  units: ['cols'],
  functions: ['double', 'okhsl'],
  states: ['@mobile', '@tablet', '@dark'],
  presets: ['h1', 'h2', 'h3', 't1', 't2', 't3'],
  recipes: ['card', 'elevated', 'reset'],
  styles: ['glaze'],
  importSources: ['@my-org/design-system'],
};

Every list defaults to "don't check": omit tokens and token existence is not validated, set tokens: false to disable the check even though a parent config sets it. importSources matters when you re-export tasty() from your own module — the plugin only recognizes tasty({ styles }) when the call comes from a tracked import, so a local barrel needs listing here.

functions was called funcs before v1. The old spelling is still read as a deprecated alias.

Rules

RuleSeverityDescription
tasty/known-propertywarnUnknown style property names (checked against the full MDN/W3C CSS property set)
tasty/valid-valueerrorMalformed style values (unbalanced parens, !important)
tasty/valid-color-tokenerrorInvalid color token syntax or unknown tokens
tasty/valid-custom-uniterrorUnknown custom units
tasty/valid-boolean-propertyerrortrue on properties that don't support it
tasty/valid-state-keyerrorInvalid state key syntax in style mappings (including misuse of the _ fallback floor)
tasty/valid-styles-structureerrorInvalid styles object structure, and the v2 at-rule key spellings (auto-fixable)
tasty/no-nested-state-maperrorNested state maps (not supported)
tasty/no-importanterror!important usage (breaks tasty specificity)
tasty/valid-sub-elementerrorSub-element values must be style objects
tasty/valid-directional-modifiererrorDirectional modifiers on wrong properties, and more than one value in a group that names directions
tasty/valid-radius-shapeerrorUnknown radius shape keywords
tasty/valid-preseterrorUnknown preset names
tasty/valid-recipeerrorUnknown recipe names
tasty/valid-transitionwarnUnknown transition property names
tasty/no-nested-selectorwarn&-prefixed nested selectors (use sub-elements)
tasty/static-no-dynamic-valueserrorDynamic values in tastyStatic()
tasty/static-valid-selectorerrorInvalid selector in tastyStatic(selector, ...)
tasty/require-default-stateerrorMissing default ('') or fallback floor (_) key in state mappings (skipped for extending calls)
tasty/no-own-at-rootwarn@own() used at root level where it is redundant
tasty/valid-default-state-orderwarnMisplaced default ('') or redundant '' when only _ is present
tasty/prefer-shorthand-propertywarnUse Tasty shorthand instead of native CSS properties (backgroundColorfill, etc.)
tasty/no-raw-color-valueswarnRaw hex/rgb/okhsl/okhst/oklch/named colors instead of #color tokens
tasty/consistent-token-usagewarnRaw px values when custom units or tokens exist
tasty/prefer-auto-calcwarncalc(...) instead of Tasty auto-calc (...)
tasty/prefer-custom-property-syntaxwarnvar(--prop) / $x-color / transparent / currentColor instead of $prop / #color / #clear / #current
tasty/prefer-hidewarndisplay: 'none' instead of hide: true
tasty/prefer-directional-shorthandwarn4-value margin/padding/inset/radius/fade/border with placeholder positions instead of directional form
tasty/prefer-longhand-propertyerrorLossy flex shorthand instead of flexGrow / flexShrink / flexBasis
RuleSeverityDescription
tasty/valid-custom-propertywarnUnknown $name custom properties
tasty/valid-state-definitionwarnInvalid state definition values in configure() or tasty.config
tasty/no-unknown-state-aliaswarnUnknown @name state aliases
tasty/no-styles-propwarnDirect styles prop usage
tasty/no-runtime-styles-mutationwarnDynamic values in style objects

License

MIT