Skip to content

Commit

Permalink
Merge pull request #10 from ubq-testing/fix/pr-closure
Browse files Browse the repository at this point in the history
fix: close only assignee PR
  • Loading branch information
Keyrxng authored Jul 29, 2024
2 parents ac9590a + ffaf073 commit b50f0a8
Show file tree
Hide file tree
Showing 25 changed files with 1,311 additions and 1,027 deletions.
17 changes: 16 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "./src/adapters/supabase/**/**.ts"],
"useGitignore": true,
"language": "en",
"words": ["dataurl", "devpool", "outdir", "servedir", "Supabase", "supabase", "SUPABASE", "typebox", "ubiquibot", "signoff", "sonarjs", "mswjs"],
"words": [
"knip",
"mischeck",
"dataurl",
"devpool",
"outdir",
"servedir",
"Supabase",
"supabase",
"SUPABASE",
"typebox",
"ubiquibot",
"signoff",
"sonarjs",
"mswjs"
],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
Expand Down
59 changes: 0 additions & 59 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/worker-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Enable corepack
run: corepack enable

- uses: actions/checkout@v4
- uses: cloudflare/wrangler-action@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ coverage
junit.xml
cypress/screenshots
script.ts
.wrangler
.wrangler
test-dashboard.md
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ To configure your Ubiquibot to run this plugin, add the following to the `.ubiqu
command: "\/start|\/stop"
example: "/start" # or "/stop"
with:
isEnabled: true
timers:
reviewDelayTolerance: 86000
taskStaleTimeoutDuration: 2580000
Expand Down
126 changes: 126 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// @ts-check
import tsEslint from "typescript-eslint";
import eslint from "@eslint/js";
import sonarjs from "eslint-plugin-sonarjs";
import checkFile from "eslint-plugin-check-file";

export default tsEslint.config({
plugins: {
"@typescript-eslint": tsEslint.plugin,
"check-file": checkFile,
},
ignores: [".github/knip.ts", ".github/cspell.ts", ".wrangler/**/*.ts", ".wrangler/**/*.js"],
extends: [eslint.configs.recommended, ...tsEslint.configs.recommended, sonarjs.configs.recommended],
languageOptions: {
parser: tsEslint.parser,
parserOptions: {
project: ["./tsconfig.json"],
},
},
rules: {
"check-file/filename-naming-convention": [
"error",
{
"**/*.{js,ts}": "+([-._a-z0-9])",
},
],
"prefer-arrow-callback": [
"warn",
{
allowNamedFunctions: true,
},
],
"func-style": [
"warn",
"declaration",
{
allowArrowFunctions: false,
},
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"constructor-super": "error",
"no-invalid-this": "off",
"@typescript-eslint/no-invalid-this": ["error"],
"no-restricted-syntax": ["error", "ForInStatement"],
"use-isnan": "error",
"no-unneeded-ternary": "error",
"no-nested-ternary": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "after-used",
ignoreRestSiblings: true,
vars: "all",
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"sonarjs/no-all-duplicated-branches": "error",
"sonarjs/no-collection-size-mischeck": "error",
"sonarjs/no-duplicated-branches": "error",
"sonarjs/no-element-overwrite": "error",
"sonarjs/no-identical-conditions": "error",
"sonarjs/no-identical-expressions": "error",
"@typescript-eslint/naming-convention": [
"error",
{
selector: "interface",
format: ["StrictPascalCase"],
custom: {
regex: "^I[A-Z]",
match: false,
},
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["strictCamelCase"],
leadingUnderscore: "require",
},
{
selector: "typeLike",
format: ["StrictPascalCase"],
},
{
selector: "typeParameter",
format: ["StrictPascalCase"],
prefix: ["T"],
},
{
selector: "variable",
format: ["strictCamelCase", "UPPER_CASE"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
{
selector: "variable",
format: ["strictCamelCase"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
{
selector: "variable",
modifiers: ["destructured"],
format: null,
},
{
selector: "variable",
types: ["boolean"],
format: ["StrictPascalCase"],
prefix: ["is", "should", "has", "can", "did", "will", "does"],
},
{
selector: "variableLike",
format: ["strictCamelCase"],
},
{
selector: ["function", "variable"],
format: ["strictCamelCase"],
},
],
},
});
2 changes: 1 addition & 1 deletion jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"coveragePathIgnorePatterns": ["node_modules", "mocks"],
"collectCoverage": true,
"coverageReporters": ["json", "lcov", "text", "clover", "json-summary"],
"reporters": ["default", "jest-junit"],
"reporters": ["default", "jest-junit", "jest-md-dashboard"],
"coverageDirectory": "coverage"
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Start | Stop",
"description": "Assign or un-assign yourself from an issue.",
"ubiquity:listeners": [ "issue_comment.created" ],
"ubiquity:listeners": ["issue_comment.created"],
"commands": {
"start": {
"ubiquity:example": "/start",
Expand Down
51 changes: 26 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"open-source"
],
"dependencies": {
"@octokit/rest": "^20.0.2",
"@octokit/webhooks": "^13.1.0",
"@octokit/rest": "20.1.1",
"@octokit/webhooks": "13.2.7",
"@sinclair/typebox": "^0.32.5",
"@supabase/supabase-js": "2.42.0",
"@ubiquity-dao/ubiquibot-logger": "^1.3.0",
Expand All @@ -39,35 +39,36 @@
"typebox-validators": "^0.3.5"
},
"devDependencies": {
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.2",
"@cspell/dict-node": "^4.0.3",
"@cspell/dict-software-terms": "^3.3.18",
"@cspell/dict-typescript": "^3.1.2",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@cspell/dict-node": "5.0.1",
"@cspell/dict-software-terms": "3.4.6",
"@cspell/dict-typescript": "3.1.5",
"@eslint/js": "9.5.0",
"@jest/globals": "29.7.0",
"@mswjs/data": "0.16.1",
"@types/jest": "29.5.12",
"@types/ms": "^0.7.34",
"@types/node": "^20.11.19",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"cspell": "^8.4.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-filename-rules": "^1.3.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-sonarjs": "^0.24.0",
"husky": "^9.0.11",
"@types/node": "20.14.5",
"cspell": "8.9.0",
"eslint": "9.5.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-check-file": "2.8.0",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-sonarjs": "1.0.3",
"husky": "9.0.11",
"jest": "29.7.0",
"jest-junit": "16.0.0",
"knip": "^5.0.1",
"lint-staged": "^15.2.2",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"ts-jest": "29.1.2",
"tsx": "^4.7.1",
"typescript": "^5.5.2",
"wrangler": "3.57.0"
"jest-md-dashboard": "0.8.0",
"knip": "5.21.2",
"lint-staged": "15.2.7",
"npm-run-all": "4.1.5",
"prettier": "3.3.2",
"ts-jest": "29.1.5",
"tsx": "4.15.6",
"typescript": "5.4.5",
"typescript-eslint": "7.13.1",
"wrangler": "3.60.3"
},
"lint-staged": {
"*.ts": [
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/supabase/helpers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ export class User extends Super {
}

async getWalletByUserId(userId: number, issueNumber: number) {
const { data, error } = await this.supabase.from("users").select("wallets(*)").eq("id", userId).single() as { data: { wallets: Wallet }, error: unknown };
const { data, error } = (await this.supabase.from("users").select("wallets(*)").eq("id", userId).single()) as { data: { wallets: Wallet }; error: unknown };
if ((error && !data) || !data.wallets?.address) {
this.context.logger.error("No wallet address found", { userId, issueNumber });
if (this.context.config.miscellaneous.startRequiresWallet) {
await addCommentToIssue(this.context, "```diff\n! Please set your wallet address with the /wallet command first and try again.\n```");
throw new Error("No wallet address found");
} else {
await addCommentToIssue(this.context, "```diff\n# Please set your wallet address with the /wallet command in order to receive a task reward.\n```");
await addCommentToIssue(this.context, "```diff\n# Please set your wallet address with the /wallet command in order to be eligible for rewards.\n```");
}
} else {
this.context.logger.info("Successfully fetched wallet", { userId, address: data.wallets?.address });
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/shared/check-task-stale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ export function checkTaskStale(staleTask: number, createdAt: string) {
if (staleTask !== 0) {
const days = Math.floor((new Date().getTime() - new Date(createdAt).getTime()) / (1000 * 60 * 60 * 24));
const staleToDays = Math.floor(staleTask / (1000 * 60 * 60 * 24));
return days >= staleToDays;
return days >= staleToDays && staleToDays > 0;
}

return false;
}
}
Loading

0 comments on commit b50f0a8

Please sign in to comment.