View Source mix es6_maps.format (es6_maps v0.2.0)
Replaces all map keys with their shorthand form.
mix es6_maps.format 'lib/**/*.ex' 'test/**/*.exs'
The arguments are expanded with Path.wildcard(match_dot: true).
The task manipulates the AST, not raw strings, so it's precise and will only change your code by:
- changing map keys into the shorthand form;
- reordering map keys so the shorthand form comes first;
- formatting the results with
mix format.
Going back to old-style maps
You can revert all of the ES6-style shorthand uses with the --revert format flag:
mix es6_maps.format --revert lib/myapp/myapp.ex
Reordering map keys
When applicable, the formatting will reorder the keys to shorthand them, for example:
%{hello: "world", foo: foo, bar: bar} = varwill become:
%{foo, bar, hello: "world"} = varOptions
--revert- Reverts the transformation.--locals-without-parens- Specifies a list of locals that should not have parentheses. The format islocal_name/arity, wherearitycan be an integer or*. This option can be given multiple times, and/or multiple values can be separated by commas.