style guide
This commit is contained in:
parent
7b2c566cad
commit
2f8aa00595
13
style.txt
13
style.txt
@ -17,8 +17,8 @@ Basics:
|
|||||||
|
|
||||||
|
|
||||||
JavaScript version:
|
JavaScript version:
|
||||||
Stick with ES6 features. Do not rely on any vendor-specific extensions (such
|
Stick to ES6 features. Do not rely on any vendor-specific extensions (such as
|
||||||
as Firefox often offers). ES6 features not yet supported by major browsers are
|
Firefox often offers). ES6 features not yet supported by major browsers are
|
||||||
okay as long as there is a well-supported and reasonable polyfill (such as
|
okay as long as there is a well-supported and reasonable polyfill (such as
|
||||||
babel) available.
|
babel) available.
|
||||||
|
|
||||||
@ -33,6 +33,15 @@ APIs:
|
|||||||
- Prefer 'Promise' to one-shot continuations whenever possible.
|
- Prefer 'Promise' to one-shot continuations whenever possible.
|
||||||
- Prefer handlebars templates to poking around in the DOM.
|
- Prefer handlebars templates to poking around in the DOM.
|
||||||
|
|
||||||
|
|
||||||
|
Dependency Injection (DI):
|
||||||
|
DI is a useful pattern when components need to be replaced by mocks or have
|
||||||
|
multiple co-existing implementations. But DI also makes code overly generic,
|
||||||
|
bureaucratic and less readble. Only use DI if there is a definite need for it,
|
||||||
|
do not use it by default. Inject individual dependencies via class
|
||||||
|
constructors and avoid service locators.
|
||||||
|
|
||||||
|
|
||||||
Misc:
|
Misc:
|
||||||
- Do not use ES6 template strings for constructing HTML,
|
- Do not use ES6 template strings for constructing HTML,
|
||||||
use TSX/JSX literals instead.
|
use TSX/JSX literals instead.
|
||||||
|
Loading…
Reference in New Issue
Block a user