Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-template-lint-plugin-prettier

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-template-lint-plugin-prettier

A prettier plugin for ember-template-lint

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

ember-template-lint-plugin-prettier 👋

It uses Prettier to lint your handlebars templates with ember-template-lint. The plugin defines a - single - rule. That rule will compare your code with Prettier's output.

⚠️ Prettier support for handlebars is still experimental ⚠️

Here is an output example:

error: Replace `New·Addons</h1>` with <h1>⏎New Addons⏎</h1>` (prettier/prettier) at app/templates/lists/new-addons.hbs:2:5:
  1 | <div class="addons-index">
> 2 |   <h1>New Addons</h1>
  3 |   {{addon-list addons=model}}
  4 | </div>

./node_modules/.bin/ember-template-lint app/templates/lists/new-addons.hbs (code from emberobserver).

Install

yarn add -D prettier ember-template-lint-plugin-prettier

As peerDependencies, prettier and ember-template-lint will have to be installed in your project. Prettier version local to the project will be used (not any global one!).

A recommended configuration is available. To use it, merge the following object to your .templatelintrc.js file:

module.exports = {
  plugins: ["ember-template-lint-plugin-prettier"],

  extends: ["recommend", "ember-template-lint-plugin-prettier:recommended"],
  },
};

The recommended set will apply these rules.

Warnings

General

Handlebars support is still experimental in Prettier! So, between Prettier upgrades, you'll probably find out that your code is formatted in a slightly different way. Also, a few bug fixes are in progress. You can follow the work in progress here.

Special warning: bare strings in templates (ie. )

Are you're using bare strings in your templates? If you're unsure, you can lint your templates against this rule.

If you do so, you implicitly rely on your templates whitespaces. As such, you most probably want to wait before using this package. Indeed, whitespaces / newlines handling is still not 100% settled in Prettier.

Tips

You may want to define these two scripts in your package.json:

{
  "scripts": {
    "lint:hbs": "ember-template-lint .",
    "format:hbs": "prettier **/*.hbs --write --parser=glimmer"
  }
}

yarn lint:hbs is useful in CI. yarn format:hbs will let you format your templates if your editor does not have this feature yet.

Examples

Here is an early example of usage in emberobserver source code. As you can see, it's illustrating the whitespaces / newlines issue with bare strings.

Here is another early example of usage in ember-osf-web.

Credits

This plugin has been inspired by the prettier plugin for Eslint.

Contributing

See CONTRIBUTING.md

Keywords

FAQs

Package last updated on 27 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc