View Source mix surface.format (surface v0.11.4)

Formatter Plugin Preferred

To format Surface code using Elixir 1.13 or later, use Surface.Formatter.Plugin.

Formats Surface ~F sigils and .sface files in the given files and patterns.

$ mix surface.format "lib/**/*.{ex,exs}" "test/**/*.{ex,exs}"
$ cat path/to/file.ex | mix surface.format -

Takes the same options as mix format except for --check-equivalent.

Formatting options

Like mix format, the Surface formatter reads a .formatter.exs file in the current directory for formatter configuration. The Surface formatter accepts the same options as mix format. Read more about the expected format of .formatter.exs and the shared configuration options documented here.

The Surface formatter also takes the following two additional options specified in .formatter.exs:

  • :surface_line_length overrides :line_length only for mix surface.format (:line_length is used otherwise, or defaults to 98)
  • :surface_inputs overrides :inputs only for mix surface.format (:inputs is used otherwise)

Task-specific options

The Surface formatter accepts the same task-specific options as mix format. Read documentation for the options documented here..

For quick reference, here are some examples of using these options:

$ mix surface.format --check-formatted
** (Mix) mix surface.format failed due to --check-formatted.
The following files are not formatted:
  * path/to/component.ex
  * path/to/file.sface
$ mix surface.format --dry-run
$ mix surface.format --dot-formatter path/to/.formatter.exs

You can also use the same syntax as mix format for specifying which files to format:

$ mix surface.format path/to/file.ex "lib/**/*.{ex,exs}" "test/**/*.{ex,exs}"