diff options
| author | Xavier Morel <xmo@openerp.com> | 2011-06-17 11:13:44 +0200 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2011-06-17 11:13:44 +0200 |
| commit | 7ed58deec796efcd4c3cd14bb85f789d081428c6 (patch) | |
| tree | ed64f7233f03f299d8c0d19625b649ddc8e7c6bb /doc | |
| parent | ceda49fbad9b86b140012011c4a07087aa31537d (diff) | |
[FIX] remove trailing commas in object literals
bzr revid: xmo@openerp.com-20110617091344-mlal79a9poagjwm3
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/source/project.rst | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/doc/source/project.rst b/doc/source/project.rst index 80ed0e86143..38e2fe507dd 100644 --- a/doc/source/project.rst +++ b/doc/source/project.rst @@ -22,6 +22,13 @@ Coding issues and coding conventions Javascript coding ~~~~~~~~~~~~~~~~~ +These are a number of guidelines for javascript code. More than coding +conventions, these are warnings against potentially harmful or sub-par +constructs. + +Ideally, you should be able to configure your editor or IDE to warn you against +these kinds of issues. + Use ``var`` for *all* declarations ********************************** @@ -53,6 +60,29 @@ All local *and global* variables should be declared via ``var``. page (because it's used in embedded mode) each instance will have its own internal but global-to-its-objects data. +Do not leave trailing commas in object literals +*********************************************** + +While it is legal to leave trailing commas in Python dictionaries, e.g. + +:: + + foo = { + 'a': 1, + 'b': 2, + } + +and it's valid in ECMAScript 5 and most browsers support it in Javascript, you +should *never* use trailing commas in Javascript object literals: + +* Internet Explorer does *not* support trailing commas (at least until and + including Internet Explorer 8), and trailing comma will cause hard-to-debug + errors in it + +* JSON does not accept trailing comma (it is a syntax error), and using them + in object literals puts you at risks of using them in literal JSON strings + as well (though there are few reasons to write JSON by hand) + Writing documentation +++++++++++++++++++++ |
