Skip to content

Commit

Permalink
fix linting style
Browse files Browse the repository at this point in the history
  • Loading branch information
huan committed Nov 1, 2021
1 parent b7d4fb5 commit 0f86df2
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 38 deletions.
7 changes: 6 additions & 1 deletion bin/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {

// https://probot.github.io/docs/development/#run-probot-programmatically
import { run } from 'probot'
import { wrapAsyncError } from 'gerror'

// import { Command } from 'commander'

Expand Down Expand Up @@ -74,7 +75,11 @@ async function main () {
// }

try {
await run(probotApp)
await run(
wrapAsyncError(console.error)(
probotApp,
),
)
} catch (e) {
console.error(e)
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"ducks": "^0.11.10",
"express": "^4.17.1",
"finis": "^0.4.5",
"gerror": "^1.0.2",
"ha-wechaty": "^0.9.12",
"micromatch": "^4.0.4",
"moment": "^2.29.1",
Expand All @@ -51,10 +52,10 @@
"rx-queue": "^0.12.6",
"smee-client": "^1.2.2",
"wechaty": "^0.68.1",
"wechaty-chatopera": "^0.4.2",
"wechaty-ducks-contrib": "^0.3.6",
"wechaty-plugin-contrib": "^0.14.23",
"wechaty-puppet-padlocal": "^0.4.2",
"wechaty-chatopera": "^0.4.2",
"wechaty-redux": "^0.5.7"
},
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions src/chatops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {

export class Chatops {

private static singleton: Chatops
private static singleton?: Chatops

public static instance (
haBot?: HAWechaty,
Expand Down Expand Up @@ -108,30 +108,30 @@ export class Chatops {
{
const image = await info.toFileBox()
await Promise.all(
roomList.map(room => room.say(image))
roomList.map(room => room.say(image)),
)
}
break
case Message.Type.Url:
{
const urlLink = await info.toUrlLink()
await Promise.all(
roomList.map(room => room.say(urlLink))
roomList.map(room => room.say(urlLink)),
)
}
break
default:
{
const typeName = Message.Type[info.type()]
await Promise.all(
roomList.map(room => room.say(`message type: ${typeName}`))
roomList.map(room => room.say(`message type: ${typeName}`)),
)
}
break
}
} else if (info instanceof UrlLink) {
await Promise.all(
roomList.map(room => room.say(info))
roomList.map(room => room.say(info)),
)
}

Expand Down
4 changes: 2 additions & 2 deletions src/deliver-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ async function getRoomList (
if (Array.isArray(idOrList)) {
const roomList = await Promise.all(
idOrList.map(
id => getBot().Room.load(id)
)
id => getBot().Room.load(id),
),
)
return roomList.filter(r => !!r) as Room[]
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/get-bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const duckery = {

type Duckery = typeof duckery

let haWechaty: HAWechaty<Duckery>
let haWechaty: undefined | HAWechaty<Duckery>

export function getBot () {
log.verbose('getWechaty', 'getHAWechaty()')
Expand Down
2 changes: 1 addition & 1 deletion src/get-memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
log,
} from './config.js'

export let memory: MemoryCard
export let memory: undefined | MemoryCard

export function getMemory (name: string): MemoryCard {
log.verbose('getMemory', 'getMemory(%s)', name)
Expand Down
2 changes: 1 addition & 1 deletion src/handlers-probot/pull-request.opened.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const pullRequestOpenedPlugin = (app: Probot) => app.on('pull_request.opened', a

const title = [
`#${pullRequestNumber}`,
pullRequestTitle?.slice(0, Math.max(pullRequestTitle.length, 30)),
pullRequestTitle.slice(0, Math.max(pullRequestTitle.length, 30)),
fullName,
].join(' ')
const url = htmlUrl
Expand Down
12 changes: 5 additions & 7 deletions src/handlers-wechaty/on-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,19 @@ export default async function onMessage (
// }

const text = message.text()
const contact = message.talker()
if (!contact) {
return
}
const talker = message.talker()

if (text.toLowerCase() === 'oss') {

// To Be Fix: Change "OSSChat ChatOps" Group Name to actual group name
log.info('on-message', 'Begin to find the OSSChat ChatOps room')
const room = this.Room.load(CHATOPS_ROOM_ID)
const room = await this.Room.find({ id: CHATOPS_ROOM_ID })

if (room) {
await room.add(contact)
await room.add(talker)

// To Be Fix: Change a formal welcome message
await room.say('Welcome to join OSSChat ChatOps Group', contact)
await room.say('Welcome to join OSSChat ChatOps Group', talker)
}
}
log.info('on-message', 'onMessage(%s)', message)
Expand Down
2 changes: 1 addition & 1 deletion src/handlers-wechaty/on-room-invite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Chatops } from '../chatops.js'

export default async function onRoomInvite (
this : Wechaty,
roomInvitation : RoomInvitation
roomInvitation : RoomInvitation,
): Promise<void> {
log.info('on-room-invite', 'onRoomInvite(%s)', roomInvitation)

Expand Down
18 changes: 9 additions & 9 deletions src/pure-functions/match-org-repo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,31 @@ test('matchRepo', async t => {
'docs',
'wechaty/docs',
),
'should match repo in plan text'
'should match repo in plan text',
)

t.notOk(
matchRepoFullname(
'docs',
'wechaty/matrix',
),
'should not match repo in plan text'
'should not match repo in plan text',
)

t.ok(
matchRepoFullname(
'docs',
'wechaty/*cs',
),
'should match repo in wildcat text'
'should match repo in wildcat text',
)

t.notOk(
matchRepoFullname(
'docs',
'wechaty/*trix',
),
'should not match repo in wildcat text'
'should not match repo in wildcat text',
)
})

Expand All @@ -57,7 +57,7 @@ test('matchOwner between uppercase with lowercase', async t => {
'weCHATY',
'WEchaty/Docs',
),
'should match owner in plan text for different cases'
'should match owner in plan text for different cases',
)
})

Expand All @@ -67,7 +67,7 @@ test('matchRepo between uppercase with lowercase', async t => {
'docs',
'wechaty/Docs',
),
'should match repo in plan text for different cases'
'should match repo in plan text for different cases',
)
})

Expand All @@ -77,7 +77,7 @@ test('matchRepo with empty wildcat', async t => {
'docs',
'wechaty/*Docs*',
),
'should match repo with empty wildcat for different cases'
'should match repo with empty wildcat for different cases',
)
})

Expand All @@ -94,7 +94,7 @@ test('matchRepo with complex wildcat', async t => {
repo,
fullName,
),
'should match repo with complex wildcat for ' + repo
'should match repo with complex wildcat for ' + repo,
)
}
})
Expand All @@ -113,7 +113,7 @@ test('matchRepo with group wildcat', async t => {
repo,
fullName,
),
'should match repo with group match for ' + repo
'should match repo with group match for ' + repo,
)
}
})
2 changes: 1 addition & 1 deletion src/pure-functions/match-org-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function matchOwnerFullname (
): boolean {
return fullName.toLowerCase()
.startsWith(
owner.toLowerCase() + '/'
owner.toLowerCase() + '/',
)
}

