Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
fix: import paths in files
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Nov 25, 2023
1 parent 9151881 commit c427d09
Show file tree
Hide file tree
Showing 68 changed files with 168 additions and 104 deletions.
18 changes: 17 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,23 @@
{ "selector": "interface", "format": ["PascalCase"], "custom": { "regex": "^I[A-Z]", "match": false } },
{ "selector": ["function", "variable"], "format": ["camelCase"] },
{ "selector": "variable", "modifiers": ["destructured"], "format": null },
{ "selector": "variable", "format": ["camelCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }
{ "selector": "variable", "format": ["camelCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" },

{
"selector": "parameter",
"format": ["camelCase"],
"leadingUnderscore": "allow", // This allows the use of a leading underscore
"trailingUnderscore": "allow" // This allows the use of a trailing underscore
},
{
"selector": "parameter",
"format": null,
"filter": {
// This allows parameters to be named as just an underscore
"regex": "^_$",
"match": true
}
}
]
}
}
3 changes: 2 additions & 1 deletion src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { Settlement } from "./supabase/helpers/tables/settlement";
import { Super } from "./supabase/helpers/tables/super";
import { User } from "./supabase/helpers/tables/user";
import { Wallet } from "./supabase/helpers/tables/wallet";
import { Database } from "./supabase/types";

import { env } from "../bindings/env";
import { Database } from "./supabase/types/database";

