format-code

Learn how to format code files.

This action formats code files using the project's configured formatter, if available. If no formatter is found or formatting fails, the action completes silently without error.

Example

The following template downloads a component and formats it:

template.json5
{  "$schema": "https://schema.croct.com/json/v1/template.json",  "title": "Component installer",  "description": "Downloads and formats a component file.",  "actions": [    {      "name": "download",      "source": "./code/hero.tsx",      "destination": "src/components"    },    {      "name": "format-code",      "files": ["src/components/hero.tsx"]    }  ]}

To apply this template, run:

npx croct@latest use template.json5

Properties

These are the supported properties:

name
string

The action identifier. Always format-code for this action.

files
Array<string>

The list of file paths to format.