Coding Guidelines
João Moreno edited this page
·
11 revisions
Pages 21
- Home
- Breaking Changes
- Code Build Process
- Code Organization
- Coding Guidelines
- Contributor License Agreement
- December Pre Release
- December Test Plan
- Design Goals
- Development Process
- Feedback Channels
- How to Contribute
- Issue Tracking
- Iteration Plans
- November Plan
- Previous Releases
- Related Projects
- Releases and Branches
- Requested Extensions
- Roadmap
- Submitting Bugs and Suggestions
- Show 6 more pages…
Coding Guidelines
Git
We prefer a rebase workflow and occasional feature branches. Most work happens directly on the master branch. For that reason, we recommend setting the pull.rebase setting to true.
git config --global pull.rebase true
Indentation
We use tabs, not spaces.
Names
- Use PascalCase for
typenames - Use PascalCase for
enumvalues - Use camelCase for
functionandmethodnames - Use camelCase for
propertynames andlocal variables - Use whole words in names when possible
Types
- Do not export
typesorfunctionsunless you need to share it across multiple components - Do not introduce new
typesorvaluesto the global namespace
Comments
- Use JSDoc style comments for
functions,interfaces,enums, andclasses
Strings
- Use "double quotes" for strings shown to the user that need to be externalized (localized)
- Use 'single quotes' otherwise
- All strings visible to the user need to be externalized
Style
- Use arrow functions
=>over anonymous function expressions - Only surround arrow function parameters when necessary. For example,
(x) => x + xis wrong but the following are correct:
x => x + x
(x,y) => x + y
<T>(x: T, y: T) => x === y- Always surround loop and conditional bodies with curly braces
- Open curly braces always go on the same line as whatever necessitates them
- Parenthesized constructs should have no surrounding whitespace. A single space follows commas, colons, and semicolons in those constructs. For example:
for (var i = 0, n = str.length; i < 10; i++) { }
if (x < 10) { }
function f(x: number, y: string): void { }

