yarn add -D prettier prettier-plugin-eex
- printWidth - used by Prettier directly
- eexMultilineNoParens - Array - used to format multiline expressions, provide which functions shouldn't wrap parens around arguments
- eexMultilineLineLength - Number - used to format multiline expressions
Example:
{
"printWidth": 130,
"eexMultilineLineLength": 100,
"eexMultilineNoParens": [
"link",
"form_for"
]
}
Add .prettierignore file with:
deps/
_build/
.elixir_ls
assets
priv
And .prettierrc.js
module.exports = {
printWidth: 120,
};
cd assets
yarn add -D prettier prettier-plugin-eex
Add to mix.exs
aliases
and use as mix prettier
defp aliases do
[...
prettier: "cmd ./assets/node_modules/.bin/prettier --check . --color"
]
end
It's important to add node modules path.
"prettier.prettierPath": "./assets/node_modules/prettier"
Your code wasn't formatted correctly or there was an error? Add the problematic file to .prettierignore and submit an Issue.