Prettier Plugin Ember Template Tag

raw JSON →
2.1.5 verified Sat Apr 25 auth: no javascript

A Prettier plugin for formatting Ember template tags in .gjs and .gts files, currently at version 2.1.5. It requires Prettier >= 3.0.0 and Node 18+ or 20+. The plugin integrates Prettier's babel-ts parser for the script portion and the glimmer parser for template content, providing seamless formatting for Ember's first-class component templates. Unlike alternative approaches (e.g., using eslint-plugin-ember), this plugin is the recommended official solution for formatting GJS/GTS files. Releases follow a patch/minor cadence with active maintenance from the Ember Tooling team. Notable recent changes include dual CJS/ESM output since v2.1.0, and fix for comment formatting crash in v2.1.4.

error Cannot find module 'prettier-plugin-ember-template-tag'
cause Plugin not installed or incorrect import path in config.
fix
Install plugin: npm install --save-dev prettier-plugin-ember-template-tag. Use string name in plugins array, not a path.
error Error: Couldn't resolve plugin "prettier-plugin-ember-template-tag"
cause Plugin not installed or not in node_modules, or prettier version < 3.0.0.
fix
Check if plugin is installed. Ensure prettier >= 3.0.0.
error TypeError: prettier.resolveConfig.sync is not a function
cause Using incompatible version of prettier-plugin-ember-template-tag with Prettier 2.x.
fix
Upgrade to Prettier 3+ or downgrade plugin to v1.x.
error Error: You cannot use .gjs files with prettier-plugin-ember-template-tag without the plugin
cause Prettier is run without the plugin enabled, and does not recognize .gjs/.gts extensions.
fix
Add 'prettier-plugin-ember-template-tag' to the plugins array in config or use --plugin flag.
breaking Requires Prettier >= 3.0.0. Prettier 2.x is not supported.
fix Upgrade to Prettier 3+.
breaking v2.0.0 dropped support for Prettier 2.x and changed plugin initialization behavior.
fix Ensure Prettier version is >=3.0.0. Update configuration as needed.
deprecated With eslint-plugin-ember <12, use plugin version 1.1.0.
fix If using eslint-plugin-ember <12, downgrade plugin to 1.1.0. Otherwise upgrade eslint-plugin-ember to >=12.
gotcha When using Prettier < 3.1, the --plugin flag must be used explicitly (e.g., --plugin prettier-plugin-ember-template-tag).
fix Use prettier >=3.1 and the plugins array in config, or add --plugin flag to command.
gotcha If you have a `"prettier"` section in package.json, it takes precedence over .prettierrc.js.
fix Remove the prettier section from package.json or ensure consistency between both config sources.
gotcha The plugin does not support formatting .hbs files; only .gjs and .gts.
fix Use separate handlebars prettier plugin for .hbs files.
npm install prettier-plugin-ember-template-tag
yarn add prettier-plugin-ember-template-tag
pnpm add prettier-plugin-ember-template-tag

Shows how to configure Prettier with the plugin for .gjs/.gts files, including overrides for single quotes and trailing commas.

// .prettierrc.js
module.exports = {
  plugins: ['prettier-plugin-ember-template-tag'],
  overrides: [
    {
      files: '*.{js,ts,gjs,gts}',
      options: {
        singleQuote: true,
        trailingComma: 'all',
      },
    },
  ],
};

// Then run:
// prettier --write . (Prettier >= 3.1)
// prettier --write . --plugin prettier-plugin-ember-template-tag (Prettier < 3.1)