Expand Down
11 changes: 7 additions & 4 deletions src/routers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
Room,
Wechaty,
} from 'wechaty'
import { wrapAsyncError } from 'gerror'

import {
log,
Expand All @@ -22,6 +23,8 @@ import { getBot } from './get-bot.js'
// counterSelectors,
// } from './ducks/.js'

const wrapAsync = wrapAsyncError(console.error)

const haBot = getBot()

const FORM_HTML = `
Expand All @@ -33,9 +36,9 @@ const FORM_HTML = `
`

function configureRoutes (router: Router) {
router.get('/dashboard/', rootHandler)
router.get('/chatops/', chatopsHandler)
router.get('/logout/', logoutHandler)
router.get('/dashboard/', wrapAsync(rootHandler))
router.get('/chatops/', wrapAsync(chatopsHandler))
router.get('/logout/', wrapAsync(logoutHandler))
}

async function logoutHandler (
Expand Down Expand Up @@ -145,7 +148,7 @@ async function rootHandler (
html,
htmlCounter,
htmlFoot,
].join('\n')
].join('\n'),
)

}
Expand Down
4 changes: 1 addition & 3 deletions src/setup-finis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ finis(async (code, signal) => {

try {
log.info('RestartReporter', 'finis() setTimeout() going to exit with %d', code)
if (bot) {
await bot.stop()
}
await bot.stop()
} catch (e) {
log.error('RestartReporter', 'finis() setTimeout() exception: %s', e)
} finally {
Expand Down
2 changes: 1 addition & 1 deletion src/wtmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface WtmpEntry {

class Wtmp {

private static singleton: Wtmp
private static singleton?: Wtmp

private bornTime: number
private wtmpList: WtmpEntry[] = []
Expand Down

0 comments on commit 0f86df2

Please sign in to comment.