2019-01-22 19:27:56 +03:00
|
|
|
# Code Style
|
2015-09-30 17:28:31 +03:00
|
|
|
|
2019-01-22 19:27:56 +03:00
|
|
|
## UI
|
2018-09-18 06:03:06 +03:00
|
|
|
|
2018-11-16 11:28:34 +03:00
|
|
|
We use Prettier for JS/JSX formatting and the [Airbnb](https://github.com/airbnb/javascript)
|
|
|
|
guide for non-style related best practices. Both are validated using ESlint (see Validating
|
2019-02-06 22:34:08 +03:00
|
|
|
Javascript in the [Installation section](installation.md#validating-javascript)).
|
2018-11-16 11:28:34 +03:00
|
|
|
|
2019-01-22 19:13:47 +03:00
|
|
|
Prettier is also used to format JSON/CSS/HTML/Markdown/YAML. However these are not supported
|
|
|
|
by ESLint, so instead are validated using Prettier's CLI. To manually check their formatting
|
|
|
|
(as well as that of JS/JSX) using Prettier, run `yarn format:check`, or to apply formatting
|
|
|
|
fixes run `yarn format`.
|
|
|
|
|
|
|
|
However we recommend that you instead
|
|
|
|
[add Prettier to your editor/IDE](https://prettier.io/docs/en/editors.html)
|
2018-11-16 11:28:34 +03:00
|
|
|
and enable "format on save" for the most seamless development workflow.
|
2018-11-16 11:07:49 +03:00
|
|
|
|
|
|
|
Imports in JS/JSX must be ordered like so (with newlines between each group):
|
2019-01-22 19:27:56 +03:00
|
|
|
|
2018-11-16 11:07:49 +03:00
|
|
|
1. external modules (eg `'react'`)
|
|
|
|
2. modules from a parent directory (eg `'../foo'`)
|
|
|
|
3. "sibling" modules from the same or a sibling's directory (eg `'./bar'` or './bar/baz')
|
2018-11-16 11:28:34 +03:00
|
|
|
|
|
|
|
For CSS, we use [reactstrap](https://reactstrap.github.io/) and Bootstrap's utility classes as
|
|
|
|
much as possible before adding custom CSS to a style sheet. Any custom style that can be made
|
2020-02-27 21:01:46 +03:00
|
|
|
reusable should be named generically and stored in the `ui/css/treeherder-custom-styles.css` file.
|