From 4ad5adea4c03f4eebad7677a073f0b9dc362ca89 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 28 Nov 2024 14:23:28 +0000 Subject: [PATCH] lint --- .gitignore | 1 + eslint.config.mjs | 2 +- package.json | 2 +- src/AdminRoom.ts | 1 - src/AdminRoomCommandHandler.ts | 1 - src/CommentProcessor.ts | 1 - src/Connections/GithubIssue.ts | 1 - src/Connections/GithubProject.ts | 1 - src/Connections/GithubUserSpace.ts | 1 - src/Gitlab/Types.ts | 1 - src/Gitlab/WebhookTypes.ts | 2 -- src/MatrixEvent.ts | 2 -- src/NotificationsProcessor.ts | 6 ------ src/config/Config.ts | 17 ----------------- src/config/Defaults.ts | 5 +---- src/generic/types.ts | 2 -- src/github/Types.ts | 1 - tests/connections/FeedTest.spec.ts | 1 - tests/connections/GenericHookTest.ts | 1 - tests/connections/GithubRepoTest.ts | 1 - tsconfig.spec.json | 24 +++--------------------- 21 files changed, 7 insertions(+), 67 deletions(-) diff --git a/.gitignore b/.gitignore index 320941111..0db7bb407 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ public/ # Generated during test run /spec-lib +/hookshot-int-* book *.cer diff --git a/eslint.config.mjs b/eslint.config.mjs index 98f3c959e..c5d20da64 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -6,7 +6,7 @@ import chai from "eslint-plugin-chai-expect"; export default [ { - ignores: ["lib/**/*", "contrib/**/*"], + ignores: ["lib/**/*", "spec-lib/**/*", "contrib/**/*"], }, ...tseslint.config( { diff --git a/package.json b/package.json index 6791bfec0..539cf4ba2 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "start:matrixsender": "node --require source-map-support/register lib/App/MatrixSenderApp.js", "start:resetcrypto": "node --require source-map-support/register lib/App/ResetCryptoStore.js", "test": "mocha -r ts-node/register tests/init.ts 'tests/*.ts' 'tests/**/*.ts'", - "test:e2e": "tsc --p tsconfig.spec.json && yarn node --experimental-vm-modules $(yarn bin jest)", + "test:e2e": "tsc --p tsconfig.spec.json && cp ./lib/libRs.js ./lib/matrix-hookshot-rs.node ./spec-lib/src && yarn node --experimental-vm-modules $(yarn bin jest)", "test:cover": "nyc --reporter=lcov --reporter=text yarn test", "lint": "yarn run lint:js && yarn run lint:rs", "lint:js": "eslint", diff --git a/src/AdminRoom.ts b/src/AdminRoom.ts index 2739b2da2..9c9b85553 100644 --- a/src/AdminRoom.ts +++ b/src/AdminRoom.ts @@ -1,4 +1,3 @@ - import "reflect-metadata"; import { AdminAccountData, AdminRoomCommandHandler, Category } from "./AdminRoomCommandHandler"; import { botCommand, compileBotCommands, handleCommand, BotCommands, HelpFunction } from "./BotCommands"; diff --git a/src/AdminRoomCommandHandler.ts b/src/AdminRoomCommandHandler.ts index 52e1992a4..e11a081f1 100644 --- a/src/AdminRoomCommandHandler.ts +++ b/src/AdminRoomCommandHandler.ts @@ -13,7 +13,6 @@ export enum Category { export interface AdminAccountData { - admin_user: string; github?: { notifications?: { diff --git a/src/CommentProcessor.ts b/src/CommentProcessor.ts index 0f50e8c60..b2d0fb6e8 100644 --- a/src/CommentProcessor.ts +++ b/src/CommentProcessor.ts @@ -16,7 +16,6 @@ const log = new Logger("CommentProcessor"); const mime = import('mime'); interface IMatrixCommentEvent extends MatrixMessageContent { - external_url: string; "uk.half-shot.matrix-hookshot.github.comment": { id: number; diff --git a/src/Connections/GithubIssue.ts b/src/Connections/GithubIssue.ts index 7c94022d3..f5656e49a 100644 --- a/src/Connections/GithubIssue.ts +++ b/src/Connections/GithubIssue.ts @@ -20,7 +20,6 @@ export interface GitHubIssueConnectionState { repo: string; state: string; issues: string[]; - comments_processed: number; } diff --git a/src/Connections/GithubProject.ts b/src/Connections/GithubProject.ts index dbe5bac6e..6d21db51b 100644 --- a/src/Connections/GithubProject.ts +++ b/src/Connections/GithubProject.ts @@ -7,7 +7,6 @@ import { ConfigGrantChecker, GrantChecker } from "../grants/GrantCheck"; import { BridgeConfig } from "../config/Config"; export interface GitHubProjectConnectionState { - project_id: number; state: "open"|"closed"; } diff --git a/src/Connections/GithubUserSpace.ts b/src/Connections/GithubUserSpace.ts index c834825e3..456acdc7d 100644 --- a/src/Connections/GithubUserSpace.ts +++ b/src/Connections/GithubUserSpace.ts @@ -76,7 +76,6 @@ export class GitHubUserSpace extends BaseConnection implements IConnection { throw Error("Could not find repo"); } - let avatarState: {type: "m.room.avatar", state_key: "", content: { url: string}}|undefined; try { if (avatarUrl) { diff --git a/src/Gitlab/Types.ts b/src/Gitlab/Types.ts index 5e81b8ebc..956b8a823 100644 --- a/src/Gitlab/Types.ts +++ b/src/Gitlab/Types.ts @@ -1,4 +1,3 @@ - export interface GitLabAuthor { id: number; name: string; diff --git a/src/Gitlab/WebhookTypes.ts b/src/Gitlab/WebhookTypes.ts index cf36428b3..c331df03d 100644 --- a/src/Gitlab/WebhookTypes.ts +++ b/src/Gitlab/WebhookTypes.ts @@ -1,5 +1,3 @@ - - export interface IGitLabWebhookEvent { object_kind: string; } diff --git a/src/MatrixEvent.ts b/src/MatrixEvent.ts index 1feb6b5d3..67bb5e90b 100644 --- a/src/MatrixEvent.ts +++ b/src/MatrixEvent.ts @@ -1,4 +1,3 @@ - export interface MatrixEvent { content: T; event_id: string; @@ -8,7 +7,6 @@ export interface MatrixEvent { type: string; } - type MatrixEventContent = object; export interface MatrixMemberContent extends MatrixEventContent { diff --git a/src/NotificationsProcessor.ts b/src/NotificationsProcessor.ts index 955296dc8..640e85cb8 100644 --- a/src/NotificationsProcessor.ts +++ b/src/NotificationsProcessor.ts @@ -10,7 +10,6 @@ import { GitHubUserNotification } from "./github/Types"; import { components } from "@octokit/openapi-types/types"; import { NotifFilter } from "./NotificationFilters"; - const log = new Logger("NotificationProcessor"); const md = new markdown(); @@ -21,18 +20,15 @@ export interface IssueDiff { merged: boolean; mergedBy: null|{ login: string; - html_url: string; }; user: { login: string; - html_url: string; }; } export interface CachedReviewData { - requested_reviewers: PullsListRequestedReviewersResponseData; reviews: PullsListReviewsResponseData; } @@ -40,8 +36,6 @@ export interface CachedReviewData { type PROrIssue = IssuesGetResponseData|PullGetResponseData; export class NotificationProcessor { - - private static formatUser(user: {login: string, html_url: string}) { return `**[${user.login}](${user.html_url})**`; } diff --git a/src/config/Config.ts b/src/config/Config.ts index 3aece92b1..c2aa5abdc 100644 --- a/src/config/Config.ts +++ b/src/config/Config.ts @@ -51,11 +51,8 @@ interface BridgeConfigGitHubYAML { secret: string; }; oauth?: { - client_id: string; - client_secret: string; - redirect_uri: string; }; defaultOptions?: GitHubRepoConnectionOptions; @@ -74,11 +71,8 @@ export class BridgeConfigGitHub { }; @configKey("Settings for allowing users to sign in via OAuth.", true) readonly oauth?: { - client_id: string; - client_secret: string; - redirect_uri: string; }; @configKey("Default options for GitHub connections.", true) @@ -111,18 +105,14 @@ export class BridgeConfigGitHub { } export interface BridgeConfigJiraCloudOAuth { - client_id: string; - client_secret: string; - redirect_uri: string; } export interface BridgeConfigJiraOnPremOAuth { consumerKey: string; privateKey: string; - redirect_uri: string; } @@ -186,11 +176,6 @@ export class BridgeConfigJira implements BridgeConfigJiraYAML { export interface GitLabInstance { url: string; - // oauth: { - // client_id: string; - // client_secret: string; - // redirect_uri: string; - // }; } export interface BridgeConfigGitLabYAML { @@ -746,11 +731,9 @@ export async function parseRegistrationFile(filename: string) { if (require.main === module) { Logger.configure({console: "info"}); BridgeConfig.parseConfig(process.argv[2] || "config.yml", process.env).then(() => { - console.log('Config successfully validated.'); process.exit(0); }).catch(ex => { - console.error('Error in config:', ex); process.exit(1); }); diff --git a/src/config/Defaults.ts b/src/config/Defaults.ts index 2e1ea29c4..fa511f953 100644 --- a/src/config/Defaults.ts +++ b/src/config/Defaults.ts @@ -248,19 +248,16 @@ async function renderRegistrationFile(configPath?: string) { rooms: [], }, }; - + console.log(YAML.stringify(obj)); } - // Can be called directly if (require.main === module) { if (process.argv[2] === '--config') { - console.log(renderDefaultConfig()); } else if (process.argv[2] === '--registration') { renderRegistrationFile(process.argv[3]).catch(ex => { - console.error(ex); process.exit(1); }); diff --git a/src/generic/types.ts b/src/generic/types.ts index 611c490fe..4011936de 100644 --- a/src/generic/types.ts +++ b/src/generic/types.ts @@ -5,10 +5,8 @@ export interface GenericWebhookEvent { hookId: string; } - export type GenericWebhookEventResult = GenericWebhookEventResultSuccess | GenericWebhookEventResultFailure; - export interface GenericWebhookEventResultSuccess { successful: true|null; response?: WebhookResponse, diff --git a/src/github/Types.ts b/src/github/Types.ts index 99d198606..f51dc2843 100644 --- a/src/github/Types.ts +++ b/src/github/Types.ts @@ -19,7 +19,6 @@ export type CreateInstallationAccessTokenDataType = Endpoints["POST /app/install export const NAMELESS_ORG_PLACEHOLDER = "No name"; - export interface GitHubUserNotification { id: string; reason: "assign"|"author"|"comment"|"invitation"|"manual"|"mention"|"review_requested"| diff --git a/tests/connections/FeedTest.spec.ts b/tests/connections/FeedTest.spec.ts index aa66b0a39..7359349ea 100644 --- a/tests/connections/FeedTest.spec.ts +++ b/tests/connections/FeedTest.spec.ts @@ -1,4 +1,3 @@ - import { AppserviceMock } from "../utils/AppserviceMock"; import { FeedConnection, FeedConnectionState } from "../../src/Connections"; import { FeedEntry } from "../../src/feeds/FeedReader"; diff --git a/tests/connections/GenericHookTest.ts b/tests/connections/GenericHookTest.ts index b6e91c5bc..975d250d8 100644 --- a/tests/connections/GenericHookTest.ts +++ b/tests/connections/GenericHookTest.ts @@ -1,4 +1,3 @@ - import { assert, expect } from "chai"; import { Appservice, Intent, MatrixError } from "matrix-bot-sdk"; import { BridgeConfigGenericWebhooks, BridgeGenericWebhooksConfigYAML } from "../../src/config/sections"; diff --git a/tests/connections/GithubRepoTest.ts b/tests/connections/GithubRepoTest.ts index 19b34cab5..8c8a0e0dd 100644 --- a/tests/connections/GithubRepoTest.ts +++ b/tests/connections/GithubRepoTest.ts @@ -55,7 +55,6 @@ function createConnection(state: Record = {}, isExistingState=f "state_key", githubInstance, // Default config always contains GitHub - DefaultConfig.github! ); return {connection, intent: intent as IntentMock}; diff --git a/tsconfig.spec.json b/tsconfig.spec.json index af7e393ac..fb6a30d7f 100644 --- a/tsconfig.spec.json +++ b/tsconfig.spec.json @@ -1,29 +1,11 @@ { - "extends": "@tsconfig/node22/tsconfig.json", + "extends": "./tsconfig.json", "compilerOptions": { - "incremental": true, + "incremental": false, "declaration": false, "outDir": "./spec-lib", "rootDir": "./", - "noImplicitAny": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "strictBindCallApply": true, - "strictPropertyInitialization": true, - "noImplicitThis": true, - "alwaysStrict": true, - /* Additional Checks */ - "noUnusedLocals": false, - "noUnusedParameters": false, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "inlineSourceMap": true, - "inlineSources": true, - "allowJs": true, - "experimentalDecorators": true, - "emitDecoratorMetadata": true, - // TODO: Type errors - "useUnknownInCatchVariables": false + "allowJs": true }, "include": [ "spec/**/*"