Skip to content

Commit

Permalink
style(module:all): fix tslint (#691)
Browse files Browse the repository at this point in the history
  • Loading branch information
trotyl authored and vthinkxie committed Dec 7, 2017
1 parent c6c28b8 commit b5e9aee
Show file tree
Hide file tree
Showing 178 changed files with 2,399 additions and 2,200 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ branches:
env:
- TASK=build
- TASK=test
- TASK=lint
- TASK=integration-cli
- TASK=integration-webpack
- TASK=integration-rollup
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"integration-cli": "npm run generate && cd integration/angular-cli && npm run integration",
"integration-webpack": "npm run generate && cd integration/webpack && npm run integration",
"integration-rollup": "npm run generate && cd integration/rollup && npm run integration",
"lint": "ng lint",
"lint": "tslint -c tslint.json 'src/components/**/*.ts'",
"e2e": "ng e2e"
},
"main": "./bundles/antd.umd.js",
Expand Down
19 changes: 12 additions & 7 deletions src/components/affix/nz-affix.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed, ComponentFixtureAutoDetect, fakeAsync, tick } from '@angular/core/testing';
/* tslint:disable:no-unused-variable prefer-const */
import { Component, DebugElement } from '@angular/core';
import { async, fakeAsync, tick, ComponentFixture, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';

import { NzScrollService } from '../core/scroll/nz-scroll.service';
import { NzAffixComponent } from './nz-affix.component';
import { NzAffixModule } from './nz-affix.module';
import { NzScrollService } from "../core/scroll/nz-scroll.service";
import { NzAffixComponent } from "./nz-affix.component";

describe('Component:nz-affix', () => {

let scrollSrv: MockNzScrollService;
let fixture: ComponentFixture<TestAffixComponent>;
let context: TestAffixComponent;
Expand Down Expand Up @@ -39,9 +38,15 @@ describe('Component:nz-affix', () => {

});

@Component({ template: `<nz-affix [nzOffsetTop]="10" (nzChange)="onChange($event)"><button>Affix Button</button></nz-affix>` })
@Component({
template: `
<nz-affix [nzOffsetTop]="10" (nzChange)="onChange($event)">
<button>Affix Button</button>
</nz-affix>
`
})
class TestAffixComponent {
onChange(status: boolean) {
onChange(status: boolean): boolean {
return status;
}
}
Expand Down
31 changes: 15 additions & 16 deletions src/components/affix/nz-affix.component.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {
AfterViewInit,
Component,
ViewEncapsulation,
OnInit,
Input,
ElementRef,
EventEmitter,
Output,
Input,
OnDestroy,
OnInit,
Output,
ViewChild,
ElementRef,
AfterViewInit
ViewEncapsulation,
} from '@angular/core';
import { fromEvent } from 'rxjs/observable/fromEvent';
import { Subscription } from 'rxjs/Subscription';
import { throttleTime } from 'rxjs/operators/throttleTime';
import { fromEvent } from 'rxjs/observable/fromEvent';
import { distinctUntilChanged } from 'rxjs/operators/distinctUntilChanged';
import { throttleTime } from 'rxjs/operators/throttleTime';

import { NzScrollService } from '../core/scroll/nz-scroll.service';

Expand All @@ -32,7 +32,7 @@ import { NzScrollService } from '../core/scroll/nz-scroll.service';
export class NzAffixComponent implements OnInit, OnDestroy, AfterViewInit {

private didScroll = false;
private scrollTime: any = null;
private scrollTime: number = null;
private scroll$: Subscription = null;
private scrollWinInTarget$: Subscription = null;
private target: Element = null;
Expand All @@ -54,8 +54,7 @@ export class NzAffixComponent implements OnInit, OnDestroy, AfterViewInit {

@Output() nzChange: EventEmitter<boolean> = new EventEmitter();

constructor(private scrollSrv: NzScrollService, private _el: ElementRef) {
}
constructor(private scrollSrv: NzScrollService, private _el: ElementRef) { }

ngOnInit(): void {
if (!this.scroll$) {
Expand All @@ -72,7 +71,7 @@ export class NzAffixComponent implements OnInit, OnDestroy, AfterViewInit {
return this.target || window;
}

private reCalculate() {
private reCalculate(): this {
const elOffset = this.scrollSrv.getOffset(this._el.nativeElement);
this.orgOffset = {
top : elOffset.top + this.scrollSrv.getScroll(this.getTarget()),
Expand All @@ -82,7 +81,7 @@ export class NzAffixComponent implements OnInit, OnDestroy, AfterViewInit {
return this;
}

private process() {
private process(): void {
if (!this.orgOffset) {
this.reCalculate();
}
Expand All @@ -105,7 +104,7 @@ export class NzAffixComponent implements OnInit, OnDestroy, AfterViewInit {
this.nzChange.emit(hasFixed);
}

private removeListen() {
private removeListen(): void {
if (this.scrollTime) {
clearTimeout(this.scrollTime);
}
Expand All @@ -117,10 +116,10 @@ export class NzAffixComponent implements OnInit, OnDestroy, AfterViewInit {
}
}

private registerScrollEvent() {
private registerScrollEvent(): void {
this.removeListen();
this.reCalculate().process();
this.scrollTime = setInterval(() => {
this.scrollTime = window.setInterval(() => {
if (this.didScroll) {
this.didScroll = false;
this.process();
Expand Down
5 changes: 2 additions & 3 deletions src/components/affix/nz-affix.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

import { SCROLL_SERVICE_PROVIDER } from '../core/scroll/nz-scroll.service';
import { NzAffixComponent } from './nz-affix.component';
import { SCROLL_SERVICE_PROVIDER } from "../core/scroll/nz-scroll.service";

@NgModule({
declarations: [ NzAffixComponent ],
Expand All @@ -12,4 +12,3 @@ import { SCROLL_SERVICE_PROVIDER } from "../core/scroll/nz-scroll.service";
})
export class NzAffixModule {
}

18 changes: 10 additions & 8 deletions src/components/alert/nz-alert.component.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import {
Component,
ViewEncapsulation,
EventEmitter,
Input,
OnChanges,
OnInit,
Output,
EventEmitter, OnChanges, OnInit
ViewEncapsulation,
} from '@angular/core';
import { fadeAnimation } from '../core/animation/fade-animations';
import { toBoolean } from '../util/convert';
import { FadeAnimation } from '../core/animation/fade-animations';

@Component({
selector : 'nz-alert',
encapsulation: ViewEncapsulation.None,
animations : [ FadeAnimation ],
animations : [ fadeAnimation ],
template : `
<div [ngClass]="_classMap" *ngIf="_display" [@fadeAnimation]>
<i
Expand All @@ -29,13 +31,13 @@ import { FadeAnimation } from '../core/animation/fade-animations';
[class.anticon-exclamation-circle]="nzType==='warning'"
*ngIf="nzShowIcon&&!nzDescription"></i>
<ng-template [ngIf]="nzMessage">
<span class="ant-alert-message">{{nzMessage}}</span>
<span class="ant-alert-message">{{ nzMessage }}</span>
</ng-template>
<ng-template [ngIf]="!nzMessage">
<ng-content select="[alert-body]"></ng-content>
</ng-template>
<ng-template [ngIf]="nzDescription">
<span class="ant-alert-description">{{nzDescription}}</span>
<span class="ant-alert-description">{{ nzDescription }}</span>
</ng-template>
<ng-template [ngIf]="!nzDescription">
<ng-content select="alert-description"></ng-content>
Expand All @@ -44,7 +46,7 @@ import { FadeAnimation } from '../core/animation/fade-animations';
<a *ngIf="nzCloseable" (click)="closeAlert($event)" class="ant-alert-close-icon">
<i class="anticon anticon-cross"></i>
</a>
<a *ngIf="nzCloseText" class="ant-alert-close-icon" (click)="closeAlert()">{{nzCloseText}}</a>
<a *ngIf="nzCloseText" class="ant-alert-close-icon" (click)="closeAlert()">{{ nzCloseText }}</a>
</ng-template>
</div>
`,
Expand Down Expand Up @@ -105,7 +107,7 @@ export class NzAlertComponent implements OnChanges {
this.nzOnClose.emit(true);
}

ngOnChanges() {
ngOnChanges(): void {
this._classMap = {
[`${this.antAlert}`] : true,
[`${this.antAlert}-${this.nzType}`] : true,
Expand Down
2 changes: 1 addition & 1 deletion src/components/alert/nz-alert.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { NzAlertComponent } from './nz-alert.component';
import { CommonModule } from '@angular/common';

@NgModule({
declarations: [ NzAlertComponent ],
Expand Down
16 changes: 8 additions & 8 deletions src/components/anchor/nz-anchor-link.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
Component,
ViewEncapsulation,
Input,
TemplateRef,
ContentChild,
ElementRef,
HostBinding,
HostListener,
ElementRef
Input,
TemplateRef,
ViewEncapsulation,
} from '@angular/core';

import { NzAnchorComponent } from './nz-anchor.component';
Expand All @@ -16,7 +16,7 @@ import { NzAnchorComponent } from './nz-anchor.component';
encapsulation: ViewEncapsulation.None,
template: `
<a (click)="goToClick($event)" href="{{nzHref}}" class="ant-anchor-link-title">
<span *ngIf="!nzTemplate">{{nzTitle}}</span>
<span *ngIf="!nzTemplate">{{ nzTitle }}</span>
<ng-template *ngIf="nzTemplate" [ngTemplateOutlet]="nzTemplate"></ng-template>
</a>
<ng-content></ng-content>
Expand All @@ -31,20 +31,20 @@ export class NzAnchorLinkComponent {

@Input() nzTitle: string;

@ContentChild('nzTemplate') nzTemplate: TemplateRef<any>;
@ContentChild('nzTemplate') nzTemplate: TemplateRef<void>;

@HostBinding('class.ant-anchor-link-active') active: boolean = false;

@HostListener('click')
_onClick() {
_onClick(): void {
this._anchorComp.scrollTo(this);
}

constructor(public el: ElementRef, private _anchorComp: NzAnchorComponent) {
this._anchorComp.add(this);
}

goToClick(e: Event) {
goToClick(e: Event): void {
e.preventDefault();
e.stopPropagation();
this._anchorComp.scrollTo(this);
Expand Down
38 changes: 21 additions & 17 deletions src/components/anchor/nz-anchor.component.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import { DOCUMENT } from '@angular/common';
import {
Component,
ViewEncapsulation,
Input,
ElementRef,
EventEmitter,
Inject,
Input,
OnDestroy,
OnInit,
Output,
Renderer2,
OnDestroy,
ViewChild,
ElementRef,
Inject, OnInit
ViewEncapsulation,
} from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { Subscription } from 'rxjs/Subscription';
import { fromEvent } from 'rxjs/observable/fromEvent';
import { throttleTime } from 'rxjs/operators/throttleTime';
import { distinctUntilChanged } from 'rxjs/operators/distinctUntilChanged';
import { Subscription } from 'rxjs/Subscription';
import { throttleTime } from 'rxjs/operators/throttleTime';

import { NzScrollService } from '../core/scroll/nz-scroll.service';
import { NzAnchorLinkComponent } from './nz-anchor-link.component';

interface Section {
comp: NzAnchorLinkComponent,
top: number
comp: NzAnchorLinkComponent;
top: number;
}

@Component({
Expand All @@ -48,6 +49,7 @@ export class NzAnchorComponent implements OnDestroy, OnInit {
private scroll$: Subscription = null;
private target: Element = null;
private animating = false;
private doc: Document;

@ViewChild('container')
private container: ElementRef;
Expand All @@ -70,7 +72,9 @@ export class NzAnchorComponent implements OnDestroy, OnInit {

@Output() nzScroll: EventEmitter<NzAnchorLinkComponent> = new EventEmitter();

constructor(private scrollSrv: NzScrollService, private _renderer: Renderer2, @Inject(DOCUMENT) private doc: any) {
/* tslint:disable-next-line:no-any */
constructor(private scrollSrv: NzScrollService, private _renderer: Renderer2, @Inject(DOCUMENT) doc: any) {
this.doc = doc;
}

ngOnInit(): void {
Expand All @@ -83,7 +87,7 @@ export class NzAnchorComponent implements OnDestroy, OnInit {
return this.target || window;
}

private handleScroll() {
private handleScroll(): void {
if (this.animating) {
return;
}
Expand All @@ -97,7 +101,7 @@ export class NzAnchorComponent implements OnDestroy, OnInit {
sections.push({
top,
comp
})
});
}
});

Expand All @@ -115,13 +119,13 @@ export class NzAnchorComponent implements OnDestroy, OnInit {
this.nzScroll.emit(maxSection.comp);
}

private removeListen() {
private removeListen(): void {
if (this.scroll$) {
this.scroll$.unsubscribe();
}
}

private registerScrollEvent() {
private registerScrollEvent(): void {
this.removeListen();
// 由于页面刷新时滚动条位置的记忆
// 倒置在dom未渲染完成,导致计算不正确(500ms用于延后执行解决)
Expand All @@ -134,12 +138,12 @@ export class NzAnchorComponent implements OnDestroy, OnInit {
});
}

add(linkComp: NzAnchorLinkComponent) {
add(linkComp: NzAnchorLinkComponent): void {
this.links.push(linkComp);
}

/** 设置滚动条至 `linkComp` 所处位置 */
scrollTo(linkComp: NzAnchorLinkComponent) {
scrollTo(linkComp: NzAnchorLinkComponent): void {
const el = this.doc.querySelector(linkComp.nzHref);
if (!el) {
return;
Expand Down
7 changes: 3 additions & 4 deletions src/components/anchor/nz-anchor.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

import { SCROLL_SERVICE_PROVIDER } from '../core/scroll/nz-scroll.service';
import { NzAnchorLinkComponent } from './nz-anchor-link.component';
import { NzAnchorComponent } from './nz-anchor.component';
import { NzAnchorLinkComponent } from "./nz-anchor-link.component";
import { SCROLL_SERVICE_PROVIDER } from "../core/scroll/nz-scroll.service";

@NgModule({
declarations: [ NzAnchorComponent, NzAnchorLinkComponent ],
Expand All @@ -13,4 +13,3 @@ import { SCROLL_SERVICE_PROVIDER } from "../core/scroll/nz-scroll.service";
})
export class NzAnchorModule {
}

Loading

0 comments on commit b5e9aee

Please sign in to comment.