Skip to content

Commit

Permalink
chore: add @typescript-eslint/no-explicit-any (#1300)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Aug 1, 2021
1 parent 2cae62a commit 3f124ad
Show file tree
Hide file tree
Showing 223 changed files with 853 additions and 599 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ module.exports = {
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'prefer-arrow/prefer-arrow-functions': 'off',
'import/no-duplicates': 'error',
'import/no-unused-modules': 'error',
Expand Down
1 change: 1 addition & 0 deletions _mock/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const USERS = {
// 支持值为 Object 和 Array
'GET /users': (req: MockRequest) => {
const total = +(req.queryString.total || 100);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const res: any = {
list: [],
total
Expand Down
4 changes: 2 additions & 2 deletions packages/abc/avatar-list/avatar-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

import { NzSafeAny, NzSizeLDSType } from 'ng-zorro-antd/core/types';
import { NgStyleInterface, NzSizeLDSType } from 'ng-zorro-antd/core/types';

import { InputNumber, NumberInput } from '@delon/util/decorator';

Expand Down Expand Up @@ -62,7 +62,7 @@ export class AvatarListComponent implements AfterViewInit, OnChanges, OnDestroy
}
}
@Input() @InputNumber() maxLength = 0;
@Input() excessItemsStyle: { [klass: string]: NzSafeAny };
@Input() excessItemsStyle: NgStyleInterface;

constructor(private cdr: ChangeDetectorRef, @Optional() private directionality: Directionality) {}

Expand Down
9 changes: 5 additions & 4 deletions packages/abc/date-picker/range.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { DomSanitizer } from '@angular/platform-browser';
import { Subject } from 'rxjs';

import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NzDatePickerComponent, NzRangePickerComponent } from 'ng-zorro-antd/date-picker';
import { DatePickerService } from 'ng-zorro-antd/date-picker/date-picker.service';

Expand Down Expand Up @@ -58,8 +59,8 @@ export class RangePickerDirective implements OnDestroy, AfterViewInit {
get shortcut(): AlainDateRangePickerShortcut | null {
return this._shortcut;
}
@Input() ngModelEnd: any;
@Output() readonly ngModelEndChange = new EventEmitter<any>();
@Input() ngModelEnd: NzSafeAny;
@Output() readonly ngModelEndChange = new EventEmitter<NzSafeAny>();

private get dp(): NzDatePickerComponent {
return this.nativeComp.datePicker;
Expand Down Expand Up @@ -126,7 +127,7 @@ export class RangePickerDirective implements OnDestroy, AfterViewInit {
}

private cd(): void {
(this.dp as any).cdr.markForCheck();
(this.dp as NzSafeAny).cdr.markForCheck();
}

private overrideNative(): void {
Expand Down Expand Up @@ -159,7 +160,7 @@ export class RangePickerDirective implements OnDestroy, AfterViewInit {
return;
}
const { enabled, list } = this._shortcut;
let extraFooter: TemplateRef<any> | undefined;
let extraFooter: TemplateRef<NzSafeAny> | undefined;
if (!this.nativeComp || !enabled) {
extraFooter = undefined;
} else {
Expand Down
6 changes: 3 additions & 3 deletions packages/abc/down-file/down-file.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import { _HttpClient } from '@delon/theme';
})
export class DownFileDirective {
private isFileSaverSupported = true;
@Input('http-data') httpData: any;
@Input('http-body') httpBody: any;
@Input('http-data') httpData: NzSafeAny;
@Input('http-body') httpBody: NzSafeAny;
@Input('http-method') httpMethod: string = 'get';
@Input('http-url') httpUrl: string;
@Input('file-name') fileName: string | ((rep: HttpResponse<Blob>) => string);
@Input() pre: (ev: MouseEvent) => Promise<boolean>;
@Output() readonly success = new EventEmitter<HttpResponse<Blob>>();
@Output() readonly error = new EventEmitter<any>();
@Output() readonly error = new EventEmitter<NzSafeAny>();

private getDisposition(data: string | null): NzSafeAny {
const arr: Array<Record<string, string>> = (data || '')
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/down-file/down-file.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ describe('abc: down-file', () => {
class TestComponent {
fileTypes = ['xlsx', 'docx', 'pptx', 'pdf'];

data: any = {
data: NzSafeAny = {
otherdata: 1,
time: new Date()
};
Expand Down
4 changes: 3 additions & 1 deletion packages/abc/ellipsis/ellipsis.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { take } from 'rxjs/operators';

import { NzSafeAny } from 'ng-zorro-antd/core/types';

import { BooleanInput, InputBoolean, InputNumber, NumberInput } from '@delon/util/decorator';

@Component({
Expand Down Expand Up @@ -60,7 +62,7 @@ export class EllipsisComponent implements AfterViewInit, OnChanges {
private el: ElementRef,
private ngZone: NgZone,
private dom: DomSanitizer,
@Inject(DOCUMENT) private doc: any,
@Inject(DOCUMENT) private doc: NzSafeAny,
private cdr: ChangeDetectorRef
) {}

Expand Down
3 changes: 2 additions & 1 deletion packages/abc/ellipsis/ellipsis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, DebugElement, ViewChild } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';

import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NzTooltipDirective } from 'ng-zorro-antd/tooltip';

import { EllipsisComponent } from './ellipsis.component';
Expand Down Expand Up @@ -87,7 +88,7 @@ describe('abc: ellipsis', () => {
});
describe('when not support line clamp', () => {
beforeEach(fakeAsync(() => {
spyOn(window, 'getComputedStyle').and.returnValue({ lineHeight: 20 } as any);
spyOn(window, 'getComputedStyle').and.returnValue({ lineHeight: 20 } as NzSafeAny);
page.comp['isSupportLineClamp'] = false;
context.lines = 1;
page.tick();
Expand Down
4 changes: 3 additions & 1 deletion packages/abc/error-collect/error-collect.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
import { interval, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

import { NzSafeAny } from 'ng-zorro-antd/core/types';

import { AlainConfigService } from '@delon/util/config';
import { InputNumber } from '@delon/util/decorator';

Expand Down Expand Up @@ -49,7 +51,7 @@ export class ErrorCollectComponent implements OnInit, OnDestroy {
constructor(
private el: ElementRef,
private cdr: ChangeDetectorRef,
@Inject(DOCUMENT) private doc: any,
@Inject(DOCUMENT) private doc: NzSafeAny,
configSrv: AlainConfigService,
@Optional() private directionality: Directionality
) {
Expand Down
4 changes: 3 additions & 1 deletion packages/abc/footer-toolbar/footer-toolbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
ViewEncapsulation
} from '@angular/core';

import { NzSafeAny } from 'ng-zorro-antd/core/types';

import { BooleanInput, InputBoolean } from '@delon/util/decorator';

const CLSBODY = 'footer-toolbar__body';
Expand All @@ -30,7 +32,7 @@ export class FooterToolbarComponent implements OnInit, OnDestroy {
@Input() @InputBoolean() errorCollect = false;
@Input() extra: string | TemplateRef<void>;

constructor(private el: ElementRef, private renderer: Renderer2, @Inject(DOCUMENT) private doc: any) {}
constructor(private el: ElementRef, private renderer: Renderer2, @Inject(DOCUMENT) private doc: NzSafeAny) {}

private get bodyCls(): DOMTokenList {
return (this.doc.querySelector('body') as HTMLElement).classList;
Expand Down
4 changes: 3 additions & 1 deletion packages/abc/full-content/full-content.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { ActivationEnd, ActivationStart, Event, Router } from '@angular/router';
import { fromEvent, Subscription } from 'rxjs';
import { debounceTime, filter } from 'rxjs/operators';

import { NzSafeAny } from 'ng-zorro-antd/core/types';

import { BooleanInput, InputBoolean, InputNumber, NumberInput } from '@delon/util/decorator';

import { FullContentService } from './full-content.service';
Expand Down Expand Up @@ -62,7 +64,7 @@ export class FullContentComponent implements AfterViewInit, OnInit, OnChanges, O
private cdr: ChangeDetectorRef,
private srv: FullContentService,
private router: Router,
@Inject(DOCUMENT) private doc: any
@Inject(DOCUMENT) private doc: NzSafeAny
) {}

private updateCls(): void {
Expand Down
8 changes: 5 additions & 3 deletions packages/abc/full-content/full-content.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { ActivationEnd, Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { BehaviorSubject } from 'rxjs';

import { NzSafeAny } from 'ng-zorro-antd/core/types';

import { FullContentComponent } from './full-content.component';
import { FullContentModule } from './full-content.module';
import { FullContentService } from './full-content.service';
Expand Down Expand Up @@ -110,7 +112,7 @@ describe('abc: full-content', () => {
const bodyHeight = 10;
spyOn(bodyEl, 'getBoundingClientRect').and.returnValue({
height: bodyHeight
} as any);
} as NzSafeAny);
expect(bodyEl.getBoundingClientRect).not.toHaveBeenCalled();
window.dispatchEvent(new Event('resize'));
fixture.detectChanges();
Expand All @@ -119,7 +121,7 @@ describe('abc: full-content', () => {
expect(context.comp._height).toBe(bodyHeight - el.getBoundingClientRect().top - context.padding);
}));
it('should be clear class when go to other route', () => {
const eventsSub = new BehaviorSubject<any>(null);
const eventsSub = new BehaviorSubject<NzSafeAny>(null);
class MockRouter {
events = eventsSub;
}
Expand All @@ -138,7 +140,7 @@ describe('abc: full-content', () => {
expect(bodyEl.classList.contains('full-content')).toBe(false);
});
it('should be attach class when back route', () => {
const eventsSub = new BehaviorSubject<any>(null);
const eventsSub = new BehaviorSubject<NzSafeAny>(null);
class MockRouter {
events = eventsSub;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/full-content/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cols: 1
module: import { FullContentModule } from '@delon/abc/full-content';
---

Often used for tables with scroll bars, a simple [demo](https://ng-alain.surge.sh/#/delon/simple-table)
Often used for tables with scroll bars, a simple [demo](https://ng-alain.surge.sh/#/delon/st)

## API

Expand Down
2 changes: 1 addition & 1 deletion packages/abc/full-content/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cols: 1
module: import { FullContentModule } from '@delon/abc/full-content';
---

全屏工作区,常用于带有滚动条表格,一个在线[示例](https://ng-alain.surge.sh/#/delon/simple-table)
全屏工作区,常用于带有滚动条表格,一个在线[示例](https://ng-alain.surge.sh/#/delon/st)

## API

Expand Down
4 changes: 3 additions & 1 deletion packages/abc/global-footer/global-footer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { Router } from '@angular/router';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

import { NzSafeAny } from 'ng-zorro-antd/core/types';

import { WINDOW } from '@delon/util/token';

import { GlobalFooterItemComponent } from './global-footer-item.component';
Expand Down Expand Up @@ -52,7 +54,7 @@ export class GlobalFooterComponent implements OnInit, OnDestroy {

constructor(
private router: Router,
@Inject(WINDOW) private win: any,
@Inject(WINDOW) private win: NzSafeAny,
private dom: DomSanitizer,
@Optional() private directionality: Directionality
) {}
Expand Down
4 changes: 3 additions & 1 deletion packages/abc/global-footer/global-footer.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { NzSafeAny } from 'ng-zorro-antd/core/types';

export interface GlobalFooterLink {
[key: string]: any;
[key: string]: NzSafeAny;
title: string;
href: string;
blankTarget?: boolean;
Expand Down
3 changes: 2 additions & 1 deletion packages/abc/image/image.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { of, throwError } from 'rxjs';

import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { ModalOptions } from 'ng-zorro-antd/modal';

import { cleanCdkOverlayHtml, createTestContext } from '@delon/testing';
Expand Down Expand Up @@ -85,7 +86,7 @@ describe('abc: _src', () => {
onerror: () => {}
};
beforeEach(() => {
spyOn(window, 'FileReader').and.returnValue(mockFileReader as any);
spyOn(window, 'FileReader').and.returnValue(mockFileReader as NzSafeAny);
_http = TestBed.inject(_HttpClient);
context.useHttp = true;
});
Expand Down
4 changes: 3 additions & 1 deletion packages/abc/let/let.directive.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Directive, Inject, Input, TemplateRef, ViewContainerRef } from '@angular/core';

import { NzSafeAny } from 'ng-zorro-antd/core/types';

export class LetContext<T> {
constructor(private readonly dir: LetDirective<T>) {}

Expand All @@ -20,7 +22,7 @@ export class LetDirective<T> {
vc.createEmbeddedView(ref, new LetContext<T>(this));
}

static ngTemplateContextGuard<T>(_dir: LetDirective<T>, _ctx: any): _ctx is LetDirective<T> {
static ngTemplateContextGuard<T>(_dir: LetDirective<T>, _ctx: NzSafeAny): _ctx is LetDirective<T> {
return true;
}
}
4 changes: 2 additions & 2 deletions packages/abc/lodop/lodop.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class LodopService implements OnDestroy {
private _lodop: Lodop | null = null;
private _init = new Subject<LodopResult>();
private _events = new Subject<LodopPrintResult>();
private printBuffer: any[] = [];
private printBuffer: NzSafeAny[] = [];

constructor(private scriptSrv: LazyService, configSrv: AlainConfigService) {
this.defaultConfig = configSrv.merge('lodop', {
Expand Down Expand Up @@ -155,7 +155,7 @@ export class LodopService implements OnDestroy {
if (!res) return;
const fn = this._lodop![res[1]];
if (fn) {
let arr: any[] | null = null;
let arr: NzSafeAny[] | null = null;
try {
const fakeFn = new Function(`return [${res[2]}]`);
arr = fakeFn();
Expand Down
4 changes: 2 additions & 2 deletions packages/abc/lodop/lodop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Lodop } from './lodop.types';
const cog: AlainConfig = {
lodop: { name: 'LODOP' }
};
let mockLodop: any;
let mockLodop: NzSafeAny;
let isErrRequest = false;
let loadCount = 0;
let isNullLodop = false;
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('abc: lodop', () => {
};
setTimeout(() => {
const obj = (window as NzSafeAny)[cog.lodop!.name!] as Lodop;
(obj.webskt as any).readyState = 1;
(obj.webskt as NzSafeAny).readyState = 1;
}, 30);
srv.lodop.subscribe(res => {
expect(res).not.toBeNull();
Expand Down
14 changes: 8 additions & 6 deletions packages/abc/lodop/lodop.types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { NzSafeAny } from 'ng-zorro-antd/core/types';

export interface CLodop {
/**
* 判断是否支持https协议的属性
Expand All @@ -22,7 +24,7 @@ export interface CLodop {
}

export interface Lodop extends CLodop {
[key: string]: any;
[key: string]: NzSafeAny;

/** 获得软件版本号 */
VERSION: string;
Expand Down Expand Up @@ -157,7 +159,7 @@ export interface Lodop extends CLodop {
): void;

/** 装载文档式模板 */
ADD_PRINT_DATA(strDataStyle: string, varDataValue: any): void;
ADD_PRINT_DATA(strDataStyle: string, varDataValue: NzSafeAny): void;

/** 设置打印项风格 */
SET_PRINT_STYLE(strStyleName: LodopStyleValue, varStyleValue: number | string): void;
Expand Down Expand Up @@ -248,10 +250,10 @@ export interface Lodop extends CLodop {
GET_SYSTEM_INFO(strInfoType: string): boolean;

/** 获得数据值 */
GET_VALUE(ValueType: string, ValueIndex: number | string): any;
GET_VALUE(ValueType: string, ValueIndex: number | string): NzSafeAny;

/** 数据格式转换 */
FORMAT(oType: string, oValue: any): any;
FORMAT(oType: string, oValue: NzSafeAny): NzSafeAny;

/** 获得对话框结果值 */
GET_DIALOG_VALUE(oType: string, oPreValue: string): string;
Expand Down Expand Up @@ -376,7 +378,7 @@ export interface LodopResult {
/** 成功时携带 LODOP 对象 */
lodop?: Lodop;
/** 错误信息 */
error?: any;
error?: NzSafeAny;
}

export interface LodopPrintResult {
Expand All @@ -387,7 +389,7 @@ export interface LodopPrintResult {
/** 代码 */
code: string;
/** 动态参数上下文对象 */
item: any;
item: NzSafeAny;
/** 代码解析表达式 */
parser?: RegExp;
}
Loading

0 comments on commit 3f124ad

Please sign in to comment.