doc/coding_standards_js.rst
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 05 Sep 2011 16:48:37 +0200
branchstable
changeset 7756 98e34ae4cf89
parent 6049 f0ae98fa85a1
permissions -rw-r--r--
[form fields doc] explain when field.role should be None
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6049
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     1
Javascript Coding Standards
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     2
---------------------------
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     3
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     4
(Draft, to be continued)
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     5
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
:Naming: camelCase, except for CONSTANTS
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     7
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     8
Indentation rules
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     9
~~~~~~~~~~~~~~~~~
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    10
- espace avant accolade ouvrante
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    11
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    12
- retour à la ligne après accolade ouvrante (éventuellement pas
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    13
  de retour à la ligne s'il y a tout sur la même ligne, mais ce n'est
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    14
  pas le cas ici.
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    15
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    16
- no tabs
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    17
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    18
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    19
Documentation
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
~~~~~~~~~~~~~
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
XXX explain comment format for documentation generation
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    22
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    23
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    24
Coding
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    25
~~~~~~
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
- Don't forget 'var' before variable definition, and semi-colon (';') after **each** statement.
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    27
- Check the firebug console for deprecation warnings
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    28
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    29
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    30
API usage
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    31
~~~~~~~~~
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    32
- unless intended, use jQuery('container') rather than jqNode('container')
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    33
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    34
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    35
See also
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    36
~~~~~~~~
f0ae98fa85a1 [doc] started js/css coding standards
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    37
http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml