Plumeria

INTRODUCTION

Installation

Install Plumeria and set up the compiler, ESLint, and your bundler integration.

One command

npx @plumeria/init reads the project, asks what it cannot read, and writes the rest: the packages, the bundler plugin, plumeria.d.ts and the ESLint config.

Terminal
npx @plumeria/init

It shows the plan before it writes anything, and --dry-run stops at the plan. See @plumeria/init for every question it asks and every file it touches. The rest of this page is the same setup by hand.

Installing core

The core package is type definitions only. No bundle or runtime is included.

Terminal
npm i -D @plumeria/core
Terminal
yarn add -D @plumeria/core
Terminal
pnpm i -D @plumeria/core

plumeria.d.ts

@plumeria/core ships no prop declaration of its own. At the application root, reference the one for the default classStyle prop:

plumeria.d.ts
/// <reference types="@plumeria/core/class-style" />

To use another name, see Declaring the styling prop.

ESLint is optional. Skip to your bundler: Next.js / Vite

ESLint Setup

@plumeria/eslint-plugin sorts and formats style properties and reports invalid values and selectors. The plugin reference lists every rule.

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import { defineConfig } from 'eslint/config';
import plumeria from '@plumeria/eslint-plugin';

export default defineConfig(
  eslint.configs.recommended,
  tseslint.configs.recommended,
  plumeria.configs.recommended,
);

The bundler plugins lint the build with these rules by default, so a style error stops it with no setup. On esbuild and Bun, put plumeria-lint -- in front of the build command instead, and add --style-prop if the styling prop was renamed.

Install the plugin, plus rimraf for Next.js:

Terminal
npm i -D @plumeria/eslint-plugin rimraf
Terminal
yarn add -D @plumeria/eslint-plugin rimraf
Terminal
pnpm i -D @plumeria/eslint-plugin rimraf

On Next.js, clearing the build cache before dev and build keeps a version change from being read as a compile error:

package.json
  "scripts": {
    "predev": "rimraf .next",
    "prebuild": "rimraf .next",
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
  },

Integration

Add the plugin for your bundler.

Next.js

Terminal
npm i -D @plumeria/next-plugin
Terminal
yarn add -D @plumeria/next-plugin
Terminal
pnpm add -D @plumeria/next-plugin

It works with both Turbopack and Webpack.

next.config.ts
import type { NextConfig } from "next";
import { withPlumeria } from "@plumeria/next-plugin";

const nextConfig: NextConfig = {
  /* config options here */
};

export default withPlumeria(nextConfig);

Vite

Terminal
npm i -D @plumeria/unplugin
Terminal
yarn add -D @plumeria/unplugin
Terminal
pnpm add -D @plumeria/unplugin
vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import plumeria from '@plumeria/unplugin';

export default defineConfig({
  plugins: [react(), plumeria.vite()],
});

On this page