From 4b484ecd80cd3e4a8fbaed0b7ebaaf541063a9cc Mon Sep 17 00:00:00 2001 From: LuChao Date: Wed, 17 Jan 2024 14:12:01 +0800 Subject: [PATCH] lining fixes (#65) * lining fixes * 1.12.2 --- package.json | 2 +- src/contrib/ding-dong/ding-dong.spec.ts | 4 ++-- src/finders/contact-finder.ts | 4 ++-- src/finders/room-finder.ts | 4 ++-- src/mappers/message-mapper.ts | 2 +- src/matchers/contact-matcher.spec.ts | 6 +++--- src/matchers/contact-matcher.ts | 2 +- src/matchers/language-matcher.spec.ts | 2 +- src/matchers/language-matcher.ts | 2 +- src/matchers/message-matcher.spec.ts | 6 +++--- src/matchers/message-matcher.ts | 2 +- src/matchers/room-matcher.spec.ts | 6 +++--- src/matchers/room-matcher.ts | 2 +- src/matchers/string-matcher.spec.ts | 6 +++--- src/matchers/string-matcher.ts | 2 +- src/talkers/contact-talker.spec.ts | 2 +- src/talkers/contact-talker.ts | 2 +- src/talkers/message-talker.spec.ts | 2 +- src/talkers/room-talker.spec.ts | 8 ++++---- src/talkers/room-talker.ts | 6 +++--- 20 files changed, 36 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index 2e84fd4..b5674d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-plugin-contrib", - "version": "1.12.1", + "version": "1.12.2", "description": "Wechaty Plugin Ecosystem Contrib Package", "type": "module", "exports": { diff --git a/src/contrib/ding-dong/ding-dong.spec.ts b/src/contrib/ding-dong/ding-dong.spec.ts index 35c4ef7..f91c430 100755 --- a/src/contrib/ding-dong/ding-dong.spec.ts +++ b/src/contrib/ding-dong/ding-dong.spec.ts @@ -28,7 +28,7 @@ test('isMatchConfig {mention: true}', async t => { const mentionMessage = await new Promise(resolve => { room.once('message', resolve) - fixture.mocker.player.say('ding', [fixture.mocker.bot]).to(fixture.mocker.room) + fixture.mocker.player.say('ding', [ fixture.mocker.bot ]).to(fixture.mocker.room) }) let result: boolean = await isMatch(mentionMessage) t.equal(result, true, 'should match for room mention self message') @@ -54,7 +54,7 @@ test('isMatchConfig {mention: false}', async t => { const mentionMessage = await new Promise(resolve => { room.once('message', resolve) - fixture.mocker.player.say('ding', [fixture.mocker.bot]).to(fixture.mocker.room) + fixture.mocker.player.say('ding', [ fixture.mocker.bot ]).to(fixture.mocker.room) }) let result: boolean = await isMatch(mentionMessage) t.equal(result, true, 'should match for room mention self message') diff --git a/src/finders/contact-finder.ts b/src/finders/contact-finder.ts index 758da02..44f4812 100644 --- a/src/finders/contact-finder.ts +++ b/src/finders/contact-finder.ts @@ -16,7 +16,7 @@ export function contactFinder (options?: ContactFinderOptions): ContactFinderFun } if (!Array.isArray(options)) { - options = [options] + options = [ options ] } const optionList = options @@ -42,7 +42,7 @@ export function contactFinder (options?: ContactFinderOptions): ContactFinderFun } } - const dedupedContactList = [...new Set(allContactList.filter(Boolean))] + const dedupedContactList = [ ...new Set(allContactList.filter(Boolean)) ] return dedupedContactList } } diff --git a/src/finders/room-finder.ts b/src/finders/room-finder.ts index a9901e2..e939388 100644 --- a/src/finders/room-finder.ts +++ b/src/finders/room-finder.ts @@ -16,7 +16,7 @@ export function roomFinder (options?: RoomFinderOptions): RoomFinderFunction { } if (!Array.isArray(options)) { - options = [options] + options = [ options ] } const optionList = options @@ -41,7 +41,7 @@ export function roomFinder (options?: RoomFinderOptions): RoomFinderFunction { } } - const dedupedRoomList = [...new Set(allRoomList.filter(Boolean))] + const dedupedRoomList = [ ...new Set(allRoomList.filter(Boolean)) ] return dedupedRoomList } } diff --git a/src/mappers/message-mapper.ts b/src/mappers/message-mapper.ts index 31a4e3e..4e066e3 100644 --- a/src/mappers/message-mapper.ts +++ b/src/mappers/message-mapper.ts @@ -48,7 +48,7 @@ async function normalizeMappedMessageList ( if (Array.isArray(options)) { optionList = options } else { - optionList = [options] + optionList = [ options ] } for (const option of optionList) { diff --git a/src/matchers/contact-matcher.spec.ts b/src/matchers/contact-matcher.spec.ts index 26c3db2..235d801 100755 --- a/src/matchers/contact-matcher.spec.ts +++ b/src/matchers/contact-matcher.spec.ts @@ -43,7 +43,7 @@ test('contactMatcher() with string option', async t => { t.ok(await idMatcher(contactIdOk), 'should match expected contact by id') t.notOk(await idMatcher(contactNameOk), 'should not match contact by name') - const idListMatcher = contactMatcher([TEXT_OK]) + const idListMatcher = contactMatcher([ TEXT_OK ]) t.notOk(await idListMatcher(contactNotOk), 'should not match unexpected contact by id list') @@ -57,7 +57,7 @@ test('contactMatcher() with string option', async t => { t.notOk(await regexpMatcher(contactIdOk), 'should match contact id by regexp') t.ok(await regexpMatcher(contactNameOk), 'should match expected contact name by regexp') - const regexpListMatcher = contactMatcher([new RegExp(TEXT_OK)]) + const regexpListMatcher = contactMatcher([ new RegExp(TEXT_OK) ]) t.notOk(await regexpListMatcher(contactNotOk), 'should not match unexpected contact by regexp list') @@ -76,7 +76,7 @@ test('contactMatcher() with string option', async t => { t.ok(await functionMatcher(contactNameOk), 'should match expected name by function') t.ok(await functionMatcher(contactIdOk), 'should match expected id by function') - const functionListMatcher = contactMatcher([roomFilter]) + const functionListMatcher = contactMatcher([ roomFilter ]) t.notOk(await functionListMatcher(contactNotOk), 'should not match unexpected contact by function list') diff --git a/src/matchers/contact-matcher.ts b/src/matchers/contact-matcher.ts index 9d96b84..784bf83 100644 --- a/src/matchers/contact-matcher.ts +++ b/src/matchers/contact-matcher.ts @@ -19,7 +19,7 @@ export function contactMatcher ( } if (!Array.isArray(matcherOptions)) { - matcherOptions = [matcherOptions] + matcherOptions = [ matcherOptions ] } const matcherOptionList = matcherOptions diff --git a/src/matchers/language-matcher.spec.ts b/src/matchers/language-matcher.spec.ts index 21d7044..c318657 100755 --- a/src/matchers/language-matcher.spec.ts +++ b/src/matchers/language-matcher.spec.ts @@ -46,7 +46,7 @@ test('languageMatcher() with array options', async t => { const CHINESE_TEXT = '你好' const ENGLISH_TEXT = 'hello' - const matchLanguage = languageMatcher(['chinese', 'english']) + const matchLanguage = languageMatcher([ 'chinese', 'english' ]) let result = matchLanguage(CHINESE_TEXT) t.ok(result, 'should match Chinese language') diff --git a/src/matchers/language-matcher.ts b/src/matchers/language-matcher.ts index d681387..5ac46b6 100644 --- a/src/matchers/language-matcher.ts +++ b/src/matchers/language-matcher.ts @@ -68,7 +68,7 @@ function languageMatcher ( if (Array.isArray(options)) { codeList = options } else { - codeList = [options] + codeList = [ options ] } return function matchLanguage (text: string) { diff --git a/src/matchers/message-matcher.spec.ts b/src/matchers/message-matcher.spec.ts index 22d7db0..9481e7f 100755 --- a/src/matchers/message-matcher.spec.ts +++ b/src/matchers/message-matcher.spec.ts @@ -74,7 +74,7 @@ test('messageMatcher() with string option', async t => { t.ok(await idMatcher(messageTopicOk), 'should match expected topic by id') t.ok(await idMatcher(messageIdOk), 'should match expected text by id') - const idListMatcher = messageMatcher([TEXT_OK]) + const idListMatcher = messageMatcher([ TEXT_OK ]) t.notOk(await idListMatcher(messageNotOk), 'should not match unexpected message by id list') @@ -90,7 +90,7 @@ test('messageMatcher() with string option', async t => { t.ok(await regexpMatcher(messageTopicOk), 'should match expected topic by regexp') t.ok(await regexpMatcher(messageTextOk), 'should match expected text by regexp') - const regexpListMatcher = messageMatcher([new RegExp(TEXT_OK)]) + const regexpListMatcher = messageMatcher([ new RegExp(TEXT_OK) ]) t.notOk(await regexpListMatcher(messageNotOk), 'should not match unexpected message by regexp') @@ -112,7 +112,7 @@ test('messageMatcher() with string option', async t => { t.ok(await functionMatcher(messageTopicOk), 'should match expected topic by function') t.ok(await functionMatcher(messageTextOk), 'should match expected text by function') - const functionListMatcher = messageMatcher([messageFilter]) + const functionListMatcher = messageMatcher([ messageFilter ]) t.notOk(await functionListMatcher(messageNotOk), 'should not match unexpected message by function list') diff --git a/src/matchers/message-matcher.ts b/src/matchers/message-matcher.ts index ac19aea..21008be 100644 --- a/src/matchers/message-matcher.ts +++ b/src/matchers/message-matcher.ts @@ -19,7 +19,7 @@ function messageMatcher ( } if (!Array.isArray(matcherOptions)) { - matcherOptions = [matcherOptions] + matcherOptions = [ matcherOptions ] } const matcherOptionList = matcherOptions diff --git a/src/matchers/room-matcher.spec.ts b/src/matchers/room-matcher.spec.ts index 931e56f..7219d07 100755 --- a/src/matchers/room-matcher.spec.ts +++ b/src/matchers/room-matcher.spec.ts @@ -44,7 +44,7 @@ test('roomMatcher() with string option', async t => { t.ok(await idMatcher(roomIdOk), 'should match expected room by id') t.notOk(await idMatcher(roomTopicOk), 'should not match room by topic') - const idListMatcher = roomMatcher([TEXT_OK]) + const idListMatcher = roomMatcher([ TEXT_OK ]) t.notOk(await idListMatcher(roomNotOk), 'should not match unexpected room by id list') @@ -58,7 +58,7 @@ test('roomMatcher() with string option', async t => { t.notOk(await regexpMatcher(roomIdOk), 'should match room id by regexp') t.ok(await regexpMatcher(roomTopicOk), 'should match expected room topic by regexp') - const regexpListMatcher = roomMatcher([new RegExp(TEXT_OK)]) + const regexpListMatcher = roomMatcher([ new RegExp(TEXT_OK) ]) t.notOk(await regexpListMatcher(roomNotOk), 'should not match unexpected room by regexp list') @@ -77,7 +77,7 @@ test('roomMatcher() with string option', async t => { t.ok(await functionMatcher(roomTopicOk), 'should match expected topic by function') t.ok(await functionMatcher(roomIdOk), 'should match expected id by function') - const functionListMatcher = roomMatcher([roomFilter]) + const functionListMatcher = roomMatcher([ roomFilter ]) t.notOk(await functionListMatcher(roomNotOk), 'should not match unexpected room by function list') diff --git a/src/matchers/room-matcher.ts b/src/matchers/room-matcher.ts index e8f54d8..ed0c49e 100644 --- a/src/matchers/room-matcher.ts +++ b/src/matchers/room-matcher.ts @@ -27,7 +27,7 @@ export function roomMatcher ( } if (!Array.isArray(matcherOptions)) { - matcherOptions = [matcherOptions] + matcherOptions = [ matcherOptions ] } const matcherOptionList = matcherOptions diff --git a/src/matchers/string-matcher.spec.ts b/src/matchers/string-matcher.spec.ts index 984ed2a..f8c9ecd 100755 --- a/src/matchers/string-matcher.spec.ts +++ b/src/matchers/string-matcher.spec.ts @@ -21,7 +21,7 @@ test('stringMatcher()', async t => { t.ok(await textMatcher(TEXT_OK), 'should match expected TEXT') t.notOk(await textMatcher(TEXT_NOT_OK), 'should not match unexpected string') - const textListMatcher = stringMatcher([TEXT_OK]) + const textListMatcher = stringMatcher([ TEXT_OK ]) t.ok(await textListMatcher(TEXT_OK), 'should match expected TEXT by list') t.notOk(await textListMatcher(TEXT_NOT_OK), 'should not match unexpected string by list') @@ -29,7 +29,7 @@ test('stringMatcher()', async t => { t.notOk(await regexpMatcher(TEXT_NOT_OK), 'should not match unexpected string by regexp') t.ok(await regexpMatcher(TEXT_OK), 'should match expected from by regexp') - const regexpListMatcher = stringMatcher([new RegExp(TEXT_OK)]) + const regexpListMatcher = stringMatcher([ new RegExp(TEXT_OK) ]) t.notOk(await regexpListMatcher(TEXT_NOT_OK), 'should not match unexpected string by regexp list') t.ok(await regexpListMatcher(TEXT_OK), 'should match expected from by regexp list') @@ -39,7 +39,7 @@ test('stringMatcher()', async t => { t.notOk(await functionMatcher(TEXT_NOT_OK), 'should not match unexpected string by function') t.ok(await functionMatcher(TEXT_OK), 'should match expected from by function') - const functionListMatcher = stringMatcher([stringFilter]) + const functionListMatcher = stringMatcher([ stringFilter ]) t.notOk(await functionListMatcher(TEXT_NOT_OK), 'should not match unexpected string by function list') t.ok(await functionListMatcher(TEXT_OK), 'should match expected from by function list') }) diff --git a/src/matchers/string-matcher.ts b/src/matchers/string-matcher.ts index 419d108..22bc3ee 100644 --- a/src/matchers/string-matcher.ts +++ b/src/matchers/string-matcher.ts @@ -18,7 +18,7 @@ export function stringMatcher ( } if (!Array.isArray(options)) { - options = [options] + options = [ options ] } const optionsList = options diff --git a/src/talkers/contact-talker.spec.ts b/src/talkers/contact-talker.spec.ts index 318a535..c5c1217 100755 --- a/src/talkers/contact-talker.spec.ts +++ b/src/talkers/contact-talker.spec.ts @@ -22,7 +22,7 @@ test('contactTalker()', async t => { const OPTIONS_TEXT: ContactTalkerOptions = EXPECTED_TEXT const OPTIONS_FUNCTION: ContactTalkerOptions = spy1 - const OPTIONS_FUNCTION_LIST: ContactTalkerOptions = [spy2, spy3] + const OPTIONS_FUNCTION_LIST: ContactTalkerOptions = [ spy2, spy3 ] const mockContact = { say: spy4, diff --git a/src/talkers/contact-talker.ts b/src/talkers/contact-talker.ts index 6c8fce8..e58289f 100644 --- a/src/talkers/contact-talker.ts +++ b/src/talkers/contact-talker.ts @@ -19,7 +19,7 @@ export function contactTalker (options?: ContactTalkerOptions) { } if (!Array.isArray(options)) { - options = [options] + options = [ options ] } const optionList = options diff --git a/src/talkers/message-talker.spec.ts b/src/talkers/message-talker.spec.ts index 96a2d51..0013861 100755 --- a/src/talkers/message-talker.spec.ts +++ b/src/talkers/message-talker.spec.ts @@ -20,7 +20,7 @@ test('messageTalker()', async t => { const EXPECTED_TEXT = 'text' const OPTIONS_TEXT: MessageTalkerOptions = EXPECTED_TEXT - const OPTIONS_FUNCTION_LIST: MessageTalkerOptions = [spy2, spy3] + const OPTIONS_FUNCTION_LIST: MessageTalkerOptions = [ spy2, spy3 ] const mockMessage = { say: spy4, diff --git a/src/talkers/room-talker.spec.ts b/src/talkers/room-talker.spec.ts index 7450001..34643aa 100755 --- a/src/talkers/room-talker.spec.ts +++ b/src/talkers/room-talker.spec.ts @@ -21,7 +21,7 @@ test('roomTalker()', async t => { const EXPECTED_TEXT = 'text' const OPTIONS_TEXT: RoomTalkerOptions = EXPECTED_TEXT - const OPTIONS_FUNCTION_LIST: RoomTalkerOptions = [spy2, spy3] + const OPTIONS_FUNCTION_LIST: RoomTalkerOptions = [ spy2, spy3 ] const mockContact = {} as any as Contact const mockRoom = { @@ -84,7 +84,7 @@ test('roomTalker() with room list', async t => { const EXPECTED_TEXT = 'text' const OPTIONS_TEXT: RoomTalkerOptions = EXPECTED_TEXT - const OPTIONS_FUNCTION_LIST: RoomTalkerOptions = [spy2, spy3] + const OPTIONS_FUNCTION_LIST: RoomTalkerOptions = [ spy2, spy3 ] const mockContact1 = {} as any as Contact const mockContact2 = {} as any as Contact @@ -105,7 +105,7 @@ test('roomTalker() with room list', async t => { let talkRoom = roomTalker(OPTIONS_TEXT) spy4.resetHistory() - await talkRoom([mockRoom1, mockRoom2], [mockContact1, mockContact2]) + await talkRoom([ mockRoom1, mockRoom2 ], [ mockContact1, mockContact2 ]) t.ok(spy4.calledOnce, 'should called the room1.say once') t.equal(spy4.args[0]![0], EXPECTED_TEXT, 'should say the expected text') t.equal(spy4.args[0]![1], mockContact1, 'should pass contact1 to say') @@ -118,7 +118,7 @@ test('roomTalker() with room list', async t => { talkRoom = roomTalker(OPTIONS_FUNCTION_LIST) spy2.resetHistory() spy3.resetHistory() - await talkRoom([mockRoom1, mockRoom2], [mockContact1, mockContact2]) + await talkRoom([ mockRoom1, mockRoom2 ], [ mockContact1, mockContact2 ]) t.ok(spy2.called, 'should called the functions 1') t.equal(spy2.args[0]![0], mockRoom1, 'should called the functions 1/1 with mockRoom1') t.equal(spy2.args[0]![1], mockContact1, 'should called the functions 1/2 with mockContact1') diff --git a/src/talkers/room-talker.ts b/src/talkers/room-talker.ts index 35cb565..5de3976 100644 --- a/src/talkers/room-talker.ts +++ b/src/talkers/room-talker.ts @@ -20,7 +20,7 @@ export function roomTalker (options?: RoomTalkerOptions) { } if (!Array.isArray(options)) { - options = [options] + options = [ options ] } const optionList = options @@ -39,12 +39,12 @@ export function roomTalker (options?: RoomTalkerOptions) { ) if (!Array.isArray(rooms)) { - rooms = [rooms] + rooms = [ rooms ] } if (typeof contacts === 'undefined') { contacts = [] } else if (!Array.isArray(contacts)) { - contacts = [contacts] + contacts = [ contacts ] } for (const room of rooms) {