Brave Code Style Standards: A Complete Guide to ESLint, Standard.js, and clang-format

Brave Browser enforces code style through Standard.js for JavaScript, Chromium's upstream clang-format for C++, and automated CI checks including gn_check and tslint.

Brave's open-source browser repository maintains strict code quality through specific style guides that vary by language. Understanding these Brave code style standards ensures your contributions pass automated checks and match the project's formatting requirements. The repository uses distinct tooling for JavaScript/TypeScript, C++, and build configuration files.

JavaScript and TypeScript Standards

Brave adopts Standard.js as its sole JavaScript and TypeScript style guide. This zero-configuration linting standard requires no .eslintrc file and eliminates bikeshedding about formatting rules.

Standard.js Configuration

According to the repository's CONTRIBUTING.md (lines 53–54), contributors should install a Standard plugin for their editor rather than configuring ESLint manually. The package.json at the repository root defines the linting script that invokes the Standard CLI.

The Standard.js rules enforce:

  • No semicolons required
  • Single quotes for strings
  • No trailing spaces
  • Consistent indentation (2 spaces)

Running the Linter Locally

Before submitting changes, verify JavaScript compliance using the npm script defined in the repository:


# From the repository root

npm run lint

This command executes Standard across all .js and .ts files, flagging violations such as unused variables, inconsistent spacing, or missing quotes.

Editor Integration

Install the "Standard – JavaScript Standard Style" plugin for VS Code or equivalent plugins for Vim, Emacs, or WebStorm. These plugins provide real-time underlining of style errors as you type, ensuring your code matches the same rules used by npm run lint before you commit.

C++ Code Formatting with clang-format

For C++ code within the Chromium-based core, Brave defers entirely to Chromium's clang-format style. The repository does not ship a custom .clang-format file; instead, it reuses the upstream Chromium formatting rules.

Chromium Upstream Rules

As documented in CONTRIBUTING.md (line 54), contributors should configure their editors to use clang-format according to Chromium's documentation. The formatting rules cover:

  • Indentation width (2 spaces)
  • Column limit (80 characters)
  • Pointer alignment (left-aligned)
  • Brace wrapping conventions

Formatting Commands

Format individual files or the entire C++ codebase using clang-format with the Chromium style:


# Format a single file

clang-format -i path/to/file.cc

# Format all C++ files in the repository

# (Chromium source lives under src/)

git ls-files '*.cc' '*.h' | xargs clang-format -i

Ensure you use the clang-format version matching Chromium's current toolchain to avoid formatting inconsistencies.

Build System and CI Checks

Beyond source code formatting, Brave enforces style and correctness checks on build configuration files through automated CI pipelines.

GN and TypeScript Linting

The pull request template (.github/PULL_REQUEST_TEMPLATE.md, line 11) mandates running specific checks before submission:

npm run gn_check    # Validates GN build files

npm run tslint      # TypeScript-specific linting

These commands ensure that build configurations follow Chromium's GN formatting standards and that TypeScript files meet additional type-specific linting rules beyond Standard.js.

Pre-PR Verification

Before creating a pull request, run the complete verification suite:

npm run test -- brave_browser_tests   # Browser-level tests

npm run test -- brave_unit_tests      # Unit tests

npm run lint                          # JavaScript lint

npm run gn_check                      # GN build check

npm run tslint                        # TypeScript lint

All six checks must pass and are listed as a checklist in the PR template. The CI pipeline will block merging until these style and test requirements are satisfied.

Summary

Brave Browser maintains distinct code style standards across its multilingual codebase:

  • JavaScript/TypeScript: Enforced via Standard.js through npm run lint, requiring no ESLint configuration files
  • C++: Formatted using Chromium's clang-format rules without custom Brave modifications
  • Build files: Validated through npm run gn_check and npm run tslint in CI pipelines

Contributors should configure editor plugins for Standard.js and clang-format, then run the full verification suite before submitting pull requests.

Frequently Asked Questions

Does Brave use ESLint or Standard.js?

Brave uses Standard.js exclusively. While Standard.js runs on top of ESLint internally, the repository requires no .eslintrc configuration file. Contributors simply run npm run lint or install a Standard editor plugin to enforce the zero-config rules.

Where are the clang-format rules defined?

Brave does not maintain a custom .clang-format file. Instead, the repository uses Chromium's upstream clang-format style rules. As noted in CONTRIBUTING.md, developers should follow Chromium's formatting documentation and use the clang-format version matching the Chromium toolchain.

What checks run in Brave's CI pipeline?

The CI pipeline runs six mandatory checks listed in the PR template: brave_browser_tests, brave_unit_tests, npm run lint (Standard.js), npm run gn_check (GN build files), and npm run tslint (TypeScript). All must pass before merging.

How do I fix linting errors before submitting a PR?

Run npm run lint for JavaScript/TypeScript files and clang-format -i for C++ files. For automatic fixing where possible, Standard.js supports standard --fix. Always verify with npm run gn_check and npm run tslint to ensure build files meet requirements before creating your pull request.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →