Can .formatter.exs ignore some files

Is it possible to configure the formatter to exclude some files?

I’m currently using this as the default .formatter.exs:

  inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]

However there are some files in test/support that intentionally have compilation errors and I would like to ignore those. Is there any way beside “manually” ignoring the specific file by adding an entry for every file in the offending directory except for that single file?

IIRC you can do

  inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] -- ["lib/foo/bar.ex"]

Not tested though, I just remember seeing it mentioned somewhere in the past.


Having played around I think it’s actually something like this:

  inputs: Enum.flat_map(["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"], & Path.wildcard(&1, match_dot: true)) -- ["lib/foo/bar.ex"]

So you handle the wildcard expansion yourself.


That didn’t work for me and as written I wouldn’t expect it to since the -- runs before inputs is expanded by Path.wildcard

Yeah sorry, just edited my reply

Oh, okay. I’ll give that a try later :+1:

The edited version of this works!