JavaScript - HealthTeacher/style-guide GitHub Wiki
Much of this was inspired by idiomatic-js. Please add to this guide if you find any particular patterns or styles that we've adopted internally.
Table of Contents
General
- We lint all our JavaScript with StandardJS.
Naming
- JavaScript hooks should follow the
js-myJsHookpattern. - Testing hooks should follow the
qa-myTestHookpattern. - Do NOT apply styles to
js-orqa-prefixed classes.
Marionette
- Label
Views withclassNameexclusively, notid. - Order view properties/methods as follows:
- View properties (alphabetically)
- Child view properties (alphabetically)
- Marionette methods (by lifecycle of the view)
- Custom methods (alphabetically)
React
- Use
static propTypesandstatic defaultPropsat the top of React classes. (This does not work in the teacher app currently)
class MyComponent extends React.Component {
static propTypes = {
...
};
static defaultProps = {
...
};
render() {
...
}
}