Prettier is an opinionated code formatter. Prettier does not support the experimental syntax (similar to .tsx
) that .gjs
components are authored in.
This plugin was forked from and is heavily based on @glimmerx/prettier-plugin-component-templates
.
This plugin extends the internal printers to handle .gjs
syntax (usage of <template>
syntax alongside familiar .js
and .ts
syntax).
yarn add -D <TODO(jdurham): identifier of wherever this ends up>
Once added prettier will discover and use the plugin to format any .gjs
tagged template expression.
In your prettier config options (e.g. .prettierrc
, prettier.config.js
, etc.)
.prettierrc
{
"hbsSingleQuote": true
}
Defaults to false
forcing double-quotes for all attributes in an hbs embed. When true
will rewrite all quotes to single-quotes.
Generate a test case, add it to the tests file,
Add PRETTIER_DEBUG=true
to the environment when running the plugin in order to get complete stack traces on errors.
PRETTIER_DEBUG=true node --inspect-brk node_modules/.bin/prettier --config=./test/fixtures/basic/config.js ./test/fixtures/basic/code.js
node node_modules/.bin/prettier --ignore-path --config=./test/fixtures/simple-formatted/config.js ./test/fixtures/simple-formatted/code.js > ./test/fixtures/simple-formatted/output.js
yarn test