style
This commit is contained in:
parent
bcc70d6949
commit
362c2e0f2f
15
style.txt
15
style.txt
@ -1,10 +1,10 @@
|
|||||||
Javascript style
|
TypeScript style
|
||||||
================
|
================
|
||||||
|
|
||||||
Basics:
|
Basics:
|
||||||
- Indent with 2 spaces.
|
- Indent with 2 spaces.
|
||||||
- Keep a maximum line length of 120 characters.
|
- Keep a maximum line length of 120 characters.
|
||||||
- Prefer "double quotes" for strings/
|
- Prefer "double quotes" for strings.
|
||||||
- Never omit optional semicolons.
|
- Never omit optional semicolons.
|
||||||
- Do not put opening braces or brackets on a new line.
|
- Do not put opening braces or brackets on a new line.
|
||||||
- Call functions without spaces: foo(bar)
|
- Call functions without spaces: foo(bar)
|
||||||
@ -12,12 +12,21 @@ Basics:
|
|||||||
- Declare "use strict;".
|
- Declare "use strict;".
|
||||||
- Use rocket (=>) syntax for anonymous functions. If an anonymous function is
|
- Use rocket (=>) syntax for anonymous functions. If an anonymous function is
|
||||||
too long, make it a named function.
|
too long, make it a named function.
|
||||||
|
- Use the strict equality operator (===).
|
||||||
- Document functions with JSDoc comments (http://usejsdoc.org).
|
- Document functions with JSDoc comments (http://usejsdoc.org).
|
||||||
|
|
||||||
|
|
||||||
|
JavaScript version:
|
||||||
|
Stick with ES6 features. Do not rely on any vendor-specific extensions (such
|
||||||
|
as 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
|
||||||
|
babel) available.
|
||||||
|
|
||||||
|
|
||||||
Names:
|
Names:
|
||||||
- Use PascalCase for classes/types, camelCase for variables, functions and
|
- Use PascalCase for classes/types, camelCase for variables, functions and
|
||||||
properties, UPPER_SNAKE_CASE for constants, kebab-case for event names.
|
properties, UPPER_SNAKE_CASE for constants, kebab-case for event names.
|
||||||
- Only capitalize the first letter of an acronym in identifiers.
|
- Only capitalize the first letter of an acronym in identifiers (e.g. HttpResponseCode).
|
||||||
|
|
||||||
|
|
||||||
APIs:
|
APIs:
|
||||||
|
Loading…
Reference in New Issue
Block a user