Skip to content

Conversation

mwbrooks
Copy link
Member

@mwbrooks mwbrooks commented Jun 25, 2025

Summary

This pull request upgrades @biomejs/biome from 1.8.3 to 2.0.5 using the Biome v2 Migration Guide.

The following packages are upgraded:

  • @slack/socket-mode
  • @slack/cli-hooks
  • @slack/cli-test
  • @slack/logger
  • @slack/oauth
  • @slack/rtm-api
  • @slack/types
  • @slack/web-api
  • @slack/webhook

Open PRs that are related to this migration:

Reviewers

Biome v2 appears to have made changes to the organizeImports assist, which is used to sort imports and exports. Most of the changes in this PR are from new rules. Most of the time, alphabetically sorted makes sense. But there are a few situations where it's better to sort by logic (e.g. import the main client then it's types and callbacks).

I'm not advocating for the changes in this PR. I simply migrated to Biome v2. If these changes don't jive with you, then I can explore disabling organizeImports to see if it feels better for us.

Requirements (place an x in each [ ])

@mwbrooks mwbrooks self-assigned this Jun 25, 2025
@mwbrooks mwbrooks added semver:patch pkg:web-api applies to `@slack/web-api` pkg:rtm-api applies to `@slack/rtm-api` pkg:webhook applies to `@slack/webhook` pkg:logger applies to `@slack/logger` pkg:types applies to `@slack/types` pkg:oauth applies to `@slack/oauth` pkg:socket-mode applies to `@slack/socket-mode` pkg:cli-hooks applies to `@slack/cli-hooks` pkg:cli-test applies to `@slack/cli-test` dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Jun 25, 2025
Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 95.34884% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.71%. Comparing base (181d486) to head (fbe3737).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2281      +/-   ##
==========================================
- Coverage   92.71%   92.71%   -0.01%     
==========================================
  Files          38       38              
  Lines       10609    10607       -2     
  Branches      683      683              
==========================================
- Hits         9836     9834       -2     
  Misses        761      761              
  Partials       12       12              
Flag Coverage Δ
cli-hooks 95.23% <ø> (ø)
cli-test 94.74% <100.00%> (-0.02%) ⬇️
oauth 77.39% <100.00%> (ø)
socket-mode 61.87% <71.42%> (+0.05%) ⬆️
web-api 97.97% <100.00%> (+<0.01%) ⬆️
webhook 96.66% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mwbrooks mwbrooks changed the title Mwbrooks biome 2 migration chore(deps-dev): bump @biomejs/biome to v2 for all packages Jun 25, 2025
Copy link
Member Author

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

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

Some comments to help the kind reviewers understand why these changes were made 🙇🏻

@@ -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

Comment on lines +31 to +42
"style": {
"noParameterAssign": "error",
"useAsConstAssertion": "error",
"useDefaultParameterLast": "error",
"useEnumInitializers": "error",
"useSelfClosingElements": "error",
"useSingleVarDeclarator": "error",
"noUnusedTemplateLiteral": "error",
"useNumberNamespace": "error",
"noInferrableTypes": "error",
"noUselessElse": "error"
}
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.

@@ -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.

@@ -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.

Comment on lines +7 to +11
"keywords": [
"cli",
"hooks",
"slack"
],
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.

} from './RTMClient';

export { Logger, LogLevel } from './logger';
// 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.

note: Added a // Utilities chunk to keep the RTMClient export at the top of the file.

Comment on lines +11 to +15

// const { WebClient } = require('@slack/web-api');
// const webClient = new WebClient(process.env.SLACK_BOT_TOKEN, {
// logLevel,
// });
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 didn't like the unused variable, but it's important for the example. I've commented it out, similar to how we've commented out the serverPingTimeout above. The alternative is an _webClient prefix, but that could be misunderstood as a recommended naming pattern.

Copy link
Member

Choose a reason for hiding this comment

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

@mwbrooks Thanks for catching this with comments! I think it's useful to keep with these files too, for fast reference 🙏 ✨

At a glance I didn't realize this was an unused variable also, so I am glad for this linter setting 👾

