diff --git a/client/.eslintrc.js b/client/.eslintrc.js index 646883db1c..6d589a6361 100644 --- a/client/.eslintrc.js +++ b/client/.eslintrc.js @@ -62,6 +62,9 @@ module.exports = { 'message': 'Please use a typecast or explicitly instantiate a new Observable.' }], 'lines-between-class-members': ['error', 'always', { 'exceptAfterSingleLine': true }], + '@typescript-eslint/no-unnecessary-type-constraint': ['error'], + '@typescript-eslint/no-this-alias': ['error'], + '@typescript-eslint/adjacent-overload-signatures': ['error'], 'jsdoc/require-example': ['off'], 'jsdoc/newline-after-description': ['off'], @@ -71,10 +74,7 @@ module.exports = { 'rxjs/no-async-subscribe': ['off'], // Should be switched to error ordered by priority - '@typescript-eslint/no-unnecessary-type-constraint': ['warn'], - '@typescript-eslint/no-this-alias': ['warn'], '@typescript-eslint/ban-types': ['warn'], - '@typescript-eslint/adjacent-overload-signatures': ['warn'], '@typescript-eslint/ban-ts-comment': ['warn'], '@typescript-eslint/no-explicit-any': ['off'], '@typescript-eslint/no-non-null-assertion': ['off'], diff --git a/client/src/app/domain/models/organizations/organization.ts b/client/src/app/domain/models/organizations/organization.ts index 09b5d2e72d..76db09381a 100644 --- a/client/src/app/domain/models/organizations/organization.ts +++ b/client/src/app/domain/models/organizations/organization.ts @@ -29,7 +29,7 @@ export class OrganizationSetting { public saml_enabled!: boolean; // default: false public saml_login_button_text!: string; - public saml_attr_mapping!: Object; + public saml_attr_mapping!: unknown; public saml_metadata_idp!: string; public saml_metadata_sp!: string; public saml_private_key!: string; diff --git a/client/src/app/gateways/actions/action-utils.ts b/client/src/app/gateways/actions/action-utils.ts index eafe5241a8..6832f98fd7 100644 --- a/client/src/app/gateways/actions/action-utils.ts +++ b/client/src/app/gateways/actions/action-utils.ts @@ -3,13 +3,13 @@ export interface ActionRequest { data: any[]; } -export interface ActionResponse { +export interface ActionResponse { success: true; message: string; results?: ((T | null)[] | null)[]; } -export function isActionResponse(obj: any): obj is ActionResponse { +export function isActionResponse(obj: any): obj is ActionResponse { const response = obj as ActionResponse; return !!obj && response.success === true && !!response.message; } diff --git a/client/src/app/infrastructure/utils/functions.ts b/client/src/app/infrastructure/utils/functions.ts index 144369ab14..e1c4fbed7e 100644 --- a/client/src/app/infrastructure/utils/functions.ts +++ b/client/src/app/infrastructure/utils/functions.ts @@ -381,7 +381,7 @@ export function isValidId(id: number): boolean { * Returns a version of the given object that lacks all key-value pairs that don't fulfill the condition. * Doesn't change the original object. */ -export function filterObject(obj: Object, callbackFn: (keyValue: { key: string; value: any }) => boolean): Object { +export function filterObject(obj: unknown, callbackFn: (keyValue: { key: string; value: any }) => boolean): unknown { if (!obj) { return obj; } @@ -437,7 +437,7 @@ export function replaceObjectKeys( object: { [key: string]: any }, config: ObjectReplaceKeysConfig, reverse?: boolean -): Object { +): { [key: string]: any } { if (reverse) { return replaceObjectKeys( object, diff --git a/client/src/app/infrastructure/utils/import/import-context.ts b/client/src/app/infrastructure/utils/import/import-context.ts index 4733a5eaa3..a6fe2b7a07 100644 --- a/client/src/app/infrastructure/utils/import/import-context.ts +++ b/client/src/app/infrastructure/utils/import/import-context.ts @@ -29,14 +29,14 @@ export class ImportContext { return this._importStepPhaseSubject.value; } - public get phaseObservable(): Observable { - return this._importStepPhaseSubject; - } - public set phase(value: ImportStepPhase) { this._importStepPhaseSubject.next(value); } + public get phaseObservable(): Observable { + return this._importStepPhaseSubject; + } + private _data: { [key: string]: any } = {}; private readonly _modelsToCreateSubject = new BehaviorSubject([]); diff --git a/client/src/app/infrastructure/utils/overload-js-functions.ts b/client/src/app/infrastructure/utils/overload-js-functions.ts index 9fa2bcc5c0..c6a258fdad 100644 --- a/client/src/app/infrastructure/utils/overload-js-functions.ts +++ b/client/src/app/infrastructure/utils/overload-js-functions.ts @@ -91,13 +91,12 @@ function overloadArrayFunctions(): void { Object.defineProperty(Array.prototype, `intersect`, { value(other: T[] = []): T[] { - let a = this; - let b = other; - if (b.length < a.length) { - [a, b] = [b, a]; + if (other.length < this.length) { + const intersect = new Set(this); + return other.filter((element: T) => intersect.has(element)); } - const intersect = new Set(b); - return a.filter((element: T) => intersect.has(element)); + const intersect = new Set(other); + return this.filter((element: T) => intersect.has(element)); }, enumerable: false }); diff --git a/client/src/app/openslides-main-module/services/dom.service.ts b/client/src/app/openslides-main-module/services/dom.service.ts index 0afb5e91e0..f08160b457 100644 --- a/client/src/app/openslides-main-module/services/dom.service.ts +++ b/client/src/app/openslides-main-module/services/dom.service.ts @@ -25,7 +25,7 @@ export class BodyPortal { } } - public attach(componentType: Type, data: Object = {}): void { + public attach(componentType: Type, data: unknown = {}): void { this._viewContainer.clear(); this.showPane(); const componentRef = this.createComponentRef(componentType, data); @@ -45,7 +45,7 @@ export class BodyPortal { } } - private createComponentRef(component: Type, data: Object = {}): ComponentRef { + private createComponentRef(component: Type, data: unknown = {}): ComponentRef { const componentRef = this._viewContainer.createComponent(component); for (const key of Object.keys(data)) { componentRef.instance[key] = data[key]; @@ -96,7 +96,7 @@ export class DomService { return new BodyPortal({ viewContainer, root: this._pane! }); } - public attachComponent(componentType: Type, data: Object = {}): ComponentRef { + public attachComponent(componentType: Type, data: unknown = {}): ComponentRef { this._viewContainer.clear(); this.showPane(); const componentRef = this.createComponentRef(componentType, data); @@ -114,7 +114,7 @@ export class DomService { this.hidePane(); } - private createComponentRef(component: Type, data: Object = {}): ComponentRef { + private createComponentRef(component: Type, data: unknown = {}): ComponentRef { const componentRef = this._viewContainer.createComponent(component); for (const key of Object.keys(data)) { componentRef.instance[key] = data[key]; diff --git a/client/src/app/site/modules/translations/openslides-translation.service.ts b/client/src/app/site/modules/translations/openslides-translation.service.ts index 6b115b8732..c426827064 100644 --- a/client/src/app/site/modules/translations/openslides-translation.service.ts +++ b/client/src/app/site/modules/translations/openslides-translation.service.ts @@ -46,7 +46,7 @@ export class OpenSlidesTranslationService extends TranslateService { * * @override */ - public override get(key: string | string[], interpolateParams?: Object): Observable { + public override get(key: string | string[], interpolateParams?: unknown): Observable { try { return super.get(key, interpolateParams); } catch { @@ -59,7 +59,7 @@ export class OpenSlidesTranslationService extends TranslateService { * * @override */ - public override stream(key: string | string[], interpolateParams?: Object): Observable { + public override stream(key: string | string[], interpolateParams?: unknown): Observable { try { return super.stream(key, interpolateParams); } catch { @@ -72,7 +72,7 @@ export class OpenSlidesTranslationService extends TranslateService { * * @override */ - public override instant(key: string | string[], interpolateParams?: Object): string | any { + public override instant(key: string | string[], interpolateParams?: unknown): string | any { try { return super.instant(key, interpolateParams); } catch { diff --git a/client/src/app/site/pages/meetings/modules/poll/components/entitled-users-table/entitled-users-table.component.ts b/client/src/app/site/pages/meetings/modules/poll/components/entitled-users-table/entitled-users-table.component.ts index fdbf7bbcef..f3023c7c75 100644 --- a/client/src/app/site/pages/meetings/modules/poll/components/entitled-users-table/entitled-users-table.component.ts +++ b/client/src/app/site/pages/meetings/modules/poll/components/entitled-users-table/entitled-users-table.component.ts @@ -26,6 +26,12 @@ export class EntitledUsersTableComponent { ); } + public get entitledUsersObservable(): Observable { + return this._entitledUsersObservable; + } + + private _entitledUsersObservable!: Observable; + @Input() public set isViewingThis(value: boolean) { this._isViewingThis = value; @@ -38,13 +44,6 @@ export class EntitledUsersTableComponent { public readonly permission = Permission; public filterPropsEntitledUsersTable = [`user.full_name`, `vote_delegated_to.full_name`, `voted_verbose`]; - - public get entitledUsersObservable(): Observable { - return this._entitledUsersObservable; - } - - private _entitledUsersObservable!: Observable; - constructor(private controller: ParticipantControllerService) {} private getNameFromEntry(entry: EntitledUsersTableEntry): string { diff --git a/client/src/app/site/pages/meetings/modules/poll/components/single-option-chart-table/single-option-chart-table.component.ts b/client/src/app/site/pages/meetings/modules/poll/components/single-option-chart-table/single-option-chart-table.component.ts index d844364dd4..80d9f61e24 100644 --- a/client/src/app/site/pages/meetings/modules/poll/components/single-option-chart-table/single-option-chart-table.component.ts +++ b/client/src/app/site/pages/meetings/modules/poll/components/single-option-chart-table/single-option-chart-table.component.ts @@ -30,6 +30,10 @@ export class SingleOptionChartTableComponent { } } + public get tableData(): PollTableData[] { + return this._tableData; + } + @Input() public set pollService(pollService: PollService) { this._pollService = pollService; @@ -37,6 +41,10 @@ export class SingleOptionChartTableComponent { this.cd.markForCheck(); } + public get pollService() { + return this._pollService || this.defaultPollService; + } + @Input() public set poll(pollData: PollData) { this._poll = pollData; @@ -44,6 +52,10 @@ export class SingleOptionChartTableComponent { this.cd.markForCheck(); } + public get poll(): PollData { + return this._poll; + } + private get method(): string | null { return this.poll?.pollmethod || null; } @@ -54,22 +66,10 @@ export class SingleOptionChartTableComponent { @Input() public shouldShowEntitled = false; - public get pollService() { - return this._pollService || this.defaultPollService; - } - - public get poll(): PollData { - return this._poll; - } - public get chartData(): ChartData { return this._chartData; } - public get tableData(): PollTableData[] { - return this._tableData; - } - public get isMethodY(): boolean { return this.method === PollMethod.Y; } diff --git a/client/src/app/site/pages/meetings/modules/poll/components/votes-table/votes-table.component.ts b/client/src/app/site/pages/meetings/modules/poll/components/votes-table/votes-table.component.ts index 49cb1b98bb..5d266008df 100644 --- a/client/src/app/site/pages/meetings/modules/poll/components/votes-table/votes-table.component.ts +++ b/client/src/app/site/pages/meetings/modules/poll/components/votes-table/votes-table.component.ts @@ -25,30 +25,30 @@ export class VotesTableComponent { ); } + public get votesDataObservable(): Observable { + return this._votesDataObservable; + } + @Input() public set isViewingThis(value: boolean) { this._isViewingThis = value; } + public get isViewingThis(): boolean { + return this._isViewingThis; + } + @Input() public parent: BasePollDetailComponent; @Input() public templateType = ``; - public get isViewingThis(): boolean { - return this._isViewingThis; - } - public readonly permission = Permission; @Input() public filterProps = [`user.full_name`, `valueVerbose`]; - public get votesDataObservable(): Observable { - return this._votesDataObservable; - } - private _votesDataObservable!: Observable; public getVoteIcon(voteValue: string): string { diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/topics/modules/topic-poll/components/topic-poll-vote/topic-poll-vote.component.ts b/client/src/app/site/pages/meetings/pages/agenda/modules/topics/modules/topic-poll/components/topic-poll-vote/topic-poll-vote.component.ts index cd4f0e3a33..d3fce9b503 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/topics/modules/topic-poll/components/topic-poll-vote/topic-poll-vote.component.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/topics/modules/topic-poll/components/topic-poll-vote/topic-poll-vote.component.ts @@ -245,7 +245,7 @@ export class TopicPollVoteComponent extends BasePollVoteComponent imp this.handleVotingMethodYOrN(maxVotesAmount, tmpVoteRequest, user); } - public handleVotingMethodYOrN(maxVotesAmount: number, tmpVoteRequest: {}, user: ViewUser = this.user) { + public handleVotingMethodYOrN(maxVotesAmount: number, tmpVoteRequest: any, user: ViewUser = this.user) { // check if you can still vote const countedVotes = Object.keys(tmpVoteRequest).filter(key => tmpVoteRequest[key]).length; if (countedVotes <= maxVotesAmount) { @@ -262,7 +262,7 @@ export class TopicPollVoteComponent extends BasePollVoteComponent imp } } - private getTMPVoteRequestYOrN(maxVotesAmount: number, optionId: number, user: ViewUser = this.user): {} { + private getTMPVoteRequestYOrN(maxVotesAmount: number, optionId: number, user: ViewUser = this.user): any { return this.poll.options .map(option => option.id) .reduce((o, n) => { diff --git a/client/src/app/site/pages/meetings/pages/interaction/services/rtc.service.ts b/client/src/app/site/pages/meetings/pages/interaction/services/rtc.service.ts index 2ccbd3ee81..6fc94d53da 100644 --- a/client/src/app/site/pages/meetings/pages/interaction/services/rtc.service.ts +++ b/client/src/app/site/pages/meetings/pages/interaction/services/rtc.service.ts @@ -114,7 +114,7 @@ export class RtcService { return !!this.api; } - private options!: Object; + private options!: unknown; private jitsiNode!: ElementRef; private actualRoomName = ``; diff --git a/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/motion-highlight-form/motion-highlight-form.component.ts b/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/motion-highlight-form/motion-highlight-form.component.ts index 7231f9494c..5d5d182113 100644 --- a/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/motion-highlight-form/motion-highlight-form.component.ts +++ b/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/motion-highlight-form/motion-highlight-form.component.ts @@ -115,11 +115,10 @@ export class MotionHighlightFormComponent extends BaseMotionDetailChildComponent } public ngOnInit(): void { - const self = this; + const maxLineNumber = this.motionLineNumbering.getLastLineNumber(this.motion, this.lineLength); this.highlightedLineMatcher = new (class implements ErrorStateMatcher { public isErrorState(control: UntypedFormControl): boolean { const value: string = control && control.value ? control.value + `` : ``; - const maxLineNumber = self.motionLineNumbering.getLastLineNumber(self.motion, self.lineLength); return value.match(/[^\d]/) !== null || parseInt(value, 10) >= maxLineNumber; } })(); diff --git a/client/src/app/site/pages/meetings/pages/motions/pages/workflows/components/workflow-detail-sort/workflow-detail-sort.component.ts b/client/src/app/site/pages/meetings/pages/motions/pages/workflows/components/workflow-detail-sort/workflow-detail-sort.component.ts index 7d506ac2df..0ff2e99543 100644 --- a/client/src/app/site/pages/meetings/pages/motions/pages/workflows/components/workflow-detail-sort/workflow-detail-sort.component.ts +++ b/client/src/app/site/pages/meetings/pages/motions/pages/workflows/components/workflow-detail-sort/workflow-detail-sort.component.ts @@ -35,6 +35,11 @@ export class WorkflowDetailSortComponent extends BaseModelRequestHandlerComponen return this._hasChanges; } + private set previousStates(newStates: MotionState[]) { + this._previousStates = newStates; + this.compareStates(); + } + private get previousStates(): MotionState[] { return this._previousStates; } @@ -44,11 +49,6 @@ export class WorkflowDetailSortComponent extends BaseModelRequestHandlerComponen private _previousStates: MotionState[] = []; private _hasChanges = false; - private set previousStates(newStates: MotionState[]) { - this._previousStates = newStates; - this.compareStates(); - } - private _workflowId: Id | null = null; public constructor( diff --git a/client/src/app/site/pages/meetings/pages/motions/pages/workflows/components/workflow-detail/workflow-detail.component.ts b/client/src/app/site/pages/meetings/pages/motions/pages/workflows/components/workflow-detail/workflow-detail.component.ts index d5dd6dce2e..12d3464c19 100644 --- a/client/src/app/site/pages/meetings/pages/motions/pages/workflows/components/workflow-detail/workflow-detail.component.ts +++ b/client/src/app/site/pages/meetings/pages/motions/pages/workflows/components/workflow-detail/workflow-detail.component.ts @@ -79,6 +79,12 @@ export class WorkflowDetailComponent extends BaseMeetingComponent { */ public dialogData!: DialogData; + private set workflow(workflow: ViewMotionWorkflow) { + this._workflow = workflow; + this.updateRowDef(); + this.cd.markForCheck(); + } + /** * Holds the current workflow */ @@ -120,12 +126,6 @@ export class WorkflowDetailComponent extends BaseMeetingComponent { { merge: MergeAmendment.YES, label: `Yes` } ] as AmendmentIntoFinal[]; - private set workflow(workflow: ViewMotionWorkflow) { - this._workflow = workflow; - this.updateRowDef(); - this.cd.markForCheck(); - } - private _workflow!: ViewMotionWorkflow; private _workflowId!: Id; diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail/account-detail.component.ts b/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail/account-detail.component.ts index 53888bc807..385dcfb412 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail/account-detail.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail/account-detail.component.ts @@ -91,7 +91,7 @@ export class AccountDetailComponent extends BaseComponent implements OnInit { return Object.values(this._tableData).filter(row => row[`is_manager`] === true).length; } - public tableDataAscOrderCompare = (a: KeyValue, b: KeyValue) => { + public tableDataAscOrderCompare = (a: KeyValue, b: KeyValue) => { const aName = a.value[`committee_name`] ?? a.value[`meeting_name`] ?? ``; const bName = b.value[`committee_name`] ?? b.value[`meeting_name`] ?? ``; return aName.localeCompare(bName); diff --git a/client/src/app/ui/modules/grid/tile/tile.component.ts b/client/src/app/ui/modules/grid/tile/tile.component.ts index 4cb2d5edff..b7e972b5d7 100644 --- a/client/src/app/ui/modules/grid/tile/tile.component.ts +++ b/client/src/app/ui/modules/grid/tile/tile.component.ts @@ -29,7 +29,7 @@ export class TileComponent implements OnInit { * Optional data, that can be passed to the component. */ @Input() - public data: Object | null = null; + public data: any | null = null; /** * Optional input to define the preferred size of the tile. diff --git a/client/src/app/ui/modules/sidenav/modules/easter-egg/components/base-game-dialog/base-game-dialog.ts b/client/src/app/ui/modules/sidenav/modules/easter-egg/components/base-game-dialog/base-game-dialog.ts index 8f8f868cb3..d212acf48a 100644 --- a/client/src/app/ui/modules/sidenav/modules/easter-egg/components/base-game-dialog/base-game-dialog.ts +++ b/client/src/app/ui/modules/sidenav/modules/easter-egg/components/base-game-dialog/base-game-dialog.ts @@ -111,7 +111,7 @@ export abstract class BaseGameDialogComponent implements OnInit, OnDestroy { }, waitForResponse: { receivedACK: { - handle: (notify: NotifyResponse<{}>) => { + handle: (notify: NotifyResponse<{ name: string }>) => { if (notify.sender_channel_id !== this.replyChannel) { return null; } @@ -123,7 +123,7 @@ export abstract class BaseGameDialogComponent implements OnInit, OnDestroy { handle: () => `search` }, receivedRagequit: { - handle: (notify: NotifyResponse<{}>) => + handle: (notify: NotifyResponse<{ name: string }>) => notify.sender_channel_id === this.replyChannel ? `search` : null } }, diff --git a/client/src/app/ui/modules/spinner/components/spinner/spinner.component.ts b/client/src/app/ui/modules/spinner/components/spinner/spinner.component.ts index cb70513049..06fc0fa6f2 100644 --- a/client/src/app/ui/modules/spinner/components/spinner/spinner.component.ts +++ b/client/src/app/ui/modules/spinner/components/spinner/spinner.component.ts @@ -18,6 +18,10 @@ export class SpinnerComponent { this._height = value; } + public get height(): string { + return this._height; + } + @Input() public set width(value: string | number) { if (typeof value === `number`) { @@ -26,10 +30,6 @@ export class SpinnerComponent { this._width = value; } - public get height(): string { - return this._height; - } - public get width(): string { return this._width; } diff --git a/client/src/app/worker/autoupdate/autoupdate-subscription.ts b/client/src/app/worker/autoupdate/autoupdate-subscription.ts index 36039f571e..3eae3ec95f 100644 --- a/client/src/app/worker/autoupdate/autoupdate-subscription.ts +++ b/client/src/app/worker/autoupdate/autoupdate-subscription.ts @@ -49,7 +49,7 @@ export class AutoupdateSubscription { * * @param data The data to be processed */ - public updateData(data: Object): void { + public updateData(data: any): void { for (const port of this.ports) { port.postMessage({ sender: `autoupdate`, @@ -68,7 +68,7 @@ export class AutoupdateSubscription { * * @param data The error data */ - public sendError(data: Object): void { + public sendError(data: any): void { for (const port of this.ports) { port.postMessage({ sender: `autoupdate`, diff --git a/client/src/testing/models/test-change-recommendation.ts b/client/src/testing/models/test-change-recommendation.ts index 7f088210f1..ee1af835e0 100644 --- a/client/src/testing/models/test-change-recommendation.ts +++ b/client/src/testing/models/test-change-recommendation.ts @@ -11,7 +11,7 @@ export class TestChangeRecommendation implements ViewUnifiedChange { public type!: ModificationType; public creation_time!: number; - public constructor(data: Object) { + public constructor(data: unknown) { Object.assign(this, data); }