Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Nov 28, 2024
1 parent 1635083 commit 4ad5ade
Show file tree
Hide file tree
Showing 21 changed files with 7 additions and 67 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public/

# Generated during test run
/spec-lib
/hookshot-int-*

book
*.cer
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import chai from "eslint-plugin-chai-expect";

export default [
{
ignores: ["lib/**/*", "contrib/**/*"],
ignores: ["lib/**/*", "spec-lib/**/*", "contrib/**/*"],
},
...tseslint.config(
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion src/AdminRoom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import "reflect-metadata";
import { AdminAccountData, AdminRoomCommandHandler, Category } from "./AdminRoomCommandHandler";
import { botCommand, compileBotCommands, handleCommand, BotCommands, HelpFunction } from "./BotCommands";
Expand Down
1 change: 0 additions & 1 deletion src/AdminRoomCommandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export enum Category {


export interface AdminAccountData {

admin_user: string;
github?: {
notifications?: {
Expand Down
1 change: 0 additions & 1 deletion src/CommentProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/Connections/GithubIssue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export interface GitHubIssueConnectionState {
repo: string;
state: string;
issues: string[];

comments_processed: number;
}

Expand Down
1 change: 0 additions & 1 deletion src/Connections/GithubProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { ConfigGrantChecker, GrantChecker } from "../grants/GrantCheck";
import { BridgeConfig } from "../config/Config";

export interface GitHubProjectConnectionState {

project_id: number;
state: "open"|"closed";
}
Expand Down
1 change: 0 additions & 1 deletion src/Connections/GithubUserSpace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion src/Gitlab/Types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export interface GitLabAuthor {
id: number;
name: string;
Expand Down
2 changes: 0 additions & 2 deletions src/Gitlab/WebhookTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


export interface IGitLabWebhookEvent {
object_kind: string;
}
Expand Down
2 changes: 0 additions & 2 deletions src/MatrixEvent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export interface MatrixEvent<T extends MatrixEventContent|unknown> {
content: T;
event_id: string;
Expand All @@ -8,7 +7,6 @@ export interface MatrixEvent<T extends MatrixEventContent|unknown> {
type: string;
}


type MatrixEventContent = object;

export interface MatrixMemberContent extends MatrixEventContent {
Expand Down
6 changes: 0 additions & 6 deletions src/NotificationsProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -21,27 +20,22 @@ 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;
}

type PROrIssue = IssuesGetResponseData|PullGetResponseData;

export class NotificationProcessor {


private static formatUser(user: {login: string, html_url: string}) {
return `**[${user.login}](${user.html_url})**`;
}
Expand Down
17 changes: 0 additions & 17 deletions src/config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ interface BridgeConfigGitHubYAML {
secret: string;
};
oauth?: {

client_id: string;

client_secret: string;

redirect_uri: string;
};
defaultOptions?: GitHubRepoConnectionOptions;
Expand All @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
});
Expand Down
5 changes: 1 addition & 4 deletions src/config/Defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 0 additions & 2 deletions src/generic/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ export interface GenericWebhookEvent {
hookId: string;
}


export type GenericWebhookEventResult = GenericWebhookEventResultSuccess | GenericWebhookEventResultFailure;


export interface GenericWebhookEventResultSuccess {
successful: true|null;
response?: WebhookResponse,
Expand Down
1 change: 0 additions & 1 deletion src/github/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"|
Expand Down
1 change: 0 additions & 1 deletion tests/connections/FeedTest.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { AppserviceMock } from "../utils/AppserviceMock";
import { FeedConnection, FeedConnectionState } from "../../src/Connections";
import { FeedEntry } from "../../src/feeds/FeedReader";
Expand Down
1 change: 0 additions & 1 deletion tests/connections/GenericHookTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { assert, expect } from "chai";
import { Appservice, Intent, MatrixError } from "matrix-bot-sdk";
import { BridgeConfigGenericWebhooks, BridgeGenericWebhooksConfigYAML } from "../../src/config/sections";
Expand Down
1 change: 0 additions & 1 deletion tests/connections/GithubRepoTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ function createConnection(state: Record<string, unknown> = {}, isExistingState=f
"state_key",
githubInstance,
// Default config always contains GitHub

DefaultConfig.github!
);
return {connection, intent: intent as IntentMock};
Expand Down
24 changes: 3 additions & 21 deletions tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -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/**/*"
Expand Down

0 comments on commit 4ad5ade

Please sign in to comment.