Skip to content

Commit b50019c

Browse files
authored
chore: update biome configurations and applied settings (#2932)
1 parent f63cfad commit b50019c

43 files changed

Lines changed: 205 additions & 208 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

biome.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
33
"files": {
4-
"ignore": ["examples/**/dist"]
4+
"includes": ["**", "!**/examples/**/dist"]
55
},
66
"formatter": {
77
"enabled": true,
88
"formatWithErrors": false,
9-
"ignore": [],
9+
"includes": ["**"],
1010
"attributePosition": "auto",
1111
"indentStyle": "space",
1212
"indentWidth": 2,
@@ -24,9 +24,26 @@
2424
"recommended": true
2525
}
2626
},
27-
"organizeImports": {
28-
"enabled": true
27+
"assist": {
28+
"actions": {
29+
"source": {
30+
"organizeImports": "on"
31+
}
32+
}
2933
},
34+
"overrides": [
35+
{
36+
"includes": ["examples/**"],
37+
"linter": {
38+
"rules": {
39+
"correctness": {
40+
"noUnusedFunctionParameters": "off",
41+
"noUnusedVariables": "off"
42+
}
43+
}
44+
}
45+
}
46+
],
3047
"vcs": {
3148
"enabled": true,
3249
"clientKind": "git",

examples/custom-receiver/src/FastifyReceiver.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import {
44
type BufferedIncomingMessage,
55
type CodedError,
66
HTTPResponseAck,
7+
HTTPModuleFunctions as httpFunc,
78
type InstallProviderOptions,
89
type InstallURLOptions,
910
type Receiver,
1011
type ReceiverEvent,
1112
ReceiverInconsistentStateError,
1213
type ReceiverProcessEventErrorHandlerArgs,
1314
type ReceiverUnhandledRequestHandlerArgs,
14-
HTTPModuleFunctions as httpFunc,
1515
} from '@slack/bolt';
16-
import { ConsoleLogger, type LogLevel, type Logger } from '@slack/logger';
16+
import { ConsoleLogger, type Logger, type LogLevel } from '@slack/logger';
1717
import { type CallbackOptions, type InstallPathOptions, InstallProvider } from '@slack/oauth';
1818
import Fastify, { type FastifyInstance } from 'fastify';
1919

@@ -163,12 +163,7 @@ export default class FastifyReceiver implements Receiver {
163163

164164
public init(app: App): void {
165165
this.app = app;
166-
if (
167-
this.installer &&
168-
this.installerOptions &&
169-
this.installerOptions.installPath &&
170-
this.installerOptions.redirectUriPath
171-
) {
166+
if (this.installer && this.installerOptions?.installPath && this.installerOptions.redirectUriPath) {
172167
this.fastify.get(this.installerOptions.installPath, async (req, res) => {
173168
await this.installer?.handleInstallPath(req.raw, res.raw, this.installerOptions?.installPathOptions);
174169
});

examples/custom-receiver/src/KoaReceiver.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { type Server, createServer } from 'node:http';
1+
import { createServer, type Server } from 'node:http';
22
import Router from '@koa/router';
33
import {
44
type App,
55
type BufferedIncomingMessage,
66
type CodedError,
77
HTTPResponseAck,
8+
HTTPModuleFunctions as httpFunc,
89
type InstallProviderOptions,
910
type InstallURLOptions,
1011
type Receiver,
1112
type ReceiverEvent,
1213
ReceiverInconsistentStateError,
1314
type ReceiverProcessEventErrorHandlerArgs,
1415
type ReceiverUnhandledRequestHandlerArgs,
15-
HTTPModuleFunctions as httpFunc,
1616
} from '@slack/bolt';
17-
import { ConsoleLogger, type LogLevel, type Logger } from '@slack/logger';
17+
import { ConsoleLogger, type Logger, type LogLevel } from '@slack/logger';
1818
import { type CallbackOptions, type InstallPathOptions, InstallProvider } from '@slack/oauth';
1919
import Koa from 'koa';
2020

@@ -158,12 +158,7 @@ export default class KoaReceiver implements Receiver {
158158

159159
public init(app: App): void {
160160
this.app = app;
161-
if (
162-
this.installer &&
163-
this.installerOptions &&
164-
this.installerOptions.installPath &&
165-
this.installerOptions.redirectUriPath
166-
) {
161+
if (this.installer && this.installerOptions?.installPath && this.installerOptions.redirectUriPath) {
167162
this.router.get(this.installerOptions.installPath, async (ctx) => {
168163
await this.installer?.handleInstallPath(ctx.req, ctx.res, this.installerOptions?.installPathOptions);
169164
});

package-lock.json

Lines changed: 38 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"tsscmp": "^1.0.6"
5959
},
6060
"devDependencies": {
61-
"@biomejs/biome": "^1.9.0",
61+
"@biomejs/biome": "^2.4.15",
6262
"@changesets/cli": "^2.29.8",
6363
"@tsconfig/node20": "^20.1.5",
6464
"@types/chai": "^4.1.7",

src/App.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import util from 'node:util';
2-
import { ConsoleLogger, LogLevel, type Logger } from '@slack/logger';
2+
import { ConsoleLogger, type Logger, LogLevel } from '@slack/logger';
33
import {
4+
addAppMetadata,
45
type FetchFunction,
56
WebAPIHTTPError,
67
WebAPIPlatformError,
78
WebAPIRateLimitedError,
89
WebClient,
910
type WebClientOptions,
10-
addAppMetadata,
1111
} from '@slack/web-api';
1212
import type { Assistant } from './Assistant';
1313
import {
@@ -23,24 +23,25 @@ import {
2323
createSay,
2424
createSayStream,
2525
createSetStatus,
26+
type SayStreamFn,
27+
type SetStatusFn,
2628
} from './context';
27-
import type { SayStreamFn, SetStatusFn } from './context';
28-
import { type ConversationStore, MemoryStore, conversationContext } from './conversation-store';
29+
import { type ConversationStore, conversationContext, MemoryStore } from './conversation-store';
2930
import {
3031
AppInitializationError,
3132
AuthorizationError,
33+
asCodedError,
3234
type CodedError,
3335
InvalidCustomPropertyError,
3436
MultipleListenerError,
35-
asCodedError,
3637
} from './errors';
3738
import {
38-
IncomingEventType,
3939
assertNever,
4040
extractEventChannelId,
4141
extractEventThreadTs,
4242
extractEventTs,
4343
getTypeAndConversation,
44+
IncomingEventType,
4445
isBodyWithTypeEnterpriseInstall,
4546
isEventTypeToSkipAuthorize,
4647
} from './helpers';
@@ -99,7 +100,8 @@ import type {
99100
ViewOutput,
100101
} from './types';
101102
import { contextBuiltinKeys } from './types';
102-
import { type StringIndexed, isRejected } from './types/utilities';
103+
import { isRejected, type StringIndexed } from './types/utilities';
104+
103105
const packageJson = require('../package.json');
104106

105107
export type { ActionConstraints, OptionsConstraints, ShortcutConstraints, ViewConstraints } from './types';
@@ -155,7 +157,7 @@ export interface AppOptions {
155157
attachFunctionToken?: boolean;
156158
}
157159

158-
export { LogLevel, Logger } from '@slack/logger';
160+
export { Logger, LogLevel } from '@slack/logger';
159161

160162
/** Authorization function - seeds the middleware processing and listeners with an authorization context */
161163
export type Authorize<IsEnterpriseInstall extends boolean = false> = (
@@ -1051,7 +1053,7 @@ export default class App<AppCustomContext extends StringIndexed = StringIndexed>
10511053

10521054
// TODO: this logic should be isolated and tested according to the expected behavior
10531055
if (token !== undefined) {
1054-
let pool: WebClientPool | undefined = undefined;
1056+
let pool: WebClientPool | undefined;
10551057
const clientOptionsCopy = { ...this.clientOptions };
10561058
if (authorizeResult.teamId !== undefined) {
10571059
pool = this.clients[authorizeResult.teamId];
@@ -1196,7 +1198,6 @@ export default class App<AppCustomContext extends StringIndexed = StringIndexed>
11961198
const rejectedListenerResults = settledListenerResults.filter(isRejected);
11971199
if (rejectedListenerResults.length === 1) {
11981200
throw rejectedListenerResults[0].reason;
1199-
// biome-ignore lint/style/noUselessElse: I think this is a biome issue actually...
12001201
} else if (rejectedListenerResults.length > 1) {
12011202
throw new MultipleListenerError(rejectedListenerResults.map((rlr) => rlr.reason));
12021203
}
@@ -1323,15 +1324,15 @@ export default class App<AppCustomContext extends StringIndexed = StringIndexed>
13231324
throw new AppInitializationError(
13241325
`${tokenUsage} \n\nSince you have not provided a token or authorize, you might be missing one or more required oauth installer options. See https://docs.slack.dev/tools/bolt-js/concepts/authenticating-oauth/ for these required fields.\n`,
13251326
);
1326-
// biome-ignore lint/style/noUselessElse: I think this is a biome issue actually...
1327-
} else if (authorize !== undefined && usingOauth) {
1327+
}
1328+
if (authorize !== undefined && usingOauth) {
13281329
throw new AppInitializationError(`You cannot provide both authorize and oauth installer options. ${tokenUsage}`);
1329-
// biome-ignore lint/style/noUselessElse: I think this is a biome issue actually...
1330-
} else if (authorize === undefined && usingOauth) {
1330+
}
1331+
if (authorize === undefined && usingOauth) {
13311332
// biome-ignore lint/style/noNonNullAssertion: we know installer is truthy here
13321333
return httpReceiver.installer!.authorize;
1333-
// biome-ignore lint/style/noUselessElse: I think this is a biome issue actually...
1334-
} else if (authorize !== undefined && !usingOauth) {
1334+
}
1335+
if (authorize !== undefined && !usingOauth) {
13351336
return authorize as Authorize<boolean>;
13361337
}
13371338
return undefined;
@@ -1623,9 +1624,9 @@ function escapeHtml(input: string | undefined | null): string {
16231624
}
16241625

16251626
function extractFunctionContext(body: StringIndexed) {
1626-
let functionExecutionId: string | undefined = undefined;
1627-
let functionBotAccessToken: string | undefined = undefined;
1628-
let functionInputs: FunctionInputs | undefined = undefined;
1627+
let functionExecutionId: string | undefined;
1628+
let functionBotAccessToken: string | undefined;
1629+
let functionInputs: FunctionInputs | undefined;
16291630

16301631
// function_executed event
16311632
if (body.event && body.event.type === 'function_executed' && body.event.function_execution_id) {

0 commit comments

Comments
 (0)