Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.5/schema.json",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Upgraded to schema v2 by following the v3 Upgrade Gudie and running:

$ npx @biomejs/biome migrate --write

"assist": {
"actions": {
"source": {
"organizeImports": "on"
}
}
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"ignore": [],
"includes": [
"**"
],
"attributePosition": "auto",
"indentStyle": "space",
"indentWidth": 2,
Expand All @@ -18,12 +27,21 @@
"linter": {
"enabled": true,
"rules": {
"recommended": true
"recommended": true,
"style": {
"noParameterAssign": "error",
"useAsConstAssertion": "error",
"useDefaultParameterLast": "error",
"useEnumInitializers": "error",
"useSelfClosingElements": "error",
"useSingleVarDeclarator": "error",
"noUnusedTemplateLiteral": "error",
"useNumberNamespace": "error",
"noInferrableTypes": "error",
"noUselessElse": "error"
}
Comment on lines +31 to +42
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: These are the defaults that the migration command added. I believe they are meant to represent the default, recommended style rules.

}
},
"organizeImports": {
"enabled": true
},
"vcs": {
"enabled": true,
"clientKind": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-hooks/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.5/schema.json",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Each package extends the base biome.json. This is why we need to have 1 PR that upgrades all packages to Biome v2 - because the schema is not compatible with Biome 1.x.

"extends": ["../../biome.json"]
}
8 changes: 6 additions & 2 deletions packages/cli-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"description": "Node implementation of the contract between the Slack CLI and Bolt for JavaScript",
"author": "Slack Technologies, LLC",
"license": "MIT",
"keywords": ["slack", "cli", "hooks"],
"keywords": [
"cli",
"hooks",
"slack"
],
Comment on lines +7 to +11
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: biome linter rule requires multiple element arrays to be on newlines.

"type": "module",
"main": "src/get-hooks.js",
"files": [
Expand Down Expand Up @@ -51,7 +55,7 @@
"semver": "^7.5.4"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@biomejs/biome": "^2.0.5",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Upgrading the biome npm package to v2.

"@types/minimist": "^1.2.5",
"@types/mocha": "^10.0.6",
"@types/node": "^24.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-hooks/src/check-update.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { after, before, describe, it } from 'mocha';
import sinon from 'sinon';

import checkForSDKUpdates, {
createUpdateErrorMessage,
hasAvailableUpdates,
hasBreakingChange,
Comment on lines +9 to 11
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Biome linter rule requires the imports to be sorted.

createUpdateErrorMessage,
} from './check-update.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-hooks/src/protocols.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'node:assert';
import { afterEach, beforeEach, describe, it } from 'mocha';
import sinon from 'sinon';

import { DefaultProtocol, MessageBoundaryProtocol, getProtocol } from './protocols.js';
import { DefaultProtocol, getProtocol, MessageBoundaryProtocol } from './protocols.js';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Biome linter rule requires the imports to be sorted.


describe('protocol implementations', () => {
describe('default protocol', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-test/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.5/schema.json",
"extends": ["../../biome.json"]
}
12 changes: 9 additions & 3 deletions packages/cli-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
"description": "Node.js bindings for the Slack CLI for use in automated testing",
"author": "Salesforce, Inc.",
"license": "MIT",
"keywords": ["slack", "cli", "test"],
"keywords": [
"cli",
"slack",
"test"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist/**/*"],
"files": [
"dist/**/*"
],
"engines": {
"node": ">=18.15.5"
},
Expand All @@ -32,7 +38,7 @@
"winston": "^3.8.2"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@biomejs/biome": "^2.0.5",
"@tsconfig/recommended": "^1.0.6",
"@types/chai": "^4.3.16",
"@types/mocha": "^10.0.6",
Expand Down
3 changes: 1 addition & 2 deletions packages/cli-test/src/cli/cli-process.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { shell } from './shell';

import type { SpawnOptionsWithoutStdio } from 'node:child_process';
import type { ShellProcess } from '../types/shell';
import { shell } from './shell';

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: biome requires the imports to be sorted alphabetically based on their from.

export interface SlackCLIGlobalOptions {
/**
Expand Down
3 changes: 1 addition & 2 deletions packages/cli-test/src/cli/commands/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { SlackCLIProcess } from '../cli-process';

import type { ProjectCommandArguments } from '../../types/commands/common_arguments';
import { SlackCLIProcess } from '../cli-process';

/**
* `slack app delete`
Expand Down
3 changes: 1 addition & 2 deletions packages/cli-test/src/cli/commands/auth.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { ShellProcess } from '../../types/shell';
import {
type SlackCLICommandOptions,
type SlackCLIGlobalOptions,
type SlackCLIHostTargetOptions,
SlackCLIProcess,
} from '../cli-process';

import type { ShellProcess } from '../../types/shell';

type AuthLoginNoPromptArguments = SlackCLIHostTargetOptions & Pick<SlackCLIGlobalOptions, 'verbose'>;
type AuthLoginChallengeExchangeArugments = SlackCLIHostTargetOptions & {
/** @description Challenge string extracted from the Slack client UI after submitting the auth slash command. */
Expand Down
3 changes: 1 addition & 2 deletions packages/cli-test/src/cli/commands/platform.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { ProjectCommandArguments, WorkspaceGrantArgument } from '../../types/commands/common_arguments';
import type { ShellProcess } from '../../types/shell';
import { SlackTracerId } from '../../utils/constants';
import logger from '../../utils/logger';
import { type SlackCLICommandOptions, SlackCLIProcess } from '../cli-process';
import { shell } from '../shell';

import type { ShellProcess } from '../../types/shell';

export interface StringWaitArgument {
/** @description String to wait for in the command output before this function returns. */
stringToWaitFor: string;
Expand Down
3 changes: 1 addition & 2 deletions packages/cli-test/src/cli/shell.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import child from 'node:child_process';
import { assert } from 'chai';
import sinon from 'sinon';

import type { ShellProcess } from '../types/shell';
import { mockProcess } from '../utils/test';
import { shell } from './shell';

import type { ShellProcess } from '../types/shell';

describe('shell module', () => {
const sandbox = sinon.createSandbox();
let spawnSpy: sinon.SinonStub;
Expand Down
3 changes: 1 addition & 2 deletions packages/cli-test/src/cli/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import child from 'node:child_process';

import treekill from 'tree-kill';

import type { ShellProcess } from '../types/shell';
import { timeouts } from '../utils/constants';
import logger from '../utils/logger';

import type { ShellProcess } from '../types/shell';

export const shell = {
/**
* Spawns a shell command
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-test/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { SlackCLI } from './cli';
export { SlackCLIProcess } from './cli/cli-process';
export { SlackTracerId, SlackProduct } from './utils/constants';
export { shell } from './cli/shell';
export { SlackProduct, SlackTracerId } from './utils/constants';

// Check for cli binary path
if (!process.env.SLACK_CLI_PATH) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-test/src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Logger, createLogger, format, transports } from 'winston';
import { createLogger, format, type Logger, transports } from 'winston';

// Configure CLI log level
// Winston logging levels, see: https://github.com/winstonjs/winston#logging
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.5/schema.json",
"extends": ["../../biome.json"]
}
11 changes: 8 additions & 3 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
"description": "Logging utility used by Node Slack SDK",
"author": "Slack Technologies, LLC",
"license": "MIT",
"keywords": ["slack", "logging"],
"keywords": [
"slack",
"logging"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist/**/*"],
"files": [
"dist/**/*"
],
"engines": {
"node": ">= 18",
"npm": ">= 8.6.0"
Expand Down Expand Up @@ -35,7 +40,7 @@
"@types/node": ">=18.0.0"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@biomejs/biome": "^2.0.5",
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"c8": "^10.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/oauth/biome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.5/schema.json",
"extends": ["../../biome.json"]
}
14 changes: 11 additions & 3 deletions packages/oauth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
"description": "Official library for interacting with Slack's Oauth endpoints",
"author": "Slack Technologies, LLC",
"license": "MIT",
"keywords": ["slack", "oauth", "bot", "http", "api"],
"keywords": [
"slack",
"oauth",
"bot",
"http",
"api"
],
"main": "dist/index.js",
"files": ["dist/**/*"],
"files": [
"dist/**/*"
],
"engines": {
"node": ">=18",
"npm": ">=8.6.0"
Expand Down Expand Up @@ -39,7 +47,7 @@
"lodash.isstring": "^4"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@biomejs/biome": "^2.0.5",
"@types/chai": "^4",
"@types/mocha": "^10",
"@types/sinon": "^17",
Expand Down
30 changes: 17 additions & 13 deletions packages/oauth/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
export { Logger, LogLevel } from './logger';
// InstallProvider inputs / outputs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: This file was a bit of a nightmare because Biome wants the imports to be sorted alphabetically, but the file has sorted the imports logically. To keep the logical ordering, I used Biome's "Chunks", which are comments separated by newlines. Everything inside a chunk is sorted.

// Chunk 1

export A
export B
export C

// Chunk 2

export A
export B
export C

// Chunk 3

export A
// Comment about B
export B
export C

// The inputs / outputs of the InstallProvider module
export { AuthorizeResult } from './authorize-result';
export { Installation, OrgInstallation } from './installation';
export { InstallationQuery, OrgInstallationQuery } from './installation-query';

// The errors that can be returned by this module
export * from './errors';
// InstallProvider core

// The core part of this library
export {
InstallProvider,
OAuthV2TokenRefreshResponse,
OAuthV2Response,
OAuthV2TokenRefreshResponse,
} from './install-provider';

export { InstallProviderOptions } from './install-provider-options';
export { InstallURLOptions } from './install-url-options';
// the callback handlers for the `/slack/install` path
export { InstallPathOptions } from './install-path-options';
export { default as defaultRenderHtmlForInstallPath } from './default-render-html-for-install-path';
// the callback handlers for the `/slack/oauth_redirect` path

// InstallProvider callback handlers

// Callback handlers for the `/slack/oauth_redirect` path
export {
CallbackOptions,
defaultCallbackFailure,
defaultCallbackSuccess,
} from './callback-options';
// Callback handlers for the `/slack/install` path
export { default as defaultRenderHtmlForInstallPath } from './default-render-html-for-install-path';
export { InstallPathOptions } from './install-path-options';

// InstallationStore and StateStore interfaces

// InstallationStore interface and built-in implementations
export * from './installation-stores';
// StateStore interface and built-in implementations
export * from './state-stores';

// Utilities

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Anyone got a better chunk category name for errors and logger?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Half joking, but "errors" and "logger" wouldn't be not descriptive 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good suggestion, actually! Commit 22308ce updates it to "Errors" and "Logging" 🙇🏻

export * from './errors';
export { Logger, LogLevel } from './logger';
2 changes: 1 addition & 1 deletion packages/oauth/src/install-provider-options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LogLevel, Logger } from '@slack/logger';
import type { Logger, LogLevel } from '@slack/logger';
import type { WebClientOptions } from '@slack/web-api';

import type { InstallURLOptions } from './install-url-options';
Expand Down
10 changes: 7 additions & 3 deletions packages/oauth/src/install-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,27 @@ rewiremock(() => require('@slack/web-api')).with({
},
});
rewiremock.enable();

import {
type CallbackOptions,
type InstallPathOptions,
InstallProvider,
type Installation,
type InstallationStore,
type InstallPathOptions,
InstallProvider,
type StateStore,
} from './index';

rewiremock.disable();

Comment on lines +43 to +45
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Biome requires blank newlines between import/export and functions.

import type { OAuthV2AccessArguments, OauthV2AccessResponse, WebClientOptions } from '@slack/web-api';
import {
type AuthorizationError,
ErrorCode,
type GenerateInstallUrlError,
type InstallerInitializationError,
} from './errors';
import { LogLevel, type Logger } from './logger';
import { type Logger, LogLevel } from './logger';

const webClientOptions: WebClientOptions = { timeout: 1000 };

async function mockedV2AccessResp(options: OAuthV2AccessArguments): Promise<OauthV2AccessResponse> {
Expand Down
2 changes: 1 addition & 1 deletion packages/oauth/src/install-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type { InstallURLOptions } from './install-url-options';
import type { Installation } from './installation';
import type { InstallationQuery } from './installation-query';
import { type InstallationStore, MemoryInstallationStore } from './installation-stores';
import { LogLevel, type Logger, getLogger } from './logger';
import { getLogger, type Logger, LogLevel } from './logger';
import { ClearStateStore, type StateStore } from './state-stores';

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/oauth/src/installation-stores/file-store.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const storedInstallation = {
isEnterpriseInstall: false,
};

// TODO: valid tests with org-wide installations
const storedOrgInstallation = {
// TODO: valid tests with org-wide installations, remove _ prefix when implemented.
const _storedOrgInstallation = {
Comment on lines +45 to +46
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Biome requires an _ prefix on unused variables and functions. This one seemed intentionally left for the TODO, so I've added an underscore prefix to it.

team: null,
enterprise: {
id: 'test-enterprise-id',
Expand Down
Loading