API

@plumeria/codemod

★★★☆☆ Candidate

Rename the styling prop or an API, or migrate Plumeria imports and dependencies to TypedCSS.

@plumeria/codemod rewrites Plumeria source files and package dependencies.

TransformWhat it does
rename-proprenames JSX styling attributes and matching Style property signatures
rename-apirenames a Plumeria API and references to its imports
migrate-to-typedcssrewrites supported package imports, plugin calls and dependencies to TypedCSS

Every transform supports --dry-run. Commit your changes before applying a rewrite so you can review and revert it separately.

Installation

Run it without adding it to your project:

Terminal
npx @plumeria/codemod rename-prop classStyle sx --dry-run

To pin it in the repository:

Terminal
pnpm i -D @plumeria/codemod

The package depends on ESLint and its TypeScript parser. It can run before you upgrade Plumeria.

CSS Modules migration in either direction was removed in 22.0.0. The migrate --from css-modules and migrate --from plumeria commands are no longer available.

Renaming the styling prop

Terminal
npx @plumeria/codemod rename-prop <from> <to> [paths...]

paths default to the current directory. dist, build, out, .next and coverage are always skipped, and the transform reads .js, .jsx, .mjs, .cjs, .ts, .tsx, .mts and .cts.

OptionDescription
-d, --dry-runreport what would change without writing
--no-typesleave TypeScript declarations untouched
-h, --helpshow usage
-v, --versionshow the version

Start with --dry-run:

Terminal
npx @plumeria/codemod rename-prop classStyle sx --dry-run
  src/Card.tsx  3
  src/page.tsx  1

4 occurrence(s) in 2 file(s) would become "sx".
Run without --dry-run to apply.

2 occurrence(s) need a manual rename — "classStyle" is bound to a local name there:
  src/Card.tsx:8:24
  src/Card.tsx:12:71

Drop the flag to apply. The report is the same, with the count confirmed rather than predicted:

✔ renamed 4 occurrence(s) of "classStyle" to "sx" in 2 file(s).

If the git working tree is dirty, it says so before writing — the rewrite is much easier to undo from a clean tree.

What it rewrites

JSX attributes.

- <div classStyle={styles.card} />
+ <div sx={styles.card} />

Property signatures annotated with Style. That covers your plumeria.d.ts as well as the props of your own components:

  interface CardProps {
-   classStyle?: Style;
+   sx?: Style;
  }

The annotation has to be Style or Plumeria.Style, so an unrelated interface that happens to use the same key is left alone. Pass --no-types to skip declarations entirely.

What it reports instead of rewriting

Where the prop is destructured, or read off an object, the name is a local binding and not only a prop:

const Card = ({ classStyle }: CardProps) => <div classStyle={classStyle} />;

const Panel = (props: CardProps) => <section classStyle={props.classStyle} />;

The attribute is safe to rewrite; the binding is a judgement call about the surrounding code. Those sites are listed with their positions so you can finish them by hand:

  const Card = ({ classStyle, title }: CardProps) => (
-   <div classStyle={classStyle}>{title}</div>
+   <div sx={classStyle}>{title}</div>
  );

Renaming the parameter as well is the usual next step, and it is left to you.

Names it refuses

<to> has to be a valid identifier, has to differ from <from>, and cannot be a prop React already handles — className, key, ref, children or style:

✖ "style" is already used by React

Files that fail to parse are reported at the end and the command exits with 1, so a broken file cannot be mistaken for a file with nothing to rename.

After the rewrite

The codemod changes your source; it does not change your configuration. Moving to sx, the default since 22.0.0, needs no configuration: drop any styleProp: 'classStyle' from the bundler plugin and the ESLint settings, and switch the declaration to /// <reference types="@plumeria/core/sx" />.

For any other name, point the toolchain at it:

next.config.ts
export default withPlumeria({}, { styleProp: 'styleName' });
eslint.config.ts
export default [
  {
    settings: { plumeria: { styleProp: 'styleName' } },
  },
];

And point the type declaration at the same name — see Declaring the styling prop.

The codemod does not reformat. If the new name is longer than the old one, lines that were near your print width can cross it. Run your formatter afterwards.

Choosing another prop name

The names are arguments, so the transform is not tied to any particular release. Renaming the prop to whatever suits your codebase is the same command:

Terminal
npx @plumeria/codemod rename-prop sx styleName
npx @plumeria/codemod rename-prop styleName sx

Renaming an API

When a release renames a Plumeria API, rename-api moves your code to the new name:

Terminal
npx @plumeria/codemod rename-api <from> <to> [paths...]
npx @plumeria/codemod rename-api viewTransition viewTransitionClass

It rewrites calls through the namespace or default import of @plumeria/core, and named imports together with every reference to them. An alias keeps its local name, so only the import changes:

  import * as css from '@plumeria/core';
- const fade = css.viewTransition({ old: { opacity: 0 } });
+ const fade = css.viewTransitionClass({ old: { opacity: 0 } });
- import { viewTransition as vt } from '@plumeria/core';
+ import { viewTransitionClass as vt } from '@plumeria/core';
  const slide = vt({ new: { opacity: 1 } });

<to> has to be an API @plumeria/core exports, so a typo is reported instead of written. --dry-run lists the files it would change.

Migrating to TypedCSS

Preview the migration from the project root, then apply it:

Terminal
npx @plumeria/codemod migrate-to-typedcss --dry-run
npx @plumeria/codemod migrate-to-typedcss

You can pass paths after the command. Source files and package.json files are processed only under those paths, so passing just src does not update a manifest in the project root.

Package imports

The transform rewrites imports, re-exports, import() and require() for these packages, preserving their subpaths:

PlumeriaTypedCSS
@plumeria/core@typedcss/css
@plumeria/unplugin@typedcss/unplugin
@plumeria/next-plugin@typedcss/next-plugin
@plumeria/eslint-plugin@typedcss/eslint-plugin
- import * as css from '@plumeria/core';
- import plumeria from '@plumeria/unplugin/vite';
+ import * as css from '@typedcss/css';
+ import plumeria from '@typedcss/unplugin/vite';

Local names are preserved. A named import of withPlumeria from the Next.js plugin becomes withTypedCSS, along with its references:

- import { withPlumeria } from '@plumeria/next-plugin';
- export default withPlumeria(nextConfig);
+ import { withTypedCSS } from '@typedcss/next-plugin';
+ export default withTypedCSS(nextConfig);

An explicitly aliased import keeps its local name. Named re-exports and destructured require() bindings are handled too.

Dependencies

The same four packages are replaced in package.json dependency sections, preserving their version ranges. Because @typedcss/css includes a runtime, it is placed in dependencies even when @plumeria/core was a dev dependency.

The codemod does not install packages or update lockfiles. After applying the manifest changes, run the install command it prints, such as pnpm install.

What to update manually

This transform changes package references and named plugin bindings; it does not convert every Plumeria API or configuration value. Review these separately:

  • Rename an older styling prop to sx with rename-prop before migrating.
  • Replace css.use(...) with the appropriate css.props(...) spread. The return values differ, so this is not an API rename.
  • Update triple-slash type references, namespace plugin calls such as plugin.withPlumeria(...), and ESLint plugin keys and settings where needed.
  • Review dependencies outside the four supported packages.

Run your formatter, type checker and build, then check the affected UI. See TypedCSS for the authoring model and the difference between css.use and css.props.

Edit on GitHub