npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

prettier-plugin-angular

v0.3.2

Published

Prettier plugin for Angular HTML attribute alignment and sorting

Readme

prettier-plugin-angular

A Prettier plugin for Angular HTML templates that formats, aligns, and sorts element attributes.

What it does

Attribute alignment

Attributes are formatted using the minimum number of lines needed:

  • Single line — if everything fits within printWidth:

    <input type="text" [value]="v" />
  • Aligned — first attribute inline with the tag, rest aligned to the same column:

    <p-select [options]="companiesForSelector()"
              [attr.aria-invalid]="form.controls.companyId.invalid"
              id="companyId"
              class="w-full"
              filter
              showClear />
  • Fallback — if the tag itself is too long to inline the first attribute, each attribute on its own line indented by tabWidth:

    <my-very-long-component-name
      [options]="items"
      (change)="onChange($event)"
      class="w-full" />

Attribute sorting

Attributes are sorted by category in this order:

| Category | Examples | |----------|---------| | ref | #myRef | | structural | *ngIf, *ngFor | | twoWay | [(ngModel)] | | input | [value], [disabled], [attr.aria-label] | | output | (click), (ngModelChange) | | animation | [@fadeIn] | | static | id="x", class="foo", formControlName="x" | | boolean | disabled, required, showIcon |

Self-closing elements

Elements with no real children are always output as self-closing, regardless of how they were written in the source:

<!-- Input -->
<app-my-component [value]="x" [label]="y"></app-my-component>

<!-- Output -->
<app-my-component [value]="x" [label]="y" />

This also applies to elements with only whitespace between their tags.

Angular control flow formatted

Elements inside @if, @for, @switch, @defer and other Angular control flow blocks are fully formatted — not emitted verbatim:

@if (form.controls.companyId.invalid && form.controls.companyId.touched) {
  <small id="companyId-error" class="p-error block mt-1" role="alert">
    {{ 'validation.required' | translate }}
  </small>
}

Install

npm install -D prettier-plugin-angular

Configure

In .prettierrc:

{
  "plugins": ["prettier-plugin-angular"],
  "overrides": [
    {
      "files": "*.html",
      "options": {
        "parser": "angular-attributes",
        "angularAttributeSort": true
      }
    }
  ]
}

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | angularAttributeSort | boolean | true | Sort attributes by category | | angularAttributeOrder | string[] | ["ref","structural","twoWay","input","output","animation","static","boolean"] | Category order (any subset, in your preferred order) |

Full example

Input:

<p-select class="w-full" (change)="onChange($event)" [options]="items" inputId="x" #sel showIcon />

Output:

<p-select [options]="items"
          (change)="onChange($event)"
          inputId="x"
          class="w-full"
          #sel
          showIcon />