
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
prettier-plugin-angular
Advanced tools
A Prettier plugin for Angular HTML templates that formats, aligns, and sorts element attributes.
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" />
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 |
Developer-written multi-line values (e.g. ternary expressions) are preserved and re-indented to match the attribute's column:
<p-select [options]="items"
[attr.aria-describedby]="
form.controls.companyId.invalid && form.controls.companyId.touched
? 'companyId-error'
: null
"
id="companyId" />
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>
}
npm install -D prettier-plugin-angular
In .prettierrc:
{
"plugins": ["prettier-plugin-angular"],
"overrides": [
{
"files": "*.html",
"options": {
"parser": "angular-attributes",
"angularAttributeSort": true
}
}
]
}
| 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) |
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 />
FAQs
Prettier plugin for Angular HTML attribute alignment and sorting
The npm package prettier-plugin-angular receives a total of 186 weekly downloads. As such, prettier-plugin-angular popularity was classified as not popular.
We found that prettier-plugin-angular demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.