Format

Biome - Fast formatter and linter for JavaScript and TypeScript.

bot.ts uses Biomearrow-up-right for code formatting and linting. Biome is an extremely fast tool that combines the functionality of Prettier (formatting) and ESLint (linting) in a single package.

Usage

bun run format

What it does

The format command runs Biome with the --write flag, which:

  1. Formats your code according to the configured style

  2. Lints your code for potential errors and bad practices

  3. Organizes imports alphabetically and removes unused ones

  4. Fixes auto-fixable issues automatically

Configuration

Biome is configured via the biome.json file at the root of your project.

Default configuration

{
  "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
  "formatter": {
    "enabled": true,
    "indentStyle": "tab"
  },
  "organizeImports": {
    "enabled": true
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "double",
      "semicolons": "asNeeded"
    }
  }
}

Formatting options

Option
Default
Description

indentStyle

"tab"

Use tabs for indentation

quoteStyle

"double"

Use double quotes for strings

semicolons

"asNeeded"

Only add semicolons where necessary

Linter rules

The framework uses Biome's recommended rules with some exceptions to accommodate common Discord bot patterns:

Rule
Setting
Reason

noExplicitAny

off

Allows any type when needed

noConfusingVoidType

off

Allows void in union types

noAssignInExpressions

off

Allows assignments in expressions

noNonNullAssertion

off

Allows ! non-null assertions

noParameterAssign

off

Allows reassigning function parameters

noForEach

off

Allows .forEach() method

noDelete

off

Allows delete operator

useImportExtensions

off

No file extensions required in imports

Customization

Changing formatting style

To use spaces instead of tabs:

Adding semicolons everywhere

Using single quotes

Ignoring files

Enabling stricter rules

IDE Integration

VS Code

Install the Biome extensionarrow-up-right for VS Code to get:

  • Format on save

  • Real-time linting

  • Quick fixes

Add to your .vscode/settings.json:

Other editors

Biome has plugins for many editors:

Running checks without fixing

To check for issues without auto-fixing them:

To see what would change without writing:

CI Integration

Add Biome to your CI pipeline:

More information

For complete documentation, visit the Biome websitearrow-up-right.

Last updated