Skip to content

Commit

Permalink
Fix linter warnings (#3035)
Browse files Browse the repository at this point in the history
  • Loading branch information
Elblinator authored Nov 24, 2023
1 parent f16b123 commit 5d14356
Show file tree
Hide file tree
Showing 22 changed files with 76 additions and 79 deletions.
6 changes: 3 additions & 3 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/domain/models/organizations/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/gateways/actions/action-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ export interface ActionRequest {
data: any[];
}

export interface ActionResponse<T extends {}> {
export interface ActionResponse<T> {
success: true;
message: string;
results?: ((T | null)[] | null)[];
}

export function isActionResponse<T extends {}>(obj: any): obj is ActionResponse<T> {
export function isActionResponse<T>(obj: any): obj is ActionResponse<T> {
const response = obj as ActionResponse<T>;
return !!obj && response.success === true && !!response.message;
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/infrastructure/utils/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -437,7 +437,7 @@ export function replaceObjectKeys(
object: { [key: string]: any },
config: ObjectReplaceKeysConfig,
reverse?: boolean
): Object {
): { [key: string]: any } {
if (reverse) {
return replaceObjectKeys(
object,
Expand Down
8 changes: 4 additions & 4 deletions client/src/app/infrastructure/utils/import/import-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export class ImportContext<ToImport> {
return this._importStepPhaseSubject.value;
}

public get phaseObservable(): Observable<ImportStepPhase> {
return this._importStepPhaseSubject;
}

public set phase(value: ImportStepPhase) {
this._importStepPhaseSubject.next(value);
}

public get phaseObservable(): Observable<ImportStepPhase> {
return this._importStepPhaseSubject;
}

private _data: { [key: string]: any } = {};

private readonly _modelsToCreateSubject = new BehaviorSubject<ToImport[]>([]);
Expand Down
11 changes: 5 additions & 6 deletions client/src/app/infrastructure/utils/overload-js-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,12 @@ function overloadArrayFunctions(): void {

Object.defineProperty(Array.prototype, `intersect`, {
value<T>(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<T>(this);
return other.filter((element: T) => intersect.has(element));
}
const intersect = new Set<T>(b);
return a.filter((element: T) => intersect.has(element));
const intersect = new Set<T>(other);
return this.filter((element: T) => intersect.has(element));
},
enumerable: false
});
Expand Down
8 changes: 4 additions & 4 deletions client/src/app/openslides-main-module/services/dom.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class BodyPortal {
}
}

public attach<T>(componentType: Type<T>, data: Object = {}): void {
public attach<T>(componentType: Type<T>, data: unknown = {}): void {
this._viewContainer.clear();
this.showPane();
const componentRef = this.createComponentRef(componentType, data);
Expand All @@ -45,7 +45,7 @@ export class BodyPortal {
}
}

private createComponentRef<T>(component: Type<T>, data: Object = {}): ComponentRef<T> {
private createComponentRef<T>(component: Type<T>, data: unknown = {}): ComponentRef<T> {
const componentRef = this._viewContainer.createComponent(component);
for (const key of Object.keys(data)) {
componentRef.instance[key] = data[key];
Expand Down Expand Up @@ -96,7 +96,7 @@ export class DomService {
return new BodyPortal({ viewContainer, root: this._pane! });
}

public attachComponent<T>(componentType: Type<T>, data: Object = {}): ComponentRef<T> {
public attachComponent<T>(componentType: Type<T>, data: unknown = {}): ComponentRef<T> {
this._viewContainer.clear();
this.showPane();
const componentRef = this.createComponentRef(componentType, data);
Expand All @@ -114,7 +114,7 @@ export class DomService {
this.hidePane();
}

private createComponentRef<T>(component: Type<T>, data: Object = {}): ComponentRef<T> {
private createComponentRef<T>(component: Type<T>, data: unknown = {}): ComponentRef<T> {
const componentRef = this._viewContainer.createComponent(component);
for (const key of Object.keys(data)) {
componentRef.instance[key] = data[key];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class OpenSlidesTranslationService extends TranslateService {
*
* @override
*/
public override get(key: string | string[], interpolateParams?: Object): Observable<string | any> {
public override get(key: string | string[], interpolateParams?: unknown): Observable<string | any> {
try {
return super.get(key, interpolateParams);
} catch {
Expand All @@ -59,7 +59,7 @@ export class OpenSlidesTranslationService extends TranslateService {
*
* @override
*/
public override stream(key: string | string[], interpolateParams?: Object): Observable<string | any> {
public override stream(key: string | string[], interpolateParams?: unknown): Observable<string | any> {
try {
return super.stream(key, interpolateParams);
} catch {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export class EntitledUsersTableComponent {
);
}

public get entitledUsersObservable(): Observable<EntitledUsersTableEntry[]> {
return this._entitledUsersObservable;
}

private _entitledUsersObservable!: Observable<EntitledUsersTableEntry[]>;

@Input()
public set isViewingThis(value: boolean) {
this._isViewingThis = value;
Expand All @@ -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<EntitledUsersTableEntry[]> {
return this._entitledUsersObservable;
}

private _entitledUsersObservable!: Observable<EntitledUsersTableEntry[]>;

constructor(private controller: ParticipantControllerService) {}

private getNameFromEntry(entry: EntitledUsersTableEntry): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,32 @@ export class SingleOptionChartTableComponent {
}
}

public get tableData(): PollTableData[] {
return this._tableData;
}

@Input()
public set pollService(pollService: PollService) {
this._pollService = pollService;
this.setChartData();
this.cd.markForCheck();
}

public get pollService() {
return this._pollService || this.defaultPollService;
}

@Input()
public set poll(pollData: PollData) {
this._poll = pollData;
this.setChartData();
this.cd.markForCheck();
}

public get poll(): PollData {
return this._poll;
}

private get method(): string | null {
return this.poll?.pollmethod || null;
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ export class VotesTableComponent {
);
}

public get votesDataObservable(): Observable<BaseVoteData[]> {
return this._votesDataObservable;
}

@Input()
public set isViewingThis(value: boolean) {
this._isViewingThis = value;
}

public get isViewingThis(): boolean {
return this._isViewingThis;
}

@Input()
public parent: BasePollDetailComponent<PollContentObject, PollService>;

@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<BaseVoteData[]> {
return this._votesDataObservable;
}

private _votesDataObservable!: Observable<BaseVoteData[]>;

public getVoteIcon(voteValue: string): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class TopicPollVoteComponent extends BasePollVoteComponent<ViewTopic> 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) {
Expand All @@ -262,7 +262,7 @@ export class TopicPollVoteComponent extends BasePollVoteComponent<ViewTopic> 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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class RtcService {
return !!this.api;
}

private options!: Object;
private options!: unknown;
private jitsiNode!: ElementRef;

private actualRoomName = ``;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
})();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T extends unknown>(a: KeyValue<string, T>, b: KeyValue<string, T>) => {
public tableDataAscOrderCompare = <T>(a: KeyValue<string, T>, b: KeyValue<string, T>) => {
const aName = a.value[`committee_name`] ?? a.value[`meeting_name`] ?? ``;
const bName = b.value[`committee_name`] ?? b.value[`meeting_name`] ?? ``;
return aName.localeCompare(bName);
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/ui/modules/grid/tile/tile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 5d14356

Please sign in to comment.