Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(*): enabled self-closing-tags #1635

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ module.exports = {
{
files: ['*.html'],
extends: ['plugin:@angular-eslint/template/recommended'],
rules: {}
rules: {
"@angular-eslint/template/prefer-self-closing-tags": "error"
}
},
{
files: ['*.html'],
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/avatar-list/avatar-list-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from '@a
@Component({
selector: 'avatar-list-item, [avatar-list-item]',
exportAs: 'avatarListItem',
template: `<ng-content></ng-content>`,
template: `<ng-content />`,
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
Expand Down
11 changes: 3 additions & 8 deletions packages/abc/avatar-list/avatar-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@
[nzText]="i.text"
[nzIcon]="i.icon"
[nzSize]="avatarSize"
></nz-avatar>
<nz-avatar *ngIf="!i.tips" [nzSrc]="i.src" [nzText]="i.text" [nzIcon]="i.icon" [nzSize]="avatarSize"></nz-avatar>
/>
<nz-avatar *ngIf="!i.tips" [nzSrc]="i.src" [nzText]="i.text" [nzIcon]="i.icon" [nzSize]="avatarSize" />
</li>
<li *ngIf="exceedCount > 0" [ngClass]="cls">
<nz-avatar
[nzSize]="avatarSize"
style="cursor: auto"
[ngStyle]="excessItemsStyle"
[nzText]="'+' + exceedCount"
></nz-avatar>
<nz-avatar [nzSize]="avatarSize" style="cursor: auto" [ngStyle]="excessItemsStyle" [nzText]="'+' + exceedCount" />
</li>
</ul>
19 changes: 5 additions & 14 deletions packages/abc/avatar-list/avatar-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,11 @@ describe('abc: avatar-list', () => {
@Component({
template: `
<avatar-list [size]="size" [maxLength]="maxLength">
<avatar-list-item
tips="Jake"
src="https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png"
></avatar-list-item>
<avatar-list-item
tips="Andy"
src="https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png"
></avatar-list-item>
<avatar-list-item
tips="Niko"
src="https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png"
></avatar-list-item>
<avatar-list-item tips="Cipchk" text="Cipchk"></avatar-list-item>
<avatar-list-item tips="heart-o"></avatar-list-item>
<avatar-list-item tips="Jake" src="https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png" />
<avatar-list-item tips="Andy" src="https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png" />
<avatar-list-item tips="Niko" src="https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png" />
<avatar-list-item tips="Cipchk" text="Cipchk" />
<avatar-list-item tips="heart-o" />
</avatar-list>
`
})
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/count-down/count-down.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { CountdownComponent, CountdownConfig, CountdownEvent } from 'ngx-countdo
@Component({
selector: 'count-down',
exportAs: 'countDown',
template: ` <countdown #cd *ngIf="config" [config]="config" (event)="handleEvent($event)"></countdown> `,
template: `<countdown #cd *ngIf="config" [config]="config" (event)="handleEvent($event)" />`,
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
Expand Down
4 changes: 2 additions & 2 deletions packages/abc/count-down/count-down.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ describe('abc: count-down', () => {
@Component({
template: `
<div *ngIf="config">
<count-down [config]="config" (event)="handleEvent()" style="font-size: 20px"></count-down>
<count-down [config]="config" (event)="handleEvent()" style="font-size: 20px" />
</div>
<div *ngIf="target">
<count-down [target]="target" (event)="handleEvent()" style="font-size: 20px"></count-down>
<count-down [target]="target" (event)="handleEvent()" style="font-size: 20px" />
</div>
`
})
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/date-picker/range.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('abc: date-picker: nz-range-picker[extend]', () => {
extend
[(ngModelEnd)]="i.end"
[shortcut]="shortcut"
></nz-range-picker>
/>
`
})
class TestComponent {
Expand Down
4 changes: 2 additions & 2 deletions packages/abc/ellipsis/ellipsis.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div (cdkObserveContent)="refresh()" #orgEl style="display: none"><ng-content></ng-content></div>
<div (cdkObserveContent)="refresh()" #orgEl style="display: none"><ng-content /></div>
<ng-template #tooltipTpl let-con>
<span
*ngIf="tooltip; else con"
nz-tooltip
[nzTooltipTitle]="titleTpl"
[nzTooltipOverlayStyle]="{ 'overflow-wrap': 'break-word', 'word-wrap': 'break-word' }"
>
<ng-container *ngTemplateOutlet="con"></ng-container>
<ng-container *ngTemplateOutlet="con" />
<ng-template #titleTpl><div [innerHTML]="orgHtml"></div></ng-template>
</span>
</ng-template>
Expand Down
4 changes: 2 additions & 2 deletions packages/abc/error-collect/error-collect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('abc: error-collect', () => {

it('should be throw [No found form element] if no form element', () => {
expect(() => {
TestBed.overrideTemplate(TestComponent, `<error-collect #ec [freq]="freq"></error-collect>`)
TestBed.overrideTemplate(TestComponent, `<error-collect #ec [freq]="freq" />`)
.createComponent(TestComponent)
.detectChanges();
}).toThrowError('No found form element');
Expand All @@ -95,7 +95,7 @@ describe('abc: error-collect', () => {
<input nz-input formControlName="email" id="email" />
</nz-form-control>
</nz-form-item>
<error-collect #ec [freq]="freq" [offsetTop]="offsetTop"></error-collect>
<error-collect #ec [freq]="freq" [offsetTop]="offsetTop" />
</form>
`
})
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/exception/exception.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h1 class="exception__cont-title" [innerHTML]="_title"></h1>
<div class="exception__cont-desc" [innerHTML]="_desc || locale[_type]"></div>
<div class="exception__cont-actions">
<div (cdkObserveContent)="checkContent()" #conTpl>
<ng-content></ng-content>
<ng-content />
</div>
<button *ngIf="!hasCon" nz-button [routerLink]="backRouterLink" [nzType]="'primary'">
{{ locale.backToHome }}
Expand Down
4 changes: 2 additions & 2 deletions packages/abc/footer-toolbar/footer-toolbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<ng-container *nzStringTemplateOutlet="extra">{{ extra }}</ng-container>
</div>
<div class="footer-toolbar__right">
<error-collect *ngIf="errorCollect"></error-collect>
<ng-content></ng-content>
<error-collect *ngIf="errorCollect" />
<ng-content />
</div>
2 changes: 1 addition & 1 deletion packages/abc/footer-toolbar/footer-toolbar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('abc: footer-toolbar', () => {
});

@Component({
template: ` <form><footer-toolbar [errorCollect]="errorCollect" [extra]="extra"></footer-toolbar></form> `
template: ` <form><footer-toolbar [errorCollect]="errorCollect" [extra]="extra" /></form> `
})
class TestComponent {
errorCollect = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/full-content/full-content.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const hideTitleCls = `full-content__hidden-title`;
@Component({
selector: 'full-content',
exportAs: 'fullContent',
template: ` <ng-content></ng-content> `,
template: ` <ng-content /> `,
host: {
'[class.full-content]': 'true',
'[style.height.px]': '_height'
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/global-footer/global-footer-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BooleanInput, InputBoolean } from '@delon/util/decorator';
@Component({
selector: 'global-footer-item',
exportAs: 'globalFooterItem',
template: ` <ng-template #host><ng-content></ng-content></ng-template> `,
template: ` <ng-template #host><ng-content /></ng-template> `,
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
Expand Down
4 changes: 2 additions & 2 deletions packages/abc/global-footer/global-footer.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div *ngIf="links.length > 0 || items.length > 0" class="global-footer__links">
<a *ngFor="let i of links" class="global-footer__links-item" (click)="to(i)" [innerHTML]="i._title"></a>
<a *ngFor="let i of items" class="global-footer__links-item" (click)="to(i)">
<ng-container *ngTemplateOutlet="i.host"></ng-container>
<ng-container *ngTemplateOutlet="i.host" />
</a>
</div>
<div class="global-footer__copyright">
<ng-content></ng-content>
<ng-content />
</div>
2 changes: 1 addition & 1 deletion packages/abc/loading/loading.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="loading-default__icon" *ngIf="options.type! !== 'text'">
<ng-container [ngSwitch]="options.type!">
<nz-spin *ngSwitchCase="'spin'" nzSimple></nz-spin>
<nz-spin *ngSwitchCase="'spin'" nzSimple />
<i *ngSwitchCase="'icon'" nz-icon [nzType]="icon.type!" [nzTheme]="icon.theme!" [nzSpin]="icon.spin"></i>
<div *ngSwitchDefault class="loading-default__custom" [ngStyle]="custom.style!" [innerHTML]="custom.html"></div>
</ng-container>
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/media/media.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type MediaType = 'html5' | 'youtube' | 'video' | 'audio';
@Component({
selector: 'media',
exportAs: 'mediaComponent',
template: `<ng-content></ng-content>`,
template: `<ng-content />`,
host: {
'[style.display]': `'block'`
},
Expand Down
10 changes: 5 additions & 5 deletions packages/abc/media/media.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ describe('abc: media', () => {
}
});

// NOTE: <span></span> 当前不管是否有禁用eslint标签都会导致强制自关闭
@Component({
template: `
<media #comp [type]="type" [source]="source" [options]="options" [delay]="delay" (ready)="ready()"></media>
`
template: ` <media #comp [type]="type" [source]="source" [options]="options" [delay]="delay" (ready)="ready()">
<span></span>
</media>`
})
class TestComponent {
@ViewChild('comp') comp!: MediaComponent;
Expand All @@ -116,7 +117,6 @@ class TestComponent {
ready(): void {}
}
@Component({
template: `<media #comp [source]="source"><video data-type="custom"></video></media>
<media [source]="source"></media>`
template: `<media #comp [source]="source"><video data-type="custom"></video></media>`
})
class TestCustomVideoComponent extends TestComponent {}
12 changes: 6 additions & 6 deletions packages/abc/notice-icon/notice-icon-tab.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
<nz-list-item (click)="onClick(item)" [ngClass]="{ 'notice-icon__item-read': item.read }">
<nz-list-item-meta [nzTitle]="nzTitle" [nzDescription]="nzDescription" [nzAvatar]="item.avatar">
<ng-template #nzTitle>
<ng-container *nzStringTemplateOutlet="item.title; context: { $implicit: item }">{{
item.title
}}</ng-container>
<ng-container *nzStringTemplateOutlet="item.title; context: { $implicit: item }">
{{ item.title }}
</ng-container>
<div class="notice-icon__item-extra" *ngIf="item.extra">
<nz-tag [nzColor]="item.color">{{ item.extra }}</nz-tag>
</div>
</ng-template>
<ng-template #nzDescription>
<div *ngIf="item.description" class="notice-icon__item-desc">
<ng-container *nzStringTemplateOutlet="item.description; context: { $implicit: item }">{{
item.description
}}</ng-container>
<ng-container *nzStringTemplateOutlet="item.description; context: { $implicit: item }">
{{ item.description }}
</ng-container>
</div>
<div *ngIf="item.datetime" class="notice-icon__item-time">{{ item.datetime }}</div>
</ng-template>
Expand Down
11 changes: 3 additions & 8 deletions packages/abc/notice-icon/notice-icon.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</nz-badge>
</ng-template>
<div *ngIf="data!.length === 0">
<ng-template [ngTemplateOutlet]="badgeTpl"></ng-template>
<ng-template [ngTemplateOutlet]="badgeTpl" />
</div>
<div
*ngIf="data!.length > 0"
Expand All @@ -16,18 +16,13 @@
[nzOverlayClassName]="overlayCls"
[nzDropdownMenu]="noticeMenu"
>
<ng-template [ngTemplateOutlet]="badgeTpl"></ng-template>
<ng-template [ngTemplateOutlet]="badgeTpl" />
</div>
<nz-dropdown-menu #noticeMenu="nzDropdownMenu">
<nz-spin [nzSpinning]="loading" [nzDelay]="0">
<nz-tabset nzSelectedIndex="0" [nzCentered]="centered">
<nz-tab *ngFor="let i of data" [nzTitle]="i.title">
<notice-icon-tab
[locale]="locale"
[data]="i"
(select)="onSelect($event)"
(clear)="onClear($event)"
></notice-icon-tab>
<notice-icon-tab [locale]="locale" [data]="i" (select)="onSelect($event)" (clear)="onClear($event)" />
</nz-tab>
</nz-tabset>
</nz-spin>
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/notice-icon/notice-icon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('abc: notice-icon', () => {
(clear)="clear($event)"
[(popoverVisible)]="popoverVisible"
(popoverVisibleChange)="popupVisibleChange($event)"
></notice-icon>
/>
`
})
class TestComponent {
Expand Down
14 changes: 7 additions & 7 deletions packages/abc/page-header/page-header.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<nz-affix #affix *ngIf="isBrowser && fixed; else phTpl" [nzOffsetTop]="fixedOffsetTop">
<ng-template [ngTemplateOutlet]="phTpl"></ng-template>
<ng-template [ngTemplateOutlet]="phTpl" />
</nz-affix>
<ng-template #phTpl>
<div class="page-header" [class.page-header-rtl]="dir === 'rtl'">
Expand All @@ -24,29 +24,29 @@
</ng-container>
<div class="page-header__detail">
<div *ngIf="logo" class="page-header__logo">
<ng-template [ngTemplateOutlet]="logo"></ng-template>
<ng-template [ngTemplateOutlet]="logo" />
</div>
<div class="page-header__main">
<div class="page-header__row">
<h1 *ngIf="_titleVal || _titleTpl" class="page-header__title">
<ng-container *ngIf="_titleVal; else _titleTpl">{{ _titleVal }}</ng-container>
</h1>
<div *ngIf="action" class="page-header__action">
<ng-template [ngTemplateOutlet]="action"></ng-template>
<ng-template [ngTemplateOutlet]="action" />
</div>
</div>
<div class="page-header__row">
<div class="page-header__desc" (cdkObserveContent)="checkContent()" #conTpl>
<ng-content></ng-content>
<ng-template [ngTemplateOutlet]="content!"></ng-template>
<ng-content />
<ng-template [ngTemplateOutlet]="content!" />
</div>
<div *ngIf="extra" class="page-header__extra">
<ng-template [ngTemplateOutlet]="extra"></ng-template>
<ng-template [ngTemplateOutlet]="extra" />
</div>
</div>
</div>
</div>
<ng-template [ngTemplateOutlet]="tab!"></ng-template>
<ng-template [ngTemplateOutlet]="tab!" />
</nz-skeleton>
</div>
</div>
Expand Down
10 changes: 2 additions & 8 deletions packages/abc/page-header/page-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,7 @@ class TestComponent extends TestBaseComponent {}

@Component({
template: `
<page-header
#comp
[title]="title"
[home]="home"
[homeI18n]="homeI18n"
[autoBreadcrumb]="autoBreadcrumb"
></page-header>
<page-header #comp [title]="title" [home]="home" [homeI18n]="homeI18n" [autoBreadcrumb]="autoBreadcrumb" />
`
})
class TestAutoBreadcrumbComponent extends TestBaseComponent {}
Expand All @@ -483,7 +477,7 @@ class TestAutoBreadcrumbComponent extends TestBaseComponent {}
[homeI18n]="homeI18n"
[homeLink]="homeLink"
[autoBreadcrumb]="autoBreadcrumb"
></page-header>
/>
`
})
class TestI18nComponent extends TestBaseComponent {}
2 changes: 1 addition & 1 deletion packages/abc/pdf/pdf.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const BORDER_WIDTH = 9;
selector: 'pdf',
exportAs: 'pdf',
template: `
<nz-skeleton *ngIf="!inited || loading"></nz-skeleton>
<nz-skeleton *ngIf="!inited || loading" />
<div class="pdf-container">
<div class="pdfViewer"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/pdf/pdf.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('abc: pdf', () => {
});

@Component({
template: ` <pdf #comp [src]="src" [options]="options" [delay]="delay" (change)="change()"></pdf> `
template: ` <pdf #comp [src]="src" [options]="options" [delay]="delay" (change)="change()" /> `
})
class TestComponent {
@ViewChild('comp') comp!: PdfComponent;
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/qr/qr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('abc: qr', () => {
[padding]="padding"
[size]="size"
(change)="change($event)"
></qr>
/>
`
})
class TestComponent {
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/quick-menu/quick-menu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
</ng-container>
</div>
</div>
<ng-content></ng-content>
<ng-content />
</div>
Loading