From 9bb44f13bd2c8cccc8d2a0979a4aec7b81d333ae Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Fri, 7 Sep 2018 13:12:59 +0200 Subject: [PATCH] Stricter linting rules Parameter and return types are required now --- client/src/app/app.component.ts | 2 +- client/src/app/app.module.ts | 2 +- client/src/app/core/pruning-loader.ts | 2 +- .../app/core/services/autoupdate.service.ts | 4 ++-- .../collectionStringModelMapper.service.ts | 2 +- .../app/core/services/data-store.service.ts | 14 +++--------- .../app/core/services/openslides.service.ts | 2 +- .../src/app/core/services/operator.service.ts | 6 ++--- .../src/app/core/services/viewport.service.ts | 4 ++-- .../app/core/services/websocket.service.ts | 2 +- client/src/app/openslides.component.ts | 2 +- .../projector-container.component.ts | 2 +- .../projector/projector.component.ts | 2 +- .../components/footer/footer.component.ts | 2 +- .../components/head-bar/head-bar.component.ts | 6 ++--- .../app/shared/directives/perms.directive.ts | 2 +- client/src/app/shared/models/base.model.ts | 2 +- .../src/app/shared/models/motions/motion.ts | 22 +++++++++---------- client/src/app/shared/models/users/group.ts | 2 +- .../agenda-list/agenda-list.component.ts | 4 ++-- .../assignment-list.component.ts | 6 ++--- .../legal-notice/legal-notice.component.ts | 2 +- .../mediafile-list.component.ts | 8 +++---- .../category-list/category-list.component.ts | 4 ++-- .../motion-detail/motion-detail.component.ts | 12 +++++----- .../motion-list/motion-list.component.ts | 17 +++++++------- .../privacy-policy.component.ts | 2 +- .../settings-list/settings-list.component.ts | 2 +- client/src/app/site/site.component.ts | 10 ++++----- client/src/app/site/start/start.component.ts | 8 +++---- .../users/user-list/user-list.component.ts | 2 +- client/src/tslint.json | 10 ++++++++- 32 files changed, 85 insertions(+), 84 deletions(-) diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index ae541185f..cc1a96c9d 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -25,7 +25,7 @@ export class AppComponent { * the bootstrapped module. * @param moduleRef Reference to the bootstrapped AppModule */ - public static bootstrapDone(moduleRef: NgModuleRef) { + public static bootstrapDone(moduleRef: NgModuleRef): void { AppComponent.bootstrapDoneSubject.next(moduleRef); } diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index e7df754b4..ac24aacfe 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -18,7 +18,7 @@ import { LoginModule } from './site/login/login.module'; * For the translation module. Loads a Custom 'translation loader' and provides it as loader. * @param http Just the HttpClient to load stuff */ -export function HttpLoaderFactory(http: HttpClient) { +export function HttpLoaderFactory(http: HttpClient): PruningTranslationLoader { return new PruningTranslationLoader(http); } /** diff --git a/client/src/app/core/pruning-loader.ts b/client/src/app/core/pruning-loader.ts index 05549a62a..412a9d009 100644 --- a/client/src/app/core/pruning-loader.ts +++ b/client/src/app/core/pruning-loader.ts @@ -37,7 +37,7 @@ export class PruningTranslationLoader implements TranslateLoader { * Falls back to the default language or simply copy the content of the key. * @param any the content of any language file. */ - private process(object: any) { + private process(object: any): any { const newObject = {}; for (const key in object) { if (object.hasOwnProperty(key)) { diff --git a/client/src/app/core/services/autoupdate.service.ts b/client/src/app/core/services/autoupdate.service.ts index 4b5e95e0e..6a31eba0f 100644 --- a/client/src/app/core/services/autoupdate.service.ts +++ b/client/src/app/core/services/autoupdate.service.ts @@ -37,7 +37,7 @@ export class AutoupdateService extends OpenSlidesComponent { * * Saves models in DataStore. */ - public storeResponse(socketResponse): void { + public storeResponse(socketResponse: any): void { // Reorganize the autoupdate: groupy by action, then by collection. The final // entries are the single autoupdate objects. const autoupdate = { @@ -76,7 +76,7 @@ export class AutoupdateService extends OpenSlidesComponent { * * TODO: Wait for changeIds to be implemented on the server. */ - public requestChanges() { + public requestChanges(): void { console.log('requesting changed objects'); // this.websocketService.send('changeIdRequest', this.DS.maxChangeId); } diff --git a/client/src/app/core/services/collectionStringModelMapper.service.ts b/client/src/app/core/services/collectionStringModelMapper.service.ts index e9d4ebc18..67c78922f 100644 --- a/client/src/app/core/services/collectionStringModelMapper.service.ts +++ b/client/src/app/core/services/collectionStringModelMapper.service.ts @@ -15,7 +15,7 @@ export class CollectionStringModelMapperService { * @param collectionString * @param type */ - public static registerCollectionElement(collectionString: string, type: ModelConstructor) { + public static registerCollectionElement(collectionString: string, type: ModelConstructor): void { CollectionStringModelMapperService.collectionStringsTypeMapping[collectionString] = type; } diff --git a/client/src/app/core/services/data-store.service.ts b/client/src/app/core/services/data-store.service.ts index 8d22a4599..c5c67383d 100644 --- a/client/src/app/core/services/data-store.service.ts +++ b/client/src/app/core/services/data-store.service.ts @@ -305,17 +305,9 @@ export class DataStoreService { * * @param Type The desired BaseModel type to be read from the dataStore * @param ...ids An or multiple IDs or a list of IDs of BaseModels. use spread operator ("...") for arrays - * @example this.DS.remove(User, myUser.id, 3, 4) + * @example this.DS.remove('users/user', myUser.id, 3, 4) */ - public remove(collectionType, ...ids: number[]): void { - let collectionString: string; - if (typeof collectionType === 'string') { - collectionString = collectionType; - } else { - const tempObject = new collectionType(); - collectionString = tempObject.collectionString; - } - + public remove(collectionString: string, ...ids: number[]): void { const maxChangeId = 0; ids.forEach(id => { if (this.modelStore[collectionString]) { @@ -338,7 +330,7 @@ export class DataStoreService { * Updates the cache by inserting the serialized DataStore. Also changes the chageId, if it's larger * @param maxChangeId */ - private storeToCache(maxChangeId: number) { + private storeToCache(maxChangeId: number): void { this.cacheService.set(DataStoreService.cachePrefix + 'DS', this.JsonStore); if (maxChangeId > this._maxChangeId) { this._maxChangeId = maxChangeId; diff --git a/client/src/app/core/services/openslides.service.ts b/client/src/app/core/services/openslides.service.ts index 769dbee87..f78c3269c 100644 --- a/client/src/app/core/services/openslides.service.ts +++ b/client/src/app/core/services/openslides.service.ts @@ -84,7 +84,7 @@ export class OpenSlidesService extends OpenSlidesComponent { /** * Init DS from cache and after this start the websocket service. */ - private setupDataStoreAndWebSocket() { + private setupDataStoreAndWebSocket(): void { this.DS.initFromCache().then((changeId: number) => { this.websocketService.connect( false, diff --git a/client/src/app/core/services/operator.service.ts b/client/src/app/core/services/operator.service.ts index 4777a5355..5e4449fd8 100644 --- a/client/src/app/core/services/operator.service.ts +++ b/client/src/app/core/services/operator.service.ts @@ -69,7 +69,7 @@ export class OperatorService extends OpenSlidesComponent { /** * The subject that can be observed by other instances using observing functions. */ - private operatorSubject: BehaviorSubject = new BehaviorSubject(null); + private operatorSubject: BehaviorSubject = new BehaviorSubject(null); /** * @param http HttpClient @@ -82,7 +82,7 @@ export class OperatorService extends OpenSlidesComponent { * Setup the subscription of the DataStore.Update the user and it's * permissions if the user or groups changes. */ - public setupSubscription() { + public setupSubscription(): void { this.DS.changeObservable.subscribe(newModel => { if (this._user) { if (newModel instanceof Group) { @@ -120,7 +120,7 @@ export class OperatorService extends OpenSlidesComponent { * Services an components can use it to get informed when something changes in * the operator */ - public getObservable() { + public getObservable(): Observable { return this.operatorSubject.asObservable(); } diff --git a/client/src/app/core/services/viewport.service.ts b/client/src/app/core/services/viewport.service.ts index 172f8fcae..cf7ad80b8 100644 --- a/client/src/app/core/services/viewport.service.ts +++ b/client/src/app/core/services/viewport.service.ts @@ -40,7 +40,7 @@ export class ViewportService { * Needs to be called (exactly) once. * Will observe breakpoints and updates the _isMobile variable */ - public checkForChange() { + public checkForChange(): void { this.breakpointObserver .observe([Breakpoints.Small, Breakpoints.HandsetPortrait]) .subscribe((state: BreakpointState) => { @@ -52,7 +52,7 @@ export class ViewportService { }); } - public get isMobile() { + public get isMobile(): boolean { return this._isMobile; } } diff --git a/client/src/app/core/services/websocket.service.ts b/client/src/app/core/services/websocket.service.ts index 83ba5ac7f..aee2dde51 100644 --- a/client/src/app/core/services/websocket.service.ts +++ b/client/src/app/core/services/websocket.service.ts @@ -83,7 +83,7 @@ export class WebsocketService { * * Uses NgZone to let all callbacks run in the angular context. */ - public connect(retry = false, changeId?: number): void { + public connect(retry: boolean = false, changeId?: number): void { if (this.websocket) { return; } diff --git a/client/src/app/openslides.component.ts b/client/src/app/openslides.component.ts index e231a5f3a..0e191e43e 100644 --- a/client/src/app/openslides.component.ts +++ b/client/src/app/openslides.component.ts @@ -54,7 +54,7 @@ export abstract class OpenSlidesComponent { * TODO: could have more features * @return an observable error */ - public handleError() { + public handleError(): (error: any) => Observable { return (error: any): Observable => { console.error(error); return of(error); diff --git a/client/src/app/projector-container/projector-container.component.ts b/client/src/app/projector-container/projector-container.component.ts index 8ccfe12bc..4e83019b3 100644 --- a/client/src/app/projector-container/projector-container.component.ts +++ b/client/src/app/projector-container/projector-container.component.ts @@ -8,5 +8,5 @@ import { Component, OnInit } from '@angular/core'; export class ProjectorContainerComponent implements OnInit { public constructor() {} - public ngOnInit() {} + public ngOnInit(): void {} } diff --git a/client/src/app/projector-container/projector/projector.component.ts b/client/src/app/projector-container/projector/projector.component.ts index 4a034ed64..30e0280b2 100644 --- a/client/src/app/projector-container/projector/projector.component.ts +++ b/client/src/app/projector-container/projector/projector.component.ts @@ -12,7 +12,7 @@ export class ProjectorComponent extends BaseComponent implements OnInit { super(titleService); } - public ngOnInit() { + public ngOnInit(): void { super.setTitle('Projector'); } } diff --git a/client/src/app/shared/components/footer/footer.component.ts b/client/src/app/shared/components/footer/footer.component.ts index bfcd35c66..70a3d4c73 100644 --- a/client/src/app/shared/components/footer/footer.component.ts +++ b/client/src/app/shared/components/footer/footer.component.ts @@ -25,5 +25,5 @@ export class FooterComponent implements OnInit { /** * empty onInit */ - public ngOnInit() {} + public ngOnInit(): void {} } diff --git a/client/src/app/shared/components/head-bar/head-bar.component.ts b/client/src/app/shared/components/head-bar/head-bar.component.ts index 8237d8b58..8ee96c415 100644 --- a/client/src/app/shared/components/head-bar/head-bar.component.ts +++ b/client/src/app/shared/components/head-bar/head-bar.component.ts @@ -86,20 +86,20 @@ export class HeadBarComponent implements OnInit { /** * empty onInit */ - public ngOnInit() {} + public ngOnInit(): void {} /** * Emits a signal to the parent if an item in the menu was clicked. * @param item */ - public clickMenu(item: any) { + public clickMenu(item: any): void { this.ellipsisMenuItem.emit(item); } /** * Emits a signal to the parent if */ - public clickPlusButton() { + public clickPlusButton(): void { this.plusButtonClicked.emit(true); } } diff --git a/client/src/app/shared/directives/perms.directive.ts b/client/src/app/shared/directives/perms.directive.ts index 738e281fd..3f4f4f474 100644 --- a/client/src/app/shared/directives/perms.directive.ts +++ b/client/src/app/shared/directives/perms.directive.ts @@ -51,7 +51,7 @@ export class PermsDirective extends OpenSlidesComponent { * The value defines the requires permissions as an array or a single permission. */ @Input() - public set osPerms(value) { + public set osPerms(value: string | string[]) { if (!value) { value = []; } else if (typeof value === 'string') { diff --git a/client/src/app/shared/models/base.model.ts b/client/src/app/shared/models/base.model.ts index 5e2059292..6f0522d42 100644 --- a/client/src/app/shared/models/base.model.ts +++ b/client/src/app/shared/models/base.model.ts @@ -15,7 +15,7 @@ export abstract class BaseModel extends OpenSlidesComponent implements Deseriali * @param collectionString * @param type */ - public static registerCollectionElement(collectionString: string, type: any) { + public static registerCollectionElement(collectionString: string, type: any): void { CollectionStringModelMapperService.registerCollectionElement(collectionString, type); } diff --git a/client/src/app/shared/models/motions/motion.ts b/client/src/app/shared/models/motions/motion.ts index 5704af5fa..697b804de 100644 --- a/client/src/app/shared/models/motions/motion.ts +++ b/client/src/app/shared/models/motions/motion.ts @@ -67,14 +67,14 @@ export class Motion extends BaseModel { /** * update the values of the motion with new values */ - public patchValues(update: object) { + public patchValues(update: object): void { Object.assign(this, update); } /** * sets the and the workflow from either dataStore or WebSocket */ - public initDataStoreValues() { + public initDataStoreValues(): void { // check the containing Workflows in DataStore const allWorkflows = this.DS.getAll(Workflow); allWorkflows.forEach(localWorkflow => { @@ -97,7 +97,7 @@ export class Motion extends BaseModel { * add a new motionSubmitter from user-object * @param user the user */ - public addSubmitter(user: User) { + public addSubmitter(user: User): void { const newSubmitter = new MotionSubmitter(); newSubmitter.user_id = user.id; this.submitters.push(newSubmitter); @@ -107,7 +107,7 @@ export class Motion extends BaseModel { /** * return the submitters as uses objects */ - public get submitterAsUser() { + public get submitterAsUser(): User[] { const submitterIds: number[] = this.submitters .sort((a: MotionSubmitter, b: MotionSubmitter) => { return a.weight - b.weight; @@ -133,11 +133,11 @@ export class Motion extends BaseModel { /** * return the workflow state */ - public get state(): any { + public get state(): WorkflowState { if (this.workflow) { return this.workflow.state_by_id(this.state_id); } else { - return ''; + return null; } } @@ -157,29 +157,29 @@ export class Motion extends BaseModel { * * TODO: Motion workflow needs to be specific on the server */ - public get recommendation(): any { + public get recommendation(): WorkflowState { if (this.recommendation_id && this.workflow && this.workflow.id) { const state = this.workflow.state_by_id(this.recommendation_id); return state; } else { - return ''; + return null; } } /** * returns the value of 'config.motions_recommendations_by' */ - public get recomBy() { + public get recomBy(): string { const motionsRecommendationsByConfig = this.DS.filter( Config, config => config.key === 'motions_recommendations_by' )[0] as Config; if (motionsRecommendationsByConfig) { - const recomByString = motionsRecommendationsByConfig.value; + const recomByString: string = motionsRecommendationsByConfig.value as string; return recomByString; } else { - return null; + return ''; } } diff --git a/client/src/app/shared/models/users/group.ts b/client/src/app/shared/models/users/group.ts index 26fac8804..ae458cf7e 100644 --- a/client/src/app/shared/models/users/group.ts +++ b/client/src/app/shared/models/users/group.ts @@ -19,7 +19,7 @@ export class Group extends BaseModel { } } - public get users() { + public get users(): User[] { // We have to use the string version to avoid circular dependencies. return this.DS.filter('users/user', user => { return user.groups_id.includes(this.id); diff --git a/client/src/app/site/agenda/agenda-list/agenda-list.component.ts b/client/src/app/site/agenda/agenda-list/agenda-list.component.ts index bd679e0a2..b5bb46055 100644 --- a/client/src/app/site/agenda/agenda-list/agenda-list.component.ts +++ b/client/src/app/site/agenda/agenda-list/agenda-list.component.ts @@ -29,7 +29,7 @@ export class AgendaListComponent extends BaseComponent implements OnInit { * Init function. * Sets the title */ - public ngOnInit() { + public ngOnInit(): void { super.setTitle('Agenda'); // tslint:disable-next-line const i: Item = new Item(); // Needed, that the Item.ts is loaded. Can be removed, if something else creates/uses items. @@ -41,7 +41,7 @@ export class AgendaListComponent extends BaseComponent implements OnInit { * Handler for the plus button. * Comes from the HeadBar Component */ - public onPlusButton() { + public onPlusButton(): void { console.log('create new motion'); } } diff --git a/client/src/app/site/assignments/assignment-list/assignment-list.component.ts b/client/src/app/site/assignments/assignment-list/assignment-list.component.ts index 71eb498aa..94852b825 100644 --- a/client/src/app/site/assignments/assignment-list/assignment-list.component.ts +++ b/client/src/app/site/assignments/assignment-list/assignment-list.component.ts @@ -39,14 +39,14 @@ export class AssignmentListComponent extends BaseComponent implements OnInit { /** * Click on the plus button delegated from head-bar */ - public onPlusButton() { + public onPlusButton(): void { console.log('create new assignments'); } /** * Init function. Sets the title. */ - public ngOnInit() { + public ngOnInit(): void { super.setTitle('Assignments'); // tslint:disable-next-line @@ -66,7 +66,7 @@ export class AssignmentListComponent extends BaseComponent implements OnInit { * * @param event clicked entry from ellipsis menu */ - public onEllipsisItem(event: any) { + public onEllipsisItem(event: any): void { if (event.action) { this[event.action](); } diff --git a/client/src/app/site/legal-notice/legal-notice.component.ts b/client/src/app/site/legal-notice/legal-notice.component.ts index e811c81a8..c3b739d87 100644 --- a/client/src/app/site/legal-notice/legal-notice.component.ts +++ b/client/src/app/site/legal-notice/legal-notice.component.ts @@ -12,7 +12,7 @@ export class LegalNoticeComponent implements OnInit { public constructor(private configService: ConfigService, private translate: TranslateService) {} - public ngOnInit() { + public ngOnInit(): void { this.configService.get('general_event_legal_notice').subscribe(value => { if (value) { this.legalNotice = this.translate.instant(value); diff --git a/client/src/app/site/mediafiles/mediafile-list/mediafile-list.component.ts b/client/src/app/site/mediafiles/mediafile-list/mediafile-list.component.ts index 94f7f1acf..236226d84 100644 --- a/client/src/app/site/mediafiles/mediafile-list/mediafile-list.component.ts +++ b/client/src/app/site/mediafiles/mediafile-list/mediafile-list.component.ts @@ -42,14 +42,14 @@ export class MediafileListComponent extends BaseComponent implements OnInit { * Init. * Set the title */ - public ngOnInit() { + public ngOnInit(): void { super.setTitle('Files'); } /** * Click on the plus button delegated from head-bar */ - public onPlusButton() { + public onPlusButton(): void { console.log('clicked plus (mediafile)'); } @@ -59,7 +59,7 @@ export class MediafileListComponent extends BaseComponent implements OnInit { * * TODO: Not yet implemented, might not even be required */ - public deleteAllFiles() { + public deleteAllFiles(): void { console.log('do download'); } @@ -68,7 +68,7 @@ export class MediafileListComponent extends BaseComponent implements OnInit { * * @param event clicked entry from ellipsis menu */ - public onEllipsisItem(event: any) { + public onEllipsisItem(event: any): void { if (event.action) { this[event.action](); } diff --git a/client/src/app/site/motions/category-list/category-list.component.ts b/client/src/app/site/motions/category-list/category-list.component.ts index 009524180..53e89079e 100644 --- a/client/src/app/site/motions/category-list/category-list.component.ts +++ b/client/src/app/site/motions/category-list/category-list.component.ts @@ -51,7 +51,7 @@ export class CategoryListComponent extends BaseComponent implements OnInit { * * Sets the title and gets/observes categories from DataStore */ - public ngOnInit() { + public ngOnInit(): void { super.setTitle('Category'); this.categoryArray = this.DS.getAll(Category); this.dataSource = new MatTableDataSource(this.categoryArray); @@ -72,7 +72,7 @@ export class CategoryListComponent extends BaseComponent implements OnInit { * * TODO: Not yet implemented */ - public onPlusButton() { + public onPlusButton(): void { console.log('Add New Category'); } } diff --git a/client/src/app/site/motions/motion-detail/motion-detail.component.ts b/client/src/app/site/motions/motion-detail/motion-detail.component.ts index d23fa6c17..264dadf24 100644 --- a/client/src/app/site/motions/motion-detail/motion-detail.component.ts +++ b/client/src/app/site/motions/motion-detail/motion-detail.component.ts @@ -105,7 +105,7 @@ export class MotionDetailComponent extends BaseComponent implements OnInit { /** * Async load the values of the motion in the Form. */ - public patchForm(formMotion: Motion) { + public patchForm(formMotion: Motion): void { this.metaInfoForm.patchValue({ category_id: formMotion.category_id, state_id: formMotion.state_id, @@ -125,7 +125,7 @@ export class MotionDetailComponent extends BaseComponent implements OnInit { * * TODO: Build a custom form validator */ - public createForm() { + public createForm(): void { this.metaInfoForm = this.formBuilder.group({ identifier: [''], category_id: [''], @@ -149,7 +149,7 @@ export class MotionDetailComponent extends BaseComponent implements OnInit { * * TODO: state is not yet saved. Need a special "put" command */ - public saveMotion() { + public saveMotion(): void { const newMotionValues = { ...this.metaInfoForm.value, ...this.contentForm.value }; this.motionCopy.patchValues(newMotionValues); @@ -171,7 +171,7 @@ export class MotionDetailComponent extends BaseComponent implements OnInit { /** * Click on the edit button (pen-symbol) */ - public editMotionButton() { + public editMotionButton(): void { this.editMotion ? (this.editMotion = false) : (this.editMotion = true); if (this.editMotion) { // copy the motion @@ -191,7 +191,7 @@ export class MotionDetailComponent extends BaseComponent implements OnInit { /** * Trigger to delete the motion */ - public deleteMotionButton() { + public deleteMotionButton(): void { this.dataSend.delete(this.motion).subscribe(answer => { this.router.navigate(['./motions/']); }); @@ -200,5 +200,5 @@ export class MotionDetailComponent extends BaseComponent implements OnInit { /** * Init. Does nothing here. */ - public ngOnInit() {} + public ngOnInit(): void {} } diff --git a/client/src/app/site/motions/motion-list/motion-list.component.ts b/client/src/app/site/motions/motion-list/motion-list.component.ts index e2c6b3f7d..417a487fe 100644 --- a/client/src/app/site/motions/motion-list/motion-list.component.ts +++ b/client/src/app/site/motions/motion-list/motion-list.component.ts @@ -6,6 +6,7 @@ import { TranslateService } from '@ngx-translate/core'; import { Motion } from '../../../shared/models/motions/motion'; import { MatTable, MatPaginator, MatSort, MatTableDataSource } from '@angular/material'; import { Workflow } from '../../../shared/models/motions/workflow'; +import { WorkflowState } from '../../../shared/models/motions/workflow-state'; /** * Component that displays all the motions in a Table using DataSource. @@ -91,7 +92,7 @@ export class MotionListComponent extends BaseComponent implements OnInit { /** * Init function */ - public ngOnInit() { + public ngOnInit(): void { super.setTitle('Motions'); this.workflowArray = this.DS.getAll(Workflow); this.motionArray = this.DS.getAll(Motion); @@ -114,7 +115,7 @@ export class MotionListComponent extends BaseComponent implements OnInit { * * @param motion The row the user clicked at */ - public selectMotion(motion) { + public selectMotion(motion: Motion): void { this.router.navigate(['./' + motion.id], { relativeTo: this.route }); } @@ -123,7 +124,7 @@ export class MotionListComponent extends BaseComponent implements OnInit { * TODO Needs to be more accessible (Motion workflow needs adjustment on the server) * @param state the name of the state */ - public getStateIcon(state) { + public getStateIcon(state: WorkflowState): string { const stateName = state.name; if (stateName === 'accepted') { return 'thumbs-up'; @@ -140,21 +141,21 @@ export class MotionListComponent extends BaseComponent implements OnInit { * Determines if an icon should be shown in the list view * @param state */ - public isDisplayIcon(state): boolean { + public isDisplayIcon(state: WorkflowState): boolean { return state.name === 'accepted' || state.name === 'rejected' || state.name === 'not decided'; } /** * Handler for the plus button */ - public onPlusButton() { + public onPlusButton(): void { this.router.navigate(['./new'], { relativeTo: this.route }); } /** * navigate to 'motion/category' */ - public toCategories() { + public toCategories(): void { this.router.navigate(['./category'], { relativeTo: this.route }); } @@ -163,7 +164,7 @@ export class MotionListComponent extends BaseComponent implements OnInit { * * TODO: Currently does nothing */ - public downloadMotions() { + public downloadMotions(): void { console.log('Download Motions Button'); } @@ -172,7 +173,7 @@ export class MotionListComponent extends BaseComponent implements OnInit { * * @param event clicked entry from ellipsis menu */ - public onEllipsisItem(event: any) { + public onEllipsisItem(event: any): void { if (event.action) { this[event.action](); } diff --git a/client/src/app/site/privacy-policy/privacy-policy.component.ts b/client/src/app/site/privacy-policy/privacy-policy.component.ts index f6993c9b0..fb81e8f37 100644 --- a/client/src/app/site/privacy-policy/privacy-policy.component.ts +++ b/client/src/app/site/privacy-policy/privacy-policy.component.ts @@ -8,5 +8,5 @@ import { Component, OnInit } from '@angular/core'; export class PrivacyPolicyComponent implements OnInit { public constructor() {} - public ngOnInit() {} + public ngOnInit(): void {} } diff --git a/client/src/app/site/settings/settings-list/settings-list.component.ts b/client/src/app/site/settings/settings-list/settings-list.component.ts index a8c0b5feb..8c02d2559 100644 --- a/client/src/app/site/settings/settings-list/settings-list.component.ts +++ b/client/src/app/site/settings/settings-list/settings-list.component.ts @@ -26,7 +26,7 @@ export class SettingsListComponent extends BaseComponent implements OnInit { /** * Init function. Sets the title */ - public ngOnInit() { + public ngOnInit(): void { super.setTitle('Settings'); } } diff --git a/client/src/app/site/site.component.ts b/client/src/app/site/site.component.ts index 679753285..fc09d1c58 100644 --- a/client/src/app/site/site.component.ts +++ b/client/src/app/site/site.component.ts @@ -64,7 +64,7 @@ export class SiteComponent extends BaseComponent implements OnInit { /** * Initialize the site component */ - public ngOnInit() { + public ngOnInit(): void { this.vp.checkForChange(); // get a translation via code: use the translation service @@ -81,7 +81,7 @@ export class SiteComponent extends BaseComponent implements OnInit { /** * Closes the sidenav in mobile view */ - public toggleSideNav() { + public toggleSideNav(): void { if (this.vp.isMobile) { this.sideNav.toggle(); } @@ -109,15 +109,15 @@ export class SiteComponent extends BaseComponent implements OnInit { } // TODO: Implement this - public editProfile() {} + public editProfile(): void {} // TODO: Implement this - public changePassword() {} + public changePassword(): void {} /** * Function to log out the current user */ - public logout() { + public logout(): void { this.authService.logout(); } } diff --git a/client/src/app/site/start/start.component.ts b/client/src/app/site/start/start.component.ts index a9e34e7e0..94e3c53a4 100644 --- a/client/src/app/site/start/start.component.ts +++ b/client/src/app/site/start/start.component.ts @@ -37,7 +37,7 @@ export class StartComponent extends BaseComponent implements OnInit { * And observes DataStore for changes * Set title and observe DataStore for changes. */ - public ngOnInit() { + public ngOnInit(): void { // required dummy translation, cause translations for config values were never set // tslint:disable-next-line const welcomeTitleTranslateDummy = this.translate.instant('Welcome to OpenSlides'); @@ -77,7 +77,7 @@ export class StartComponent extends BaseComponent implements OnInit { /** * test data store */ - public DataStoreTest() { + public DataStoreTest(): void { console.log('add a user to dataStore'); this.DS.add(new User({ id: 100 })); console.log('add three users to dataStore'); @@ -107,14 +107,14 @@ export class StartComponent extends BaseComponent implements OnInit { /** * function to print datastore */ - public giveDataStore() { + public giveDataStore(): void { this.DS.printWhole(); } /** * test translations in component */ - public TranslateTest() { + public TranslateTest(): void { console.log('lets translate the word "motion" in the current in the current lang'); console.log('Motions in ' + this.translate.currentLang + ' is ' + this.translate.instant('Motions')); } diff --git a/client/src/app/site/users/user-list/user-list.component.ts b/client/src/app/site/users/user-list/user-list.component.ts index b07389915..26c0ea84f 100644 --- a/client/src/app/site/users/user-list/user-list.component.ts +++ b/client/src/app/site/users/user-list/user-list.component.ts @@ -26,7 +26,7 @@ export class UserListComponent extends BaseComponent implements OnInit { /** * Init function, sets the title */ - public ngOnInit() { + public ngOnInit(): void { super.setTitle('Users'); } } diff --git a/client/src/tslint.json b/client/src/tslint.json index 654f99902..bca4a513c 100644 --- a/client/src/tslint.json +++ b/client/src/tslint.json @@ -15,6 +15,14 @@ "order": ["static-field", "static-method", "instance-field", "constructor", "instance-method"] } ], - "no-unused-variable": true + "no-unused-variable": true, + "typedef": [ + true, + "call-signature", + "property-declaration", + "parameter", + "object-destructuring", + "array-destructuring" + ] } }