or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

analysis.mdconfiguration.mdeditor-integration.mdformatting.mdindex.mdutilities.md
tile.json

formatting.mddocs/

Formatting Commands

Core formatting operations for checking and applying code formatting across files and languages. These commands form the primary interface for dprint's formatting capabilities.

Capabilities

Format Command

Applies formatting changes to files, either writing changes back to disk or displaying differences.

# Basic format command
dprint fmt [OPTIONS] [FILES...]

# Format options
--diff                  # Show differences instead of writing changes
--incremental <BOOL>    # Use incremental formatting (true/false)
--skip-stable-format    # Skip stable format verification
--allow-no-files        # Allow running with no matched files
--staged                # Format only staged files (git integration)

Usage Examples:

# Format all files in current directory
dprint fmt

# Show formatting differences without writing
dprint fmt --diff

# Format specific files
dprint fmt src/main.rs lib/utils.rs

# Format with glob patterns
dprint fmt "src/**/*.rs"

# Format only staged git files
dprint fmt --staged

# Format with incremental optimization
dprint fmt --incremental true

Check Command

Validates that files are properly formatted without making changes. Returns non-zero exit code if files need formatting.

# Basic check command
dprint check [OPTIONS] [FILES...]

# Check options
--incremental <BOOL>    # Use incremental checking (true/false)
--list-different        # List files that need formatting
--allow-no-files        # Allow running with no matched files
--staged                # Check only staged files (git integration)

Usage Examples:

# Check all files
dprint check

# List files that need formatting
dprint check --list-different

# Check specific files
dprint check src/main.rs

# Check staged files only
dprint check --staged

# Allow running with no files (useful in CI)
dprint check --allow-no-files

Standard Input Formatting

Format code from standard input, useful for editor integrations and pipe operations.

# Format from stdin with file extension
dprint fmt --stdin <EXTENSION>

# Format from stdin with file path  
dprint fmt --stdin <FILE_PATH>

Usage Examples:

# Format TypeScript from stdin
echo "const x=1" | dprint fmt --stdin ts

# Format with full file path context
cat src/main.rs | dprint fmt --stdin src/main.rs

# Pipe operations
git show HEAD:src/main.rs | dprint fmt --stdin rs

Incremental Formatting

Incremental formatting optimizes performance by only processing changed files and caching results.

# Enable/disable incremental mode
--incremental true      # Enable incremental formatting
--incremental false     # Disable incremental formatting
# Default: auto-detected based on project size

Behavior:

  • Tracks file modification times and content hashes
  • Caches formatting results and plugin state
  • Automatically invalidates cache on configuration changes
  • Provides significant performance improvements for large codebases

Git Integration

Both format and check commands integrate with git to process only relevant files.

# Process only staged files
--staged

# Combined with other options
dprint fmt --staged --diff     # Show diffs for staged files
dprint check --staged          # Check staged files only

Use Cases:

  • Pre-commit hooks: dprint check --staged
  • Selective formatting: dprint fmt --staged
  • CI integration with changed files only

File Pattern Matching

Control which files are processed using include/exclude patterns.

# Include patterns (processed first)
--includes "src/**/*.rs" --includes "tests/**/*.rs"

# Exclude patterns (applied after includes)
--excludes "target/**" --excludes "*.generated.rs"

# Allow node_modules processing (normally excluded)
--allow-node-modules

Pattern Examples:

# Format specific file types
dprint fmt --includes "**/*.{rs,ts,js}"

# Exclude build directories
dprint fmt --excludes "target/**" --excludes "dist/**"

# Complex pattern combination
dprint fmt \
  --includes "src/**/*.rs" \
  --includes "tests/**/*.rs" \
  --excludes "**/*.generated.rs" \
  --excludes "integration/**"

Error Handling

Exit Codes

# Format command exit codes
0   # Success - all files formatted successfully
14  # No files found matching patterns
20  # Check failed - files need formatting (check command only)

Common Error Scenarios

No Files Found:

# When no files match patterns
dprint fmt --includes "**/*.xyz"
# Exit code: 14

# Solution: Use --allow-no-files for CI
dprint fmt --includes "**/*.xyz" --allow-no-files

Check Failures:

# When files need formatting
dprint check
# Exit code: 20 if any files need formatting

# Use --list-different to see which files
dprint check --list-different

Plugin Resolution Errors

If plugins cannot be resolved or loaded:

# Error examples
dprint fmt  # Exit code 12: Plugin resolution error
dprint fmt  # Exit code 13: No plugins found

Performance Optimization

Incremental Mode

# Optimal for large codebases
dprint fmt --incremental true

# Force full formatting (development/debugging)
dprint fmt --incremental false

File Pattern Optimization

# Efficient: specific patterns
dprint fmt --includes "src/**/*.rs"

# Less efficient: overly broad patterns
dprint fmt --includes "**/*"

Staged File Processing

# Most efficient for git workflows
dprint fmt --staged

# Process minimal file set
git diff --name-only HEAD | xargs dprint fmt