Comment on lines +18 to +26
{
"includes": ["src/index.ts"],
"assist": {
"actions": {
"source": {
"organizeImports": "off"
}
}
}
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 one is important. src/index.ts requires the imports to be a specific, logical order but Biome requires the imports to be alphabetical. Right now, the Biome v2 Supressions (e.g. // biome-ignore lint/suspicious/noPrototypeBuiltins: reason why) don't work for the assist category. So, my workaround was to disable the organizeImports for that specific file. 🤷🏻

Comment on lines +240 to 241
// biome-ignore lint/suspicious/noPrototypeBuiltins: TODO use hasOwn instead of hasOwnProperty
if (!Object.prototype.hasOwnProperty.call(toComplete, compareString)) {
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 wants .hasOwn instead of .hasOwnProperty. I didn't feel comfortable making this change here because it uses a .call(...) and I wasn't sure about test coverage.

Copy link
Member

Choose a reason for hiding this comment

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

@mwbrooks Thanks for saving this in a TODO - it would be tough to catch in this PR if it caused regressions of past Node versions 😓

@@ -1,5 +1,6 @@
import assert from 'node:assert';
import { WebClient } from '../../../dist/index.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 requires a newline between imports and logic.

@mwbrooks mwbrooks marked this pull request as ready for review June 25, 2025 23:30
Copy link
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

LGTM! And thanks biome for the wonderful linting upgrades as always.

I'm leaving a few comments but no suggested changes. A few more updates landed in the following PRs that we might want to ignore until this merges, but all is testing well:

🚢 💨

Comment on lines +11 to +15

// const { WebClient } = require('@slack/web-api');
// const webClient = new WebClient(process.env.SLACK_BOT_TOKEN, {
// logLevel,
// });
Copy link
Member

Choose a reason for hiding this comment

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

@mwbrooks Thanks for catching this with comments! I think it's useful to keep with these files too, for fast reference 🙏 ✨

At a glance I didn't realize this was an unused variable also, so I am glad for this linter setting 👾

export * from './message-attachments';
export * from './message-metadata';
export * from './views';
Copy link
Member

Choose a reason for hiding this comment

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

👁‍🗨 The * export worries me sometimes but I believe we're safe against name collisions in the build step.

Comment on lines +240 to 241
// biome-ignore lint/suspicious/noPrototypeBuiltins: TODO use hasOwn instead of hasOwnProperty
if (!Object.prototype.hasOwnProperty.call(toComplete, compareString)) {
Copy link
Member

Choose a reason for hiding this comment

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

@mwbrooks Thanks for saving this in a TODO - it would be tough to catch in this PR if it caused regressions of past Node versions 😓

@@ -1,4 +1,4 @@
import { ConsoleLogger, type LogLevel, type Logger } from '@slack/logger';
import { ConsoleLogger, type Logger, type LogLevel } from '@slack/logger';
Copy link
Member

Choose a reason for hiding this comment

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

📣 Rambling but I thought capital letters appeared before lowercase! 😉

export * from './state-stores';

// Utilities
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 😉

@@ -38,7 +38,7 @@ export class StateStoreChaiTestRunner {
it('should detect old state values', async () => {
const { stateStore } = this;
const installUrlOptions = { scopes: ['channels:read'] };
const fifteenMinutesLater = new Date(new Date().getTime() + 15 * 60 * 1000);
const fifteenMinutesLater = new Date(Date.now() + 15 * 60 * 1000);
Copy link
Member

Choose a reason for hiding this comment

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

🧠 TIL this was the same thing! Thank you for making this change.

@@ -105,7 +106,7 @@ describe('IncomingWebhook', () => {
try {
await webhook.send({ channel: 'different' });
assert.fail('expected rejection');
} catch (error) {
} catch (_err) {
Copy link
Member

Choose a reason for hiding this comment

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

📣 @mwbrooks err and _err are good choices!

@mwbrooks mwbrooks merged commit f1ebcc6 into main Jul 2, 2025
57 checks passed
@mwbrooks mwbrooks deleted the mwbrooks-biome-2-migration branch July 2, 2025 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code pkg:cli-hooks applies to `@slack/cli-hooks` pkg:cli-test applies to `@slack/cli-test` pkg:logger applies to `@slack/logger` pkg:oauth applies to `@slack/oauth` pkg:rtm-api applies to `@slack/rtm-api` pkg:socket-mode applies to `@slack/socket-mode` pkg:types applies to `@slack/types` pkg:web-api applies to `@slack/web-api` pkg:webhook applies to `@slack/webhook` semver:patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants