Skip to content

Commit bfd13c0

Browse files
gkalpakalxhub
authored andcommitted
refactor(docs-infra): fix docs examples for Angular-specific tslint rules (angular#38143)
This commit updates the docs examples to be compatible with the following Angular-specific tslint rules: - `component-selector` - `directive-selector` - `no-conflicting-lifecycle` - `no-host-metadata-property` - `no-input-rename` - `no-output-native` - `no-output-rename` This is in preparation of updating the docs examples `tslint.json` to match the one generated for new Angular CLI apps in a future commit. PR Close angular#38143
1 parent 5303773 commit bfd13c0

File tree

27 files changed

+40
-36
lines changed

27 files changed

+40
-36
lines changed

aio/content/examples/accessibility/src/app/progress-bar.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tslint:disable: no-host-metadata-property
12
// #docregion progressbar-component
23
import { Component, Input } from '@angular/core';
34

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { Component } from '@angular/core';
1+
import { Component, HostBinding } from '@angular/core';
22

33
@Component({
44
selector: 'comp-with-host-binding',
55
template: 'I am a component!',
6-
host: {
7-
'[class.special]': 'isSpecial',
8-
'[style.color]': 'color',
9-
'[style.width]': 'width'
10-
}
116
})
127
export class CompWithHostBindingComponent {
8+
@HostBinding('class.special')
139
isSpecial = false;
10+
11+
@HostBinding('style.color')
1412
color = 'green';
13+
14+
@HostBinding('style.width')
1515
width = '200px';
1616
}

aio/content/examples/component-interaction/src/app/hero-child.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ import { Hero } from './hero';
1212
})
1313
export class HeroChildComponent {
1414
@Input() hero: Hero;
15-
@Input('master') masterName: string;
15+
@Input('master') masterName: string; // tslint:disable-line: no-input-rename
1616
}
1717
// #enddocregion

aio/content/examples/dependency-injection-in-action/src/app/parent-finder.component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/* tslint:disable: no-unused-variable component-selector-name one-line space-before-function-paren */
2-
/* tslint:disable:*/
1+
/* tslint:disable: no-unused-variable component-selector one-line space-before-function-paren */
32
// #docplaster
43
// #docregion
54
import { Component, forwardRef, Optional, SkipSelf } from '@angular/core';
@@ -20,8 +19,7 @@ const DifferentParent = Parent;
2019
// The `parentType` defaults to `Parent` when omitting the second parameter.
2120
// #docregion provide-the-parent
2221
export function provideParent
23-
// #enddocregion provide-parent, provide-the-parent
24-
// #docregion provide-parent
22+
// #enddocregion provide-the-parent
2523
(component: any, parentType?: any) {
2624
return { provide: parentType || Parent, useExisting: forwardRef(() => component) };
2725
}

aio/content/examples/dynamic-component-loader/src/app/ad-banner.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { AdComponent } from './ad.component';
1111
template: `
1212
<div class="ad-banner-example">
1313
<h3>Advertisements</h3>
14-
<ng-template ad-host></ng-template>
14+
<ng-template adHost></ng-template>
1515
</div>
1616
`
1717
// #enddocregion ad-host

aio/content/examples/dynamic-component-loader/src/app/ad.directive.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
// tslint:disable: directive-selector
12
// #docregion
23
import { Directive, ViewContainerRef } from '@angular/core';
34

45
@Directive({
5-
selector: '[ad-host]',
6+
selector: '[adHost]',
67
})
78
export class AdDirective {
89
constructor(public viewContainerRef: ViewContainerRef) { }

aio/content/examples/elements/src/app/popup.component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// tslint:disable: variable-name
22
// #docregion
3-
import { Component, EventEmitter, Input, Output } from '@angular/core';
3+
import { Component, EventEmitter, HostBinding, Input, Output } from '@angular/core';
44
import { animate, state, style, transition, trigger } from '@angular/animations';
55

66
@Component({
@@ -9,9 +9,6 @@ import { animate, state, style, transition, trigger } from '@angular/animations'
99
<span>Popup: {{message}}</span>
1010
<button (click)="closed.next()">&#x2716;</button>
1111
`,
12-
host: {
13-
'[@state]': 'state',
14-
},
1512
animations: [
1613
trigger('state', [
1714
state('opened', style({transform: 'translateY(0%)'})),
@@ -41,6 +38,7 @@ import { animate, state, style, transition, trigger } from '@angular/animations'
4138
`]
4239
})
4340
export class PopupComponent {
41+
@HostBinding('@state')
4442
state: 'opened' | 'closed' = 'closed';
4543

4644
@Input()

aio/content/examples/event-binding/src/app/click.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* tslint:disable use-output-property-decorator directive-class-suffix */
1+
// tslint:disable: directive-selector
22
import { Directive, ElementRef, EventEmitter, Output } from '@angular/core';
33

44
@Directive({selector: '[myClick]'})

aio/content/examples/hierarchical-dependency-injection/src/app/hero-tax-return.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// tslint:disable: no-output-native
12
// #docregion
23
import { Component, EventEmitter, Input, Output } from '@angular/core';
34
import { HeroTaxReturn } from './hero';

aio/content/examples/inputs-outputs/src/app/aliasing/aliasing.component.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
/* tslint:disable:use-input-property-decorator */
2-
/* tslint:disable:use-output-property-decorator */
3-
4-
/* tslint:disable:no-input-rename */
5-
6-
1+
// tslint:disable: no-input-rename no-output-rename use-input-property-decorator use-output-property-decorator
72
import { Component, EventEmitter, Input, Output } from '@angular/core';
83

94
@Component({

0 commit comments

Comments
 (0)