For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /guide/cli/fmt.md.
  • English
  • fmt

    The rs fmt command is built on Prettier. It processes files in parallel by default and uses the high-performance Yuku parser for JavaScript and TypeScript, providing better performance than using Prettier directly.

    Usage

    rs fmt [options] [files/globs...]

    Pass files, directories, or glob patterns to select what to format. When no inputs are provided, rs fmt formats the current directory. rs format is an alias for rs fmt.

    Options

    OptionDescription
    --writeWrite formatted files in place. This is the default mode.
    --checkCheck formatting without writing files. Exits with code 1 when files are different.
    --list-differentPrint only unformatted paths. Exits with code 1 when files are different.
    --parallel-workers <count>Set the maximum number of formatting workers.
    -h, --helpDisplay usage and option information.

    --write, --check, and --list-different are mutually exclusive.

    Examples:

    # Format the current directory in place
    rs fmt
    
    # Format specific files and directories
    rs fmt src package.json
    
    # Include and exclude files with quoted globs
    rs fmt "src/**/*.{js,ts}" "!src/generated/**"
    
    # Check formatting in CI
    rs fmt --check

    File discovery

    Directory and glob discovery follows .gitignore files, skips binary files, and does not traverse version-control directories or node_modules. Files for which Prettier cannot infer a parser are skipped.

    Use ignorePatterns for additional project-specific exclusions. Both positive and negative input globs are resolved from the current working directory.

    Configuration

    Configure formatting through define.fmt() in the Rstack configuration file:

    rstack.config.ts
    import { define } from 'rstack';
    
    define.fmt({
      printWidth: 100,
      singleQuote: true,
      sortPackageJson: true,
      ignorePatterns: ['dist/**'],
      overrides: [
        {
          files: '*.md',
          options: {
            proseWrap: 'always',
          },
        },
      ],
    });

    define.fmt() accepts standard Prettier options and the overrides field, plus these Rstack options:

    • ignorePatterns: Gitignore-compatible patterns relative to the directory containing rstack.config.ts.
    • sortPackageJson: Sort package.json fields before formatting. The default value is false.
    Configuration sources

    rs fmt does not load Prettier configuration files, .prettierignore, or .editorconfig. Move those settings and ignore rules into define.fmt().

    When using Prettier plugins, pass each plugin as a package name, file path, or URL. Imported plugin objects are not supported because formatting runs in workers. Package names and relative paths are resolved from the Rstack configuration directory.