18.0.17 • Published 9 months ago

@firestitch/lint v18.0.17

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Angular HTML Formatting Guide

Basic Elements

Empty Elements

Elements with no content and either no attributes or a single attribute should be on one line:

<custom-element></custom-element>
<button class="primary"></button>

Single-Line Elements

Elements with content but no attributes, or with a single attribute, should be on one line:

<span>Short text</span>
<br>

Elements with Single Attribute

Always keep element and its single attribute on the same line:

<div class="container"></div>
<button (click)="onClick()"></button>
<input type="text">

Multi-Attribute Elements

With Content

When an element has multiple attributes AND content:

  • Opening tag on its own line
  • Attributes indented with 4 spaces/2 indents
  • Each attribute on its own line
  • Content indented with 2 spaces/1 indent
  • Closing tag aligned with opening tag
<div
    class="container"
    [attr]="value"
    (click)="onClick()">
  Some content here
</div>

Without Content

When an element has multiple attributes but NO content:

  • Opening tag on its own line
  • Attributes indented with 2 spaces/1 indent
  • Each attribute on its own line
  • Closing tag on new line, aligned with opening tag
<app-header
  class="main-header"
  [title]="pageTitle"
  (menuClick)="onMenuClick()">
</app-header>

Comments

Comments should be preserved exactly as written in source:

<!-- This comment stays exactly as is -->

<!--
  Multi-line comments
  preserve their
  formatting
-->

Angular Control Flow Syntax

Control flow blocks should be properly indented:

@if (condition) {
  <div>Content</div>
} @else if (otherCondition) {
  <div>Other content</div>
} @else {
  <div>Default content</div>
}

@for (item of items) {
  <div>{{ item }}</div>
}

Interpolation

Interpolation should have consistent spacing:

<div>{{ value }}</div>
<span>Prefix {{ value }} suffix</span>

Nested Elements

Each nesting level adds 2 spaces of indentation(double indents):

<div class="parent">
  <div
      class="child"
      [attr]="value">
    <span>Content</span>
  </div>
</div>

Self-Closing Tags

Self-closing tags should remain self-closing and on one line:

<input type="text">
<input
  type="text"
  name="email">
<br>
18.0.16

9 months ago

18.0.17

9 months ago

18.0.11

10 months ago

18.0.12

10 months ago

18.0.13

10 months ago

18.0.9

10 months ago

18.0.10

10 months ago

18.0.8

10 months ago

18.0.7

10 months ago

18.0.6

10 months ago

18.0.5

10 months ago

18.0.4

10 months ago

18.0.3

10 months ago

18.0.2

10 months ago

18.0.1

10 months ago

18.0.0

10 months ago

15.0.0

10 months ago

17.0.0

10 months ago

16.0.0

10 months ago

14.0.11

1 year ago

14.0.10

1 year ago

14.0.9

1 year ago

14.0.6

1 year ago

14.0.7

1 year ago

14.0.8

1 year ago

14.0.1

1 year ago

14.0.2

1 year ago

14.0.3

1 year ago

14.0.4

1 year ago

14.0.5

1 year ago

13.0.9

1 year ago

14.0.0

2 years ago

12.0.20

2 years ago

12.0.19

2 years ago

13.0.8

2 years ago

12.0.17

2 years ago

12.0.18

2 years ago

13.0.6

2 years ago

13.0.7

2 years ago

13.0.4

2 years ago

13.0.5

2 years ago

13.0.2

2 years ago

13.0.3

2 years ago

13.0.0

2 years ago

13.0.1

2 years ago

12.0.16

2 years ago

12.0.15

2 years ago

12.0.14

2 years ago

12.0.13

3 years ago

12.0.12

3 years ago

12.0.11

3 years ago

12.0.10

3 years ago

12.0.9

3 years ago

12.0.8

3 years ago

12.0.7

3 years ago

12.0.6

3 years ago

12.0.5

3 years ago

12.0.4

3 years ago

12.0.3

3 years ago

12.0.2

3 years ago

12.0.1

3 years ago

12.0.0

3 years ago