Skip to content

Commit

Permalink
build: add noUnusedParameters config (NG-ZORRO#2960)
Browse files Browse the repository at this point in the history
* build: add noUnusedLocals config

* build: add noUnusedParameters config
  • Loading branch information
Wendell authored and Ricbet committed Apr 9, 2020
1 parent 7351101 commit 89cfd32
Show file tree
Hide file tree
Showing 42 changed files with 109 additions and 119 deletions.
4 changes: 2 additions & 2 deletions components/affix/affix.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ describe('affix', () => {
});
});

it(`emit true when is affixed`, fakeAsync((done) => {
it(`emit true when is affixed`, fakeAsync(() => {
setupInitialState();
emitScroll(window, defaultOffsetTop + startOffset + 1);

Expand All @@ -355,7 +355,7 @@ describe('affix', () => {
discardPeriodicTasks();
}));

it(`emit false when is unaffixed`, fakeAsync((done) => {
it(`emit false when is unaffixed`, fakeAsync(() => {
setupInitialState();
emitScroll(window, defaultOffsetTop + startOffset + 1);
emitScroll(window, defaultOffsetTop + startOffset - 1);
Expand Down
6 changes: 3 additions & 3 deletions components/anchor/anchor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ describe('anchor', () => {
describe('[default]', () => {
it(`should scolling to target via click a link`, () => {
spyOn(srv, 'scrollTo').and.callFake((
containerEl: Element | Window,
targetTopValue: number = 0,
easing?: any,
_containerEl: Element | Window,
_targetTopValue: number = 0,
_easing?: any,
callback?: () => void
) => {
callback();
Expand Down
2 changes: 1 addition & 1 deletion components/auto-complete/demo/uncertain-category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class NzDemoAutoCompleteUncertainCategoryComponent {

onChange(value: string): void {
this.options = new Array(this.getRandomInt(15, 5)).join('.').split('.')
.map((item, idx) => ({
.map((_item, idx) => ({
value,
category: `${value}${idx}`,
count: this.getRandomInt(200, 100),
Expand Down
10 changes: 4 additions & 6 deletions components/back-top/back-top.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('Component:nz-back-top', () => {
componentObject.clickBackTop();
tick();

expect(scrollService.getScroll(window)).toEqual(0);
expect(scrollService.getScroll()).toEqual(0);
}));
});
});
Expand Down Expand Up @@ -236,15 +236,13 @@ class TestBackTopTemplateComponent {
class MockNzScrollService {
mockTopOffset: number;

getScroll(el?: Element | Window, top: boolean = true): number {
getScroll(): number {
return this.mockTopOffset;
}

scrollTo(
containerEl: Element | Window,
targetTopValue: number = 0,
easing?: {},
callback?: {}
_containerEl: Element | Window,
targetTopValue: number = 0
): void {
this.mockTopOffset = targetTopValue;
}
Expand Down
2 changes: 1 addition & 1 deletion components/button/nz-button.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe('button', () => {
beforeEach(() => {
fixture = TestBed.createComponent(NzDemoButtonSizeComponent);
testComponent = fixture.debugElement.componentInstance;
buttons = fixture.debugElement.queryAll(By.directive(NzButtonComponent)).filter((item, index) => index < 6);
buttons = fixture.debugElement.queryAll(By.directive(NzButtonComponent)).filter((_, index) => index < 6);
buttonGroup = fixture.debugElement.query(By.directive(NzButtonGroupComponent));
});

Expand Down
2 changes: 1 addition & 1 deletion components/cascader/demo/change-on-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class NzDemoCascaderChangeOnFunctionComponent {
console.log(values, this.values);
}

public validate(option: any, index: number): boolean {
public validate(option: any, _index: number): boolean {
const value = option.value;
return ['hangzhou', 'xihu', 'nanjing', 'zhonghuamen'].indexOf(value) >= 0;
}
Expand Down
2 changes: 1 addition & 1 deletion components/cascader/demo/custom-field-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class NzDemoCascaderCustomFieldNamesComponent {
console.log(values, this.values);
}

public validate(option: any, index: number): boolean {
public validate(option: any, _index: number): boolean {
const value = option.value;
return ['hangzhou', 'xihu', 'nanjing', 'zhonghuamen'].indexOf(value) >= 0;
}
Expand Down
2 changes: 1 addition & 1 deletion components/cascader/demo/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class NzDemoCascaderModalComponent {
}

handleOk($event: MouseEvent): void {
console.log('Button ok clicked!', this.values);
console.log('Button ok clicked!', this.values, $event);
this.isVisible = false;
}

Expand Down
4 changes: 2 additions & 2 deletions components/cascader/nz-cascader.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
[disabled]="nzDisabled"
[nzSize]="nzSize"
[(ngModel)]="inputValue"
(blur)="handleInputBlur($event)"
(focus)="handleInputFocus($event)"
(blur)="handleInputBlur()"
(focus)="handleInputFocus()"
(change)="$event.stopPropagation()">
<i *ngIf="clearIconVisible"
nz-icon
Expand Down
12 changes: 6 additions & 6 deletions components/cascader/nz-cascader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,11 @@ export class NzCascaderComponent implements OnDestroy, ControlValueAccessor {
}
}

handleInputBlur(event: Event): void {
handleInputBlur(): void {
this.menuVisible ? this.focus() : this.blur();
}

handleInputFocus(event: Event): void {
handleInputFocus(): void {
this.focus();
}

Expand Down Expand Up @@ -476,8 +476,8 @@ export class NzCascaderComponent implements OnDestroy, ControlValueAccessor {
}
}

@HostListener('click', [ '$event' ])
onTriggerClick(event: MouseEvent): void {
@HostListener('click')
onTriggerClick(): void {
if (this.nzDisabled) {
return;
}
Expand All @@ -490,8 +490,8 @@ export class NzCascaderComponent implements OnDestroy, ControlValueAccessor {
this.onTouched();
}

@HostListener('mouseenter', [ '$event' ])
onTriggerMouseEnter(event: MouseEvent): void {
@HostListener('mouseenter')
onTriggerMouseEnter(): void {
if (this.nzDisabled) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions components/cascader/nz-cascader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ describe('cascader', () => {
}));
it('should support custom sorter', fakeAsync(() => {
testComponent.nzShowSearch = {
sorter(a: CascaderOption[], b: CascaderOption[], inputValue: string): number {
sorter(a: CascaderOption[], b: CascaderOption[], _inputValue: string): number {
const l1 = a[ 0 ].label;
const l2 = b[ 0 ].label; // all reversed, just to be sure it works
return ('' + l1).localeCompare(l2);
Expand Down Expand Up @@ -1865,7 +1865,7 @@ export class NzDemoCascaderDefaultComponent {
onVisibleChange = jasmine.createSpy('open change');
onValueChanges = jasmine.createSpy('value change');

fakeChangeOn = (node: any, index: number): boolean => {
fakeChangeOn = (node: any, _index: number): boolean => {
return node.value === 'zhejiang';
}

Expand Down
2 changes: 1 addition & 1 deletion components/checkbox/nz-checkbox-group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class NzCheckboxGroupComponent implements ControlValueAccessor, OnInit {
this.onChange(this.options);
}

trackByOption(index: number, option: NzCheckBoxOptionInterface): string {
trackByOption(_index: number, option: NzCheckBoxOptionInterface): string {
return option.value;
}

Expand Down
22 changes: 10 additions & 12 deletions components/core/util/logger/logger.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable:no-any */
import { Inject, Injectable, InjectionToken, Optional, Provider, SkipSelf } from '@angular/core';

export const NZ_LOGGER_STATE = new InjectionToken<boolean>('nz-logger-state'); // Whether print the log
Expand All @@ -7,39 +6,38 @@ export const NZ_LOGGER_STATE = new InjectionToken<boolean>('nz-logger-state'); /
export class LoggerService {
constructor(@Inject(NZ_LOGGER_STATE) private _loggerState: boolean) {}

// tslint:disable-next-line:no-any
log(...args: any[]): void {
if (this._loggerState) {
// console.log(...args);
console.log.apply(console, arguments);
console.log(...args);
}
}

// tslint:disable-next-line:no-any
warn(...args: any[]): void {
if (this._loggerState) {
// console.warn(...args);
console.warn.apply(console, arguments);
console.warn(...args);
}
}

// tslint:disable-next-line:no-any
error(...args: any[]): void {
if (this._loggerState) {
// console.error(...args);
console.error.apply(console, arguments);
console.error(...args);
}
}

// tslint:disable-next-line:no-any
info(...args: any[]): void {
if (this._loggerState) {
// console.log(...args);
console.log.apply(console, arguments);
console.log(...args);
}
}

// tslint:disable-next-line:no-any
debug(...args: any[]): void {
if (this._loggerState) {
// console.log('[NG-ZORRO-DEBUG]', ...args);
const arrs = Array.prototype.slice.call(arguments);
console.log.apply(console, ['[NG-ZORRO-DEBUG]'].concat(arrs));
console.log('[NG-ZORRO-DEBUG]', ...args);
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions components/date-picker/date-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import en_US from '../i18n/languages/en_US';
import { NzI18nModule } from '../i18n/nz-i18n.module';
import { NzI18nService } from '../i18n/nz-i18n.service';
import { NzDatePickerModule } from './date-picker.module';
import { PickerResultSingle } from './standard-types';

registerLocaleData(zh);

Expand Down Expand Up @@ -565,7 +564,7 @@ describe('NzDatePickerComponent', () => {

it('should support nzDisabledTime and nzShowTime.nzHideDisabledOptions', fakeAsync(() => {
fixtureInstance.nzShowTime = true;
fixtureInstance.nzDisabledTime = (current: Date) => {
fixtureInstance.nzDisabledTime = () => {
return {
nzDisabledHours : () => [ 0, 1, 2 ],
nzDisabledMinutes: () => [ 0, 1 ],
Expand Down Expand Up @@ -814,10 +813,10 @@ class NzTestDatePickerComponent {
nzSize;
nzStyle;

nzOnOpenChange(d: Date): void {
nzOnOpenChange(): void {
}

nzOnChange(result: PickerResultSingle): void {
nzOnChange(): void {
}

nzValue;
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/demo/disabled-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class NzDemoDatePickerDisabledDateComponent {
};
};

disabledRangeTime = (value: Date[], type: 'start' | 'end'): object => {
disabledRangeTime = (_value: Date[], type: 'start' | 'end'): object => {
if (type === 'start') {
return {
nzDisabledHours : () => this.range(0, 60).splice(4, 20),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class DecadePanelComponent implements OnChanges {
this.gotoYear(100);
}

trackPanelDecade(index: number, decadeData: PanelDecadeData): string {
trackPanelDecade(_index: number, decadeData: PanelDecadeData): string {
return decadeData.content;
}

Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/lib/month/month-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class MonthTableComponent implements OnInit, OnChanges {
}
}

trackPanelMonth(index: number, monthData: PanelMonthData): number {
trackPanelMonth(_index: number, monthData: PanelMonthData): number {
return monthData.month;
}

Expand Down
4 changes: 2 additions & 2 deletions components/date-picker/lib/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ describe('util.ts coverage supplements', () => {
const disabledTime = () => {
return {
nzDisabledHours: () => [ 1 ],
nzDisabledMinutes: (hour) => [ 2 ],
nzDisabledSeconds: (hour, minute) => [ 3 ]
nzDisabledMinutes: () => [ 2 ],
nzDisabledSeconds: () => [ 3 ]
};
};
expect(isAllowedDate(new CandyDate('2000-11-11 01:11:11'), null, disabledTime)).toBeFalsy();
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/lib/year/year-panel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class YearPanelComponent implements OnChanges {
this.gotoYear(10);
}

trackPanelYear(index: number, yearData: PanelYearData): string {
trackPanelYear(_index: number, yearData: PanelYearData): string {
return yearData.content;
}

Expand Down
6 changes: 2 additions & 4 deletions components/date-picker/month-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import isBefore from 'date-fns/is_before';
import { dispatchMouseEvent } from '../core/testing';
import { NzInputModule } from '../input/nz-input.module';
import { NzDatePickerModule } from './date-picker.module';
import { CandyDate } from './lib/candy-date';
import { PickerResultSingle } from './standard-types';

registerLocaleData(zh);

Expand Down Expand Up @@ -481,10 +479,10 @@ class NzTestMonthPickerComponent {
nzSize;
nzStyle;

nzOnOpenChange(d: CandyDate): void {
nzOnOpenChange(): void {
}

nzOnChange(result: PickerResultSingle): void {
nzOnChange(): void {
}

nzValue;
Expand Down
6 changes: 3 additions & 3 deletions components/date-picker/range-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ describe('NzRangePickerComponent', () => {
it('should support nzDisabledTime and nzShowTime.nzHideDisabledOptions', fakeAsync(() => {
fixtureInstance.modelValue = [ new Date('2018-11-11 11:11:11'), new Date('2018-12-12 12:12:12') ];
fixtureInstance.nzShowTime = true;
fixtureInstance.nzDisabledTime = (current: Date, partial: 'start' | 'end') => {
fixtureInstance.nzDisabledTime = (_current: Date, partial: 'start' | 'end') => {
return partial === 'start' ? {
nzDisabledHours: () => [ 0, 1, 2],
nzDisabledMinutes: () => [ 0, 1 ],
Expand Down Expand Up @@ -659,9 +659,9 @@ class NzTestRangePickerComponent {
nzDropdownClassName;
nzSize;
nzStyle;
nzOnOpenChange(open: boolean): void { }
nzOnOpenChange(): void { }
modelValue;
modelValueChange(d: Date): void { }
modelValueChange(): void { }

nzDateRender;
nzShowTime: boolean | object = false;
Expand Down
6 changes: 2 additions & 4 deletions components/date-picker/year-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { dispatchMouseEvent } from '../core/testing';
import { NzInputModule } from '../input/nz-input.module';
import { NzDatePickerModule } from './date-picker.module';
import { CandyDate } from './lib/candy-date';
import { PickerResultSingle } from './standard-types';

describe('NzYearPickerComponent', () => {
let fixture: ComponentFixture<NzTestYearPickerComponent>;
Expand Down Expand Up @@ -439,10 +437,10 @@ class NzTestYearPickerComponent {
nzSize;
nzStyle;

nzOnOpenChange(d: CandyDate): void {
nzOnOpenChange(): void {
}

nzOnChange(result: PickerResultSingle): void {
nzOnChange(): void {
}

nzValue;
Expand Down
9 changes: 5 additions & 4 deletions components/grid/nz-col.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import {
ElementRef,
Host,
Input,
OnChanges, OnDestroy,
OnChanges,
OnDestroy,
OnInit,
Optional, Renderer2,
SimpleChange
Optional,
Renderer2
} from '@angular/core';
import { Subject } from 'rxjs';
import { startWith, takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -87,7 +88,7 @@ export class NzColDirective implements OnInit, OnChanges, AfterViewInit, OnDestr
) {
}

ngOnChanges(changes: { [ propertyName: string ]: SimpleChange }): void {
ngOnChanges(): void {
this.setClassMap();
}

Expand Down
Loading

0 comments on commit 89cfd32

Please sign in to comment.