Skip to main content

auto_format

Function auto_format 

Source
pub fn auto_format(path: &Path, config: &Config) -> (bool, Option<String>)
Expand description

Auto-format a file using the detected formatter for its language.

Returns (formatted, skip_reason):

  • (true, None) — file was successfully formatted
  • (false, Some(reason)) — formatting was skipped, reason explains why

Skip reasons:

  • "unsupported_language" — language has no formatter support in AFT
  • "no_formatter_configured"format_on_edit=false or no formatter detected for the language in the project
  • "formatter_not_installed" — configured formatter binary missing on PATH and not in project’s node_modules/.bin
  • "formatter_excluded_path" — formatter ran but refused to process this path because the project formatter config (e.g. biome.json files.includes, prettier .prettierignore) excludes it. NOT an error in AFT or the user’s formatter — the user told the formatter not to touch this path. Agents should treat this as informational.
  • "timeout" — formatter exceeded formatter_timeout_secs
  • "error" — formatter exited non-zero with an unrecognized error (likely a real bug in the user’s input or the formatter itself)