Skip to content

Commit

Permalink
ci: Apply ESLint 9 rules to code
Browse files Browse the repository at this point in the history
  • Loading branch information
MoritzWeber0 committed Sep 2, 2024
1 parent 4f00c42 commit 7416247
Show file tree
Hide file tree
Showing 37 changed files with 119 additions and 128 deletions.
8 changes: 7 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ repos:
- 'eslint-plugin-unused-imports@^4.1.3'
- 'eslint-plugin-tailwindcss@^3.17.4'
- 'eslint-plugin-storybook@^0.9.0--canary.156.ed236ca.0'
args: ['--config', 'frontend/eslint.config.mjs', '--fix']
args:
[
'--config',
'frontend/eslint.config.mjs',
'--fix',
'--no-warn-ignored',
]
types: []
files: '^frontend/'
exclude: '.+\.spec(-helper)?\.ts$|^frontend/src/app/openapi'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { environment } from 'src/environments/environment';
imports: [MatIcon],
})
export class ApiDocumentationComponent {
@Input() tag: string = '';
@Input() hyperlink: string = '';
@Input() tag = '';
@Input() hyperlink = '';

getAPIDocsLink() {
return `${environment.api_docs_url}/redoc#tag/${this.tag}/operation/${this.hyperlink}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class ErrorHandlingInterceptor implements HttpInterceptor {
reader.onload = (e: Event) => {
try {
const errmsg = JSON.parse(
(<FileReaderEventTarget>e.target).result,
(e.target as FileReaderEventTarget).result,
);
reject(
new HttpErrorResponse({
Expand All @@ -130,7 +130,7 @@ export class ErrorHandlingInterceptor implements HttpInterceptor {
url: err.url || undefined,
}),
);
} catch (e) {
} catch {
reject(err);
}
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/general/nav-bar/nav-bar.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ export class NavBarService {
};
}

export type NavBarItem = {
export interface NavBarItem {
name: string;
routerLink?: string | string[];
href?: string;
target?: string;
requiredRole: Role;
icon?: string;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ConfirmationDialogData {
imports: [FormsModule, MatFormField, MatInput, MatButton],
})
export class ConfirmationDialogComponent implements OnInit {
inputText: string = '';
inputText = '';

constructor(
public dialogRef: MatDialogRef<ConfirmationDialogComponent, boolean>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,16 @@ export class PipelineRunService {
}
}

export type PipelineRun = {
export interface PipelineRun {
status: PipelineRunStatus;
triggerer: User;
id: number;
trigger_time: string;
environment: PipelineRunEnvironment;
};

interface PipelineRunEnvironment {
[key: string]: string;
}

type PipelineRunEnvironment = Record<string, string>;

export type PipelineRunStatus =
| 'pending'
| 'scheduled'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ export class PipelineService {
}
}

export type Pipeline = {
export interface Pipeline {
id: number;
t4c_model: SimpleT4CModel;
git_model: BaseGitModel;
run_nightly: boolean;
include_commit_history: boolean;
};
}

export type PostPipeline = {
export interface PostPipeline {
t4cmodelId: number;
gitmodelId: number;
includeCommitHistory: boolean;
runNightly: boolean;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ export class ViewLogsDialogComponent {
}
}

export type ViewLogsData = {
export interface ViewLogsData {
projectSlug: string;
modelSlug: string;
job_id: string;
backup_id: number;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { Meta, StoryObj } from '@storybook/angular';
import { mockModel } from 'src/storybook/model';
import { mockProject } from 'src/storybook/project';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,9 @@ export class ModelDiagramDialogComponent implements OnInit {
}
}

export interface Diagrams {
[uuid: string]: Diagram;
}
export type Diagrams = Record<string, Diagram>;

type Diagram = {
interface Diagram {
loading: boolean;
content?: string | ArrayBuffer | null;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class ModelDiagramPreviewDialogComponent implements AfterViewInit {
}
}

export type MatDialogPreviewData = {
export interface MatDialogPreviewData {
diagram: DiagramMetadata;
content: string | ArrayBuffer;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export function areRestrictionsEqual(
return a.allow_pure_variants === b.allow_pure_variants;
}

export type ModelRestrictions = {
export interface ModelRestrictions {
allow_pure_variants: boolean;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class ManageGitModelComponent implements OnInit, OnDestroy {
@Input() asStepper?: boolean;
@Output() create = new EventEmitter<boolean>();

public availableGitInstances?: Array<GitInstance>;
public availableGitInstances?: GitInstance[];
public selectedGitInstance?: GitInstance;

private revisions?: Revisions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,20 @@ export class T4CModelService {
}
}

export type SubmitT4CModel = {
export interface SubmitT4CModel {
t4c_instance_id: number;
t4c_repository_id: number;
name: string;
};
}

export type T4CModel = {
export interface T4CModel {
name: string;
id: number;
repository: T4CRepository;
};
}

export type SimpleT4CModel = {
export interface SimpleT4CModel {
project_name: string;
repository_name: string;
instance_name: string;
};
}
2 changes: 1 addition & 1 deletion frontend/src/app/projects/models/service/model.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class ModelWrapperService {
}

asyncSlugValidator(ignoreModel?: ToolModel): AsyncValidatorFn {
const ignoreSlug = !!ignoreModel ? ignoreModel.slug : -1;
const ignoreSlug = ignoreModel ? ignoreModel.slug : -1;
return (control: AbstractControl): Observable<ValidationErrors | null> => {
const modelSlug = slugify(control.value, { lower: true });
return this.models$.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class GitModelService {
loadGitModels(project_slug: string, model_slug: string): void {
this.http
.get<
Array<GetGitModel>
GetGitModel[]
>(this.BACKEND_URL_PREFIX + `/projects/${project_slug}/models/${model_slug}/modelsources/git`)
.subscribe((gitModels) => this._gitModels.next(gitModels));
}
Expand Down Expand Up @@ -112,12 +112,12 @@ export class GitModelService {
}
}

export type BaseGitModel = {
export interface BaseGitModel {
path: string;
revision: string;
entrypoint: string;
username: string;
};
}

export type CreateGitModel = BaseGitModel & {
password?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ export class ProjectUserService {
}
}

export type ProjectUser = {
export interface ProjectUser {
project_name: string;
permission: ProjectUserPermission;
role: ProjectUserRole;
user: User;
};
}

export type ProjectUserPermission = 'read' | 'write';
export type ProjectUserRole = 'user' | 'manager' | 'administrator';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/projects/service/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class ProjectWrapperService {
}

asyncSlugValidator(ignoreProject?: Project): AsyncValidatorFn {
const ignoreSlug = !!ignoreProject ? ignoreProject.slug : -1;
const ignoreSlug = ignoreProject ? ignoreProject.slug : -1;
return (control: AbstractControl): Observable<ValidationErrors | null> => {
const projectSlug = slugify(control.value, { lower: true });
return this.projects$.pipe(
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/services/load-files/load-files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export class LoadFilesService {
}
}

export type UploadResponse = {
export interface UploadResponse {
message: string;
};
}
8 changes: 2 additions & 6 deletions frontend/src/app/sessions/service/session.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ import {
import { SessionHistoryService } from 'src/app/sessions/user-sessions-wrapper/create-sessions/create-session-history/session-history.service';
import { environment } from 'src/environments/environment';

export interface LocalStorage {
[id: string]: string;
}
export type LocalStorage = Record<string, string>;

export interface Cookies {
[id: string]: string;
}
export type Cookies = Record<string, string>;

export interface ReadonlySession extends Session {
project: Project;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/sessions/session/session.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { TilingWindowManagerComponent } from './tiling-window-manager/tiling-win
export class SessionComponent implements OnInit, OnDestroy {
cachedSessions?: CachedSession[] = undefined;

selectedWindowType: string = 'floating';
selectedWindowType = 'floating';

constructor(
public userSessionService: UserSessionService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,14 @@ export class TilingWindowManagerComponent implements OnInit {
}
}

type ResizeState = {
interface ResizeState {
index?: number;
startX?: number;
leftSession?: TilingSession;
rightSession?: TilingSession;
startWidthLeft?: number;
startWidthRight?: number;
};
}

type ValidResizeState = Required<ResizeState>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ import { FileExistsDialogComponent } from './file-exists-dialog/file-exists-dial
],
})
export class FileBrowserDialogComponent implements OnInit {
files: Array<[File, string]> = [];
files: [File, string][] = [];
uploadProgress: number | null = null;
loadingFiles = false;

treeControl = new NestedTreeControl<PathNode>((node) => node.children);
treeControl = new NestedTreeControl<PathNode>((node) => node.children); // eslint-disable-line @typescript-eslint/no-deprecated
dataSource = new BehaviorSubject<PathNode[]>([]);

constructor(
Expand Down Expand Up @@ -111,8 +111,7 @@ export class FileBrowserDialogComponent implements OnInit {
if (!this.files.includes([file, path]) && response) {
this.files.push([file, path]);
if (parentNode.children) {
for (let i = 0; i < parentNode.children.length; i++) {
const child = parentNode.children[i];
for (const child of parentNode.children) {
if (child.name === name) {
child.isNew = true;
break;
Expand Down Expand Up @@ -144,8 +143,7 @@ export class FileBrowserDialogComponent implements OnInit {
this.treeControl.expand(parentNode);
return true;
} else if (parentNode.children) {
for (let i = 0; i < parentNode.children.length; i++) {
const child = parentNode.children[i];
for (const child of parentNode.children) {
result = this.addFileToTree(child, path, name);
if (result) {
this.treeControl.expand(parentNode);
Expand All @@ -158,8 +156,8 @@ export class FileBrowserDialogComponent implements OnInit {

checkIfFileExists(parentNode: PathNode, fileName: string): boolean {
if (parentNode.children) {
for (let i = 0; i < parentNode.children.length; i++) {
if (fileName == parentNode.children[i].name) return true;
for (const child of parentNode.children) {
if (fileName == child.name) return true;
}
}
return false;
Expand All @@ -175,8 +173,8 @@ export class FileBrowserDialogComponent implements OnInit {
this.treeControl.expand(parentNode);
result = true;
} else if (parentNode.children) {
for (let i = 0; i < parentNode.children?.length; i++) {
result = this._expandToNode(parentNode.children[i], node);
for (const child of parentNode.children) {
result = this._expandToNode(child, node);
if (result) {
this.treeControl.expand(parentNode);
}
Expand Down Expand Up @@ -227,10 +225,10 @@ export class FileBrowserDialogComponent implements OnInit {
removeFileFromSelection(path: string, filename: string): void {
let file;
let prefix = null;
for (let i = 0; i < this.files.length; i++) {
file = this.files[i][0];
prefix = this.files[i][1];
if (this.files[i][0].name === filename && this.files[i][1] === path) {
for (const fileIter of this.files) {
file = fileIter[0];
prefix = fileIter[1];
if (file.name === filename && prefix === path) {
break;
}
}
Expand Down Expand Up @@ -280,9 +278,7 @@ export class FileBrowserDialogComponent implements OnInit {
next: (response: Blob) => {
saveAs(
response,
`${filename
.replace(/^[\/\\: ]+/, '')
.replace(/[\/\\: ]+/g, '_')}.zip`,
`${filename.replace(/^[/\\: ]+/, '').replace(/[/\\: ]+/g, '_')}.zip`,
);
this.session.download_in_progress = false;
},
Expand Down
Loading

0 comments on commit 7416247

Please sign in to comment.