Transforms
Modify code before it is added to your project.
Transforms are a way to modify code before it's added to your project. You can use transforms to format code, add comments, or any other code modification you can think of.
Transforms are also plugable so you can create your own and share them with the community. Here are a few of the officially supported transforms:
| Package | Description | Source |
|---|---|---|
@jsrepo/transform-prettier | Format code before it's added to your project using Prettier | |
@jsrepo/transform-biome | Format code before it's added to your project using Biome |
Adding transforms
You can add transforms to your config by running the following command:
jsrepo config transform jsrepo-transform-my-transformThis will automatically install the transform and add it to your config:
import { defineConfig } from "jsrepo";
import myTransform from "jsrepo-transform-my-transform";
export default defineConfig({
transforms: [myTransform()],
});Transform authors
When creating transforms we recommend you follow a few rules:
- Name your transform package with the following naming convention:
jsrepo-transform-<name>or@<org>/jsrepo-transform-<name> - Export the transform as the
defaultexport
The name of your transform in the config will be the name of your package without the jsrepo-transform- prefix converted to camel case.
For example:
jsrepo-transform-my-transform -> myTransform
@my-org/jsrepo-transform-my-transform -> myTransformOfficial plugins are an exception to this rule to prevent having to name packages like @jsrepo/jsrepo-transform-prettier.
For instance:
@jsrepo/transform-prettier -> prettier
@jsrepo/transform-faster-prettier -> fasterPrettier