Skip to main content
Lichess maintains consistent code style across its Scala backend and TypeScript frontend. Follow these guidelines to ensure your contributions match the codebase conventions.

Scala Style

Lichess uses Scala 3 with automatic formatting via scalafmt.

Scalafmt Configuration

The project uses scalafmt version 3.10.7 with the following key settings:
.scalafmt.conf

Formatting Rules

Rewrite Rules

Scalafmt automatically applies these transformations:

1. Sort Modifiers

2. Avoid Infix Notation

3. String Interpolation

4. Import Cleanup

File-Specific Overrides

Build files use Scala 2.13 dialect:

Running Scalafmt

Most IDEs can run scalafmt automatically on save. Configure your editor to use the project’s .scalafmt.conf file.

TypeScript Style

Lichess uses oxlint for TypeScript/JavaScript linting.

Oxlint Configuration

The project uses oxlint with plugins for promises, TypeScript, and unicorn rules:
.oxlintrc.json

Key Rules

Variable Declarations

Imports

Unused Variables

Variables matching these patterns are ignored:
  • varsIgnorePattern: "^_"
  • argsIgnorePattern: "^_"
  • caughtErrorsIgnorePattern: "^_"

Promises

TypeScript-Specific Rules

Modern Array Methods

Restricted Global Variables

Direct access to window globals is restricted. Use explicit window. or document. prefixes to avoid accidental global usage.
The configuration restricts 200+ window globals like addEventListener, focus, blur, etc. to prevent implicit global access.

File-Specific Overrides

Utility scripts have relaxed rules:

Running Oxlint

CSS/SCSS Style

Lichess uses stylelint for CSS and SCSS linting.

Stylelint Configuration

.stylelintrc.json

Key Rules

Color Notation

Variable Naming

The configuration disables pattern enforcement for:
  • custom-property-pattern
  • selector-class-pattern
  • selector-id-pattern
  • scss/dollar-variable-pattern

SCSS Features

Running Stylelint

Editor Integration

Configure your editor to use these tools automatically:
Install these extensions:
  • Scala (Metals)
  • oxlint
  • Stylelint
Configure format on save in settings:
  • Enable scalafmt: Settings → Editor → Code Style → Scala → Scalafmt
  • Install oxlint plugin from marketplace
  • Enable Stylelint: Settings → Languages → Style Sheets → Stylelint
Use formatters via null-ls or conform.nvim:
  • scalafmt for Scala
  • oxlint for TypeScript
  • stylelint for SCSS
Example with null-ls:

Pre-commit Checks

Before committing, ensure:
1

Run formatters

2

Check for errors

3

Run tests

CI will automatically check code style on all pull requests. Fix any style violations before requesting review.

Next Steps

Pull Request Guidelines

Learn how to submit your code

Contributing Overview

Back to contributing overview