Skip to content

Latest commit

 

History

History
69 lines (57 loc) · 1.88 KB

File metadata and controls

69 lines (57 loc) · 1.88 KB

CalCentral JavaScript Styleguide

  • Indentation: 2 spaces

  • List items/properties alphabetically

  • Use an editor that supports .editorconfig. Feel free to have a look at the editor plug-ins

  • Remove console.log() messages when committing your code.

  • Only use anchor tags <a> for actual links, otherwise use <button> instead. This is especially important for IE9.

  • Never use ngBindHtmlUnsafe.

  • Never use innerHTML unless displaying completely static data.

  • Filenames for images should be in the following format: name_name2_00x00.ext. When it's an icon (e.g. 32x32 / 64x64), then start it with icon_.

  • Specify colors in hex format and create a variable for them.

  • Write 0 instead of 0px.

  • Use data-ng-if instead of data-ng-show or data-ng-hide when possible.

  • When you're adding / updating images, make sure to optimize them. (e.g. imageOptim)

  • Use multiple lines for var statements and specify var on each line:

    👎

    var name = 'Jason',
      name2 = 'Mike'

    👍

    var name = 'Jason';
    var name2 = 'Mike';
  • Write objects on multiple lines:

    👎

    var enabled = { faceplant: true };

    👍

    var enabled = {
      faceplant: true
    };
  • Use single quotes when possible

    👎

    var name = "Christian Vuerings";

    👍

    var name = 'Christian Vuerings';
  • Use data-ng- instead of ng- or ng: and add data- for directives

    👎

    <ng:view>
    <span ng-bind="name"></span>
    <input mmddyyvalidator />

    👍

    <div data-ng-view></div>
    <span data-ng-bind="name"></span>
    <input data-mmddyyvalidator />