Formatting Setup
Table of Contents
Formatting using Prettier
Setting up Prettier
Val allows you to configure code formatting. This formatter will apply every time content is published. We recommend setting this up.
Installation
Install prettier as a regular dependency:
Important: Install Prettier as a Regular Dependency
Prettier must be installed as a regular dependency (not a devDependency) for formatting to work in production environments.
Configuration
Configure formatting in your `val/val.server.ts` file by providing a `formatter` function to `initValServer`:
Prettier Configuration File
Create a `.prettierrc.json` file in your project root with your preferred formatting options:
Using Other Formatters
While this example uses Prettier, you can use any formatter by implementing the formatter function. The function receives the code as a string and the file path, and should return the formatted code.