Skip to content

Coding Style

Bedrock and Springfield use the following open source tools to follow coding styles and conventions, as well as applying automatic code formatting:

  • ruff for Python style, code quality rules, and import ordering.
  • black for Python code formatting.
  • Prettier for JavaScript code formatting.
  • ESLint for JavaScript code quality rules.
  • Stylelint for Sass/CSS style and code quality rules.

For front-end HTML & CSS conventions, bedrock uses Mozilla's Protocol design system for building components. You can read the Protocol documentation site for more information.

Mozilla also has some more general coding styleguides available, although some of these are now rather outdated:

Test Coverage

When the Python tests are run, a coverage report is generated, showing which lines of the codebase have tests that execute them, and which do not. You can view this report in your browser at file:///path/to/your/checkout/of/bedrock-or-springfield/python_coverage/index.html.

When adding code, please aim to provide solid test coverage, using the coverage report as a guide. This doesn't necessarily mean every single line needs a test, and 100% coverage doesn't mean 0% defects.

Configuring your Code Editor

The codebase includes an .editorconfig file in the root directory that you can use with your code editor to help maintain consistent coding styles. Please see editorconfig.org. for a list of supported editors and available plugins.