export const supabaseClient = createClient<Database>(env.SUPABASE_URL, env.SUPABASE_KEY, {
auth: { persistSession: false },
Expand Down
5 changes: 3 additions & 2 deletions src/adapters/supabase/helpers/tables/label.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { Repository } from "../../../../types/payload";
import { Database } from "../../types";
import { Super } from "./super";

import Runtime from "../../../../bindings/bot-runtime";
import { Super } from "./super";
import { Database } from "../../types/database";

type LabelRow = Database["public"]["Tables"]["labels"]["Row"];

Expand Down
3 changes: 2 additions & 1 deletion src/adapters/supabase/helpers/tables/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { SupabaseClient } from "@supabase/supabase-js";
import { execSync } from "child_process";
import { Context as ProbotContext } from "probot";
import Runtime from "../../../../bindings/bot-runtime";
import { Database } from "../../types";
import { Database } from "../../types/database";

import { LogLevel, PrettyLogs } from "../pretty-logs";

type LogFunction = (message: string, metadata?: any) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/supabase/helpers/tables/wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import dotenv from "dotenv";
dotenv.config();

import { createAdapters } from "../../..";
import { User } from "../../../../types";
import { User } from "../../../../types/payload";
const SUPABASE_URL = process.env.SUPABASE_URL;
if (!SUPABASE_URL) throw new Error("SUPABASE_URL is not defined");
const SUPABASE_KEY = process.env.SUPABASE_KEY;
Expand Down
3 changes: 2 additions & 1 deletion src/adapters/supabase/helpers/tables/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { PostgrestError, SupabaseClient } from "@supabase/supabase-js";
import { Context as ProbotContext } from "probot";
import Runtime from "../../../../bindings/bot-runtime";
import { User } from "../../../../types";
import { User } from "../../../../types/payload";

import { Database } from "../../types/database";
import { Super } from "./super";
import { UserRow } from "./user";
Expand Down
3 changes: 2 additions & 1 deletion src/bindings/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { processors, wildcardProcessors } from "../handlers/processors";
import { validateConfigChange } from "../handlers/push";
import structuredMetadata from "../handlers/shared/structured-metadata";
import { addCommentToIssue, shouldSkip } from "../helpers";
import { BotConfig } from "../types";
import { BotConfig } from "../types/configuration-types";

import { Context } from "../types/context";
import {
HandlerReturnValuesNoVoid,
Expand Down
5 changes: 3 additions & 2 deletions src/handlers/access/labels-access.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Runtime from "../../bindings/bot-runtime";
import { addCommentToIssue, isUserAdminOrBillingManager, removeLabel, addLabelToIssue } from "../../helpers";
import { Context, UserType } from "../../types";
import { addCommentToIssue, addLabelToIssue, isUserAdminOrBillingManager, removeLabel } from "../../helpers";
import { Context } from "../../types/context";
import { UserType } from "../../types/payload";

export async function labelAccessPermissionsCheck(context: Context) {
const runtime = Runtime.getState();
Expand Down
4 changes: 3 additions & 1 deletion src/handlers/assign/action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { calculateDurations, calculateLabelValue, closePullRequest } from "../../helpers";
import { getLinkedPullRequests } from "../../helpers/parser";
import { Context, Label, Payload } from "../../types";
import { Context } from "../../types/context";
import { Label } from "../../types/label";
import { Payload } from "../../types/payload";

export async function startCommandHandler(context: Context) {
const config = context.config;
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/assign/auto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addAssignees, getAllPullRequests, getIssueByNumber, getPullByNumber } from "../../helpers";
import { getLinkedIssues } from "../../helpers/parser";
import { Context } from "../../types";
import { Context } from "../../types/context";

// Check for pull requests linked to their respective issues but not assigned to them
export async function checkPullRequests(context: Context) {
Expand Down
4 changes: 3 additions & 1 deletion src/handlers/comment/action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Comment, Payload, Context } from "../../types";
import { Context } from "../../types/context";
import { commentParser, userCommands } from "./handlers";
import { verifyFirstCommentInRepository } from "./handlers/first";
import { Payload } from "../../types/payload";
import { Comment } from "../../types/payload";

export async function commentCreatedOrEdited(context: Context) {
const config = context.config,
Expand Down
6 changes: 4 additions & 2 deletions src/handlers/comment/handlers/ask.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Context, Payload, StreamlinedComment, UserType } from "../../../types";
import { getAllIssueComments, getAllLinkedIssuesAndPullsInBody } from "../../../helpers";
import { CreateChatCompletionRequestMessage } from "openai/resources/chat";
import { getAllIssueComments, getAllLinkedIssuesAndPullsInBody } from "../../../helpers";
import { askGPT, decideContextGPT, sysMsg } from "../../../helpers/gpt";
import { Context } from "../../../types/context";
import { StreamlinedComment } from "../../../types/openai";
import { Payload, UserType } from "../../../types/payload";

export async function ask(context: Context, body: string) {
// The question to ask
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/comment/handlers/assign/check-task-stale.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Issue } from "../../../../types";
import { Issue } from "../../../../types/payload";

export function checkTaskStale(staleTask: number, issue: Issue) {
let days: number | undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Runtime from "../../../../bindings/bot-runtime";
import { Context, Payload } from "../../../../types";
import { Context } from "../../../../types/context";
import { Payload } from "../../../../types/payload";

const options: Intl.DateTimeFormatOptions = {
weekday: "short",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Issue, Context } from "../../../../types";
import { Context } from "../../../../types/context";
import { Issue } from "../../../../types/payload";
import { taskPaymentMetaData } from "../../../wildcard";
import { getUserMultiplier } from "./get-user-multiplier";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { BotConfig, Context, Label, Payload } from "../../../../types";
import { BotConfig } from "../../../../types/configuration-types";
import { Context } from "../../../../types/context";
import { Label } from "../../../../types/label";
import { Payload } from "../../../../types/payload";

export function getTimeLabelsAssigned(context: Context, payload: Payload, config: BotConfig) {
const logger = context.logger;
Expand Down
6 changes: 4 additions & 2 deletions src/handlers/comment/handlers/assign/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
getAssignedIssues,
getAvailableOpenedPullRequests,
} from "../../../../helpers";
import { Context, IssueType, Payload, User } from "../../../../types";
import { Context } from "../../../../types/context";
import { User, IssueType, Payload } from "../../../../types/payload";

import { isParentIssue } from "../../../pricing";
import structuredMetadata from "../../../shared/structured-metadata";
import { assignTableComment } from "../table";
Expand All @@ -24,7 +26,7 @@ export async function assign(context: Context, body: string) {
disabledCommands,
} = context.config;

const isStartDisabled = disabledCommands.some((command) => command === "start");
const isStartDisabled = disabledCommands.some((command: string) => command === "start");

logger.info("Received '/start' command", { sender: payload.sender.login, body });

Expand Down
4 changes: 3 additions & 1 deletion src/handlers/comment/handlers/authorize.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Runtime from "../../../bindings/bot-runtime";
import { isUserAdminOrBillingManager } from "../../../helpers";
import { Context, Payload } from "../../../types";
import { Context } from "../../../types/context";
import { Payload } from "../../../types/payload";

import { taskPaymentMetaData } from "../../wildcard";

export async function authorizeLabelChanges(context: Context) {
Expand Down
3 changes: 2 additions & 1 deletion src/handlers/comment/handlers/first.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Context, Payload } from "../../../types";
import { Context } from "../../../types/context";
import { Payload } from "../../../types/payload";
import { generateHelpMenu } from "./help";

export async function verifyFirstCommentInRepository(context: Context) {
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/comment/handlers/help.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { userCommands } from ".";
import { Context } from "../../../types";
import { Context } from "../../../types/context";

export async function listAvailableCommands(context: Context, body: string) {
const logger = context.logger;
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/comment/handlers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { UserCommands } from "../../../types";
import { assign } from "./assign";
import { listAvailableCommands } from "./help";
// Commented out until Gnosis Safe is integrated (https://github.com/ubiquity/ubiquibot/issues/353)
Expand All @@ -13,6 +12,7 @@ import { registerWallet } from "./wallet";

import { autoPay } from "./payout";
import { query } from "./query";
import { UserCommands } from "../../../types/handlers";

export * from "./ask";
export * from "./assign";
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/comment/handlers/issue/assignee-scoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Decimal from "decimal.js";
import { Issue, User } from "../../../../types/payload";
import { ContributorView } from "./contribution-style-types";
import { UserScoreDetails } from "./issue-shared-types";
import { Context } from "../../../../types";
import { Context } from "../../../../types/context";

export async function assigneeScoring(
context: Context,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import OpenAI from "openai";
import { Context } from "../../../../types";
import { Context } from "../../../../types/context";
import { Comment, Issue, User, UserType } from "../../../../types/payload";
import { countTokensOfConversation, estimateOptimalModel, gptRelevance, relevanceScoring } from "./relevance-scoring";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import MarkdownIt from "markdown-it";
import { Comment } from "../../../../types/payload";
import { ContributorClassesKeys } from "./contribution-style-types";
import { FormatScoreConfig, FormatScoreConfigParams } from "./element-score-config";
import { Context } from "../../../../types";
import { Context } from "../../../../types/context";

export type Tags = keyof HTMLElementTagNameMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { MaxUint256, PERMIT2_ADDRESS, PermitTransferFrom, SignatureTransfer } fr
import Decimal from "decimal.js";
import { BigNumber, ethers } from "ethers";
import { keccak256, toUtf8Bytes } from "ethers/lib/utils";
import { Context } from "../../../../types";

import { getPayoutConfigByNetworkId } from "../../../../helpers";
import { decryptKeys } from "../../../../utils/private";
import { Context } from "../../../../types/context";

export async function generatePermit2Signature(
context: Context,
Expand Down
4 changes: 3 additions & 1 deletion src/handlers/comment/handlers/issue/generate-permits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { stringify } from "yaml";
import Runtime from "../../../../bindings/bot-runtime";
import { getPayoutConfigByNetworkId } from "../../../../helpers";
import { getTokenSymbol } from "../../../../helpers/contracts";
import { Context, Issue, Payload } from "../../../../types";
import { Context } from "../../../../types/context";
import { Issue, Payload } from "../../../../types/payload";

import structuredMetadata from "../../../shared/structured-metadata";
import { generatePermit2Signature } from "./generate-permit-2-signature";
import { UserScoreTotals } from "./issue-shared-types";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Context, Payload, User } from "../../../../types";
import { Context } from "../../../../types/context";
import { Payload, User } from "../../../../types/payload";

export async function getCollaboratorsForRepo(context: Context): Promise<User[]> {
const payload = context.event.payload as Payload;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getAllIssueComments } from "../../../../helpers";

Check warning on line 1 in src/handlers/comment/handlers/issue/getPullRequestComments.ts

View workflow job for this annotation

GitHub Actions / check-filenames

This file is not in kebab-case or snake_case
import { getLinkedPullRequests } from "../../../../helpers/parser";
import { Context } from "../../../../types";
import { Context } from "../../../../types/context";

import { Comment } from "../../../../types/payload";

export async function getPullRequestComments(context: Context, owner: string, repository: string, issueNumber: number) {
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/comment/handlers/issue/identify-user-ids.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context } from "../../../../types";
import { Context } from "../../../../types/context";
import { Comment, Issue, User } from "../../../../types/payload";
import { ContributorClasses } from "./contribution-style-types";
import { getCollaboratorsForRepo } from "./get-collaborator-ids-for-repo";
Expand Down
3 changes: 2 additions & 1 deletion src/handlers/comment/handlers/issue/issue-closed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Runtime from "../../../../bindings/bot-runtime";
import { checkUserPermissionForRepoAndOrg, getAllIssueComments } from "../../../../helpers";
import { Context } from "../../../../types";
import { Context } from "../../../../types/context";

import { Comment, Issue, Payload, StateReason } from "../../../../types/payload";
import structuredMetadata from "../../../shared/structured-metadata";
import { generatePermits } from "./generate-permits";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context } from "../../../../types";
import { Context } from "../../../../types/context";

Check warning on line 1 in src/handlers/comment/handlers/issue/perUserCommentScoring.ts

View workflow job for this annotation

GitHub Actions / check-filenames

This file is not in kebab-case or snake_case
import { Comment, User } from "../../../../types/payload";
import { CommentScoring } from "./comment-scoring-rubric";

Expand Down
5 changes: 3 additions & 2 deletions src/handlers/comment/handlers/issue/relevance-scoring.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Decimal from "decimal.js";
import { encodingForModel } from "js-tiktoken";
import OpenAI from "openai";
import { Context } from "../../../../types";
import { Context } from "../../../../types/context";

import { Comment, Issue } from "../../../../types/payload";

export async function relevanceScoring(context: Context, issue: Issue, contributorComments: Comment[]) {
Expand Down Expand Up @@ -145,7 +146,7 @@ function filterSamples(context: Context, batchResults: number[][], correctLength

function averageSamples(batchResults: (number | Decimal)[][], precision: number) {
const averageScores = batchResults[0]
.map((x, columnIndex) => {
.map((_, columnIndex) => {
let sum = new Decimal(0);
batchResults.forEach((row) => {
sum = sum.plus(row[columnIndex]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Decimal from "decimal.js";

import { Context } from "../../../../types";
import { Comment, Issue } from "../../../../types/payload";
import { allCommentScoring } from "./allCommentScoring";
import { UserScoreDetails } from "./issue-shared-types";
import { addRelevanceAndFormatScoring } from "./relevance-format-scoring";

// import Runtime from "../../../../bindings/bot-runtime";
import { ContributorView } from "./contribution-style-types";
import { Context } from "../../../../types/context";

export type ContextIssue = { context: Context; issue: Issue };

Expand Down
3 changes: 2 additions & 1 deletion src/handlers/comment/handlers/labels.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Runtime from "../../../bindings/bot-runtime";
import { isUserAdminOrBillingManager } from "../../../helpers";
import { Context, Payload } from "../../../types";
import { Context } from "../../../types/context";
import { Payload } from "../../../types/payload";

export async function setLabels(context: Context, body: string) {
const logger = context.logger;
Expand Down
4 changes: 3 additions & 1 deletion src/handlers/comment/handlers/multiplier.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Runtime from "../../../bindings/bot-runtime";
import { isUserAdminOrBillingManager } from "../../../helpers";
import { Context, Payload } from "../../../types";
import { Context } from "../../../types/context";
import { Payload } from "../../../types/payload";

/**
* You can use this command to set a multiplier for a user.
* It will accept arguments in any order.
Expand Down
3 changes: 2 additions & 1 deletion src/handlers/comment/handlers/payout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Context, Payload } from "../../../types";
import { isUserAdminOrBillingManager } from "../../../helpers/issue";
import { Context } from "../../../types/context";
import { Payload } from "../../../types/payload";

export async function autoPay(context: Context, body: string) {
const payload = context.event.payload as Payload;
Expand Down
4 changes: 3 additions & 1 deletion src/handlers/comment/handlers/query.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Runtime from "../../../bindings/bot-runtime";
import { Context, Payload } from "../../../types";

import _ from "lodash";
import { Context } from "../../../types/context";
import { Payload } from "../../../types/payload";

export async function query(context: Context, body: string) {
const runtime = Runtime.getState(),
Expand Down
3 changes: 2 additions & 1 deletion src/handlers/comment/handlers/unassign.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Context, Payload } from "../../../types";
import { closePullRequestForAnIssue } from "../../assign/index";
import { Payload } from "../../../types/payload";
import { Context } from "../../../types/context";

export async function unassign(context: Context, body: string) {
const logger = context.logger;
Expand Down
4 changes: 3 additions & 1 deletion src/handlers/comment/handlers/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { constants, ethers } from "ethers";
import Runtime from "../../../bindings/bot-runtime";
import { resolveAddress } from "../../../helpers";
import { Context, Payload } from "../../../types";
import { Context } from "../../../types/context";
import { Payload } from "../../../types/payload";

// Extracts ensname from raw text.
function extractEnsName(text: string) {
// Define a regular expression to match ENS names
Expand Down
Loading

0 comments on commit c427d09

Please sign in to